Bioconductor / DelayedArray

A unified framework for working transparently with on-disk and in-memory array-like datasets
https://bioconductor.org/packages/DelayedArray
24 stars 9 forks source link

Support extract_sparse_array for DelayedAbind objects. #81

Closed LTLA closed 3 years ago

LTLA commented 3 years ago

Pretty much as it says:

library(Matrix)
x <- rsparsematrix(10, 20, 0.1)
colnames(x) <- letters[1:20]
y <- rsparsematrix(10, 30, 0.1)
colnames(y) <- 1:30

library(DelayedArray)
x0 <- DelayedArray(x)
y0 <- DelayedArray(y)

Z <- cbind(x0, y0)
is_sparse(Z) 
## [1] TRUE

all.equal(colSums(Z), colSums(as.matrix(Z)))
## [1] TRUE

all.equal(colSums(Z[,50:1]), colSums(as.matrix(Z)[,50:1]))
## [1] TRUE

Wasn't entirely sure where to put these tests, given that there don't seem to be any RUnit function for DelayedAbind.

Closes #80.

hpages commented 3 years ago

Looking into this now. Sorry for the delay.

hpages commented 3 years ago

So the real important piece that was missing here is an abind() for SparseArraySeed objects. I'm adding one to SparseArraySeed-utils.R. Does what your .combine_abinded_sparse_array_seeds() does but follows the style of simple_abind() and uses get_dims_to_bind(), combine_dims_along(), and combine_dimnames_along(). Will have unit tests.

LTLA commented 3 years ago

okay great. Should I close this?

hpages commented 3 years ago

I'll close when things are ready/pushed.

hpages commented 3 years ago

Merged with some minor edits via commit d03a6beafabb39d9a6bee33ba2004c931fecaf61 (DelayedArray 0.17.5). Thanks!