Is there a way to get `cor` to work?
还没有人认领这个 Issue。
评估
调研方向
首先重现报告的 cor(DelayedArray(x), DelayedArray(y)) 错误,并将其与提供的 delayedCov 示例进行比较。以 issue 中描述的 Pearson 相关行为为目标,并验证等效的矩阵和 DelayedArray 输入在没有数值类型错误的情况下产生匹配的结果。
由索引模型根据 Issue 内容生成。
描述
When I try cor, I get errors like Error in cor(DelayedArray(x), DelayedArray(y)) : 'x' must be numeric. Am I missing something simple?
If it's not implemented, I have a little function for this and I could send a pull request.
#' Drop-in replacement for cov or cor; tolerates DelayedArray input. Pearson correlation only.
#'
delayedCov = function(x, y = x, do_cor = F){
mux = colMeans(x)
muy = colMeans(y)
zx = sweep(x, 2, mux, "-")
zy = sweep(y, 2, muy, "-")
covxy = t(zx) %*% zy
covxy = covxy / nrow(x)
if(do_cor){
sx = sqrt(colMeans(zx^2))
sy = sqrt(colMeans(zy^2))
covxy = Matrix::Diagonal(x = 1/sx) %*% covxy %*% Matrix::Diagonal(x = 1/sy)
}
covxy
}
# tests
x = matrix(rnorm(1000), ncol = 10)
y = matrix(rnorm(1000), ncol = 10)
plot(delayedCov(x, y), cov(x, y)); abline(a = 0, b = 1)
plot(delayedCov(x, y, do_cor = T), cor(x, y)); abline(a = 0, b = 1)
plot(delayedCov(DelayedArray(x), DelayedArray(y), do_cor = T), cor(x, y)); abline(a = 0, b = 1)
- 主要语言
- R
- 星标
- 29
- 派生
- 12
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Bioconductor/DelayedArray 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 38/100
Bioconductor/DelayedArray#129 · 11 条评论 ·
-
难度 4/5 3-5 天 新手友好度 45/100
Bioconductor/DelayedArray#127 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 25/100
Bioconductor/DelayedArray#125 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
Bioconductor/DelayedArray#123 ·
-
难度 5/5 一周以上 新手友好度 20/100
Bioconductor/DelayedArray#122 ·
查看 Bioconductor/DelayedArray 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
robjhyndman/forecast#1220 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
JamesHWade/deputy#192 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
bug triage_needed
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 72/100
pharmaverse/rtables#1123 · 1 条评论 · 1 个 reaction ·