SOMA Blockwise Read Iterator for Sparse Matrices
Source:R/BlockwiseIter.R
BlockwiseSparseReadIter.RdClass that allows for blockwise read iteration of SOMA reads as sparse matrices.
Super classes
tiledbsoma::ReadIter -> tiledbsoma::BlockwiseReadIterBase -> BlockwiseSparseReadIter
Methods
Method new()
Create.
Usage
BlockwiseSparseReadIter$new(
sr,
array,
coords,
axis,
...,
repr = "T",
reindex_disable_on_axis = NA
)Arguments
srSOMA read pointer
arrayUnderlying
SOMASparseNDArraycoordsNamed list of
CoordsStriderobjects; must be named afterarray$dimnames()axisAxis to iterate over in a blockwise manner
...Ignored
reprRepresentation of the sparse matrix to return; choose from:
“
T”: returns aTsparseMatrix“
R”: returns anRsparseMatrix“
C”: returns aCsparseMatrix
Note: passing
reprof “R” or “C” are only available if re-indexing is enabled on axes0or1, respectivelyreindex_disable_on_axisAdditional axes that will not be re-indexed; the following values may be used as shorthands for common settings:
“
TRUE”: disable re-indexing on all axes“
NA”: re-index only onaxis, disable re-indexing on all others“
FALSE”: re-index on all axes, do not disable re-indexing
Examples
dir <- withr::local_tempfile(pattern = "blockwise-matrix")
dir.create(dir, recursive = TRUE)
(exp <- load_dataset("soma-exp-pbmc-small", dir))
#> <SOMAExperiment>
#> uri: /tmp/RtmpgbdEWv/blockwise-matrix276a47dfc6d1/soma-exp-pbmc-small
qry <- exp$axis_query("RNA")
xqry <- qry$X("data")
iter <- xqry$blockwise(0L, size = 20L, reindex_disable_on_axis = TRUE)$sparse_matrix()
stopifnot(inherits(iter, "BlockwiseSparseReadIter"))
while (!iter$read_complete()) {
block <- iter$read_next()
}