SOMA Blockwise Read Iterator for Sparse Matrices
Source:R/BlockwiseIter.R
BlockwiseSparseReadIter.Rd
Class 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
sr
SOMA read pointer
array
Underlying
SOMASparseNDArray
coords
Named list of
CoordsStrider
objects; must be named afterarray$dimnames()
axis
Axis to iterate over in a blockwise manner
...
Ignored
repr
Representation of the sparse matrix to return; choose from:
“
T
”: returns aTsparseMatrix
“
R
”: returns anRsparseMatrix
“
C
”: returns aCsparseMatrix
Note: passing
repr
of “R
” or “C
” are only available if re-indexing is enabled on axes0
or1
, respectivelyreindex_disable_on_axis
Additional 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/RtmpjD0Pq2/blockwise-matrix27092490ffab/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()
}