Is there a way to get `cor` to work?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Start by reproducing the reported cor(DelayedArray(x), DelayedArray(y)) error and compare it with the supplied delayedCov examples. Use the Pearson correlation behavior described in the issue as the target, and verify that equivalent matrix and DelayedArray inputs produce matching results without the numeric-type error.
Written by the indexing model from the issue text.
Description
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)
- Dominant language
- R
- Stars
- 29
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Bioconductor/DelayedArray
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Bioconductor/DelayedArray#129 · 11 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Bioconductor/DelayedArray#127 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Bioconductor/DelayedArray#125 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Bioconductor/DelayedArray#123 ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
Bioconductor/DelayedArray#122 ·
All issues in Bioconductor/DelayedArray
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
easystats/performance#950 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
briandconnelly/airnow#9 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OHDSI/CohortConstructor#774 ·
-
pre-review R TeX Track: 5 (DSAIS)
Difficulty 1/5 Under an hour Newbie friendliness 60/100
openjournals/joss-reviews#11330 · 7 comments ·