H5ADMatrix-class | R Documentation |
h5ad
files are HDF5 files used for on-disk representation
of AnnData Python objects. At the very minimum, they contain a central
data matrix, named X
, of shape #observations x #variables, and
possibly additional data matrices (stored in the HDF5 group /layers
)
that share the shape and dimnames of X
.
See https://anndata.readthedocs.io/ for more information.
The H5ADMatrix class is a DelayedMatrix subclass
for representing and operating on the central matrix of an h5ad
file, or any matrix in its /layers
group.
All the operations available for DelayedMatrix objects work on H5ADMatrix objects.
## Constructor function:
H5ADMatrix(filepath, layer=NULL)
filepath |
The path (as a single string) to the |
layer |
|
H5ADMatrix()
returns an H5ADMatrix object of shape #variables x
#observations. Note that in Python and HDF5 the shape of this matrix is
considered to be #observations x #variables, but in R it is transposed.
This follows the widely adopted convention of transposing HDF5 matrices
when they get loaded into R.
https://anndata.readthedocs.io/ for AnnData Python objects
and the h5ad
format.
HDF5Array objects for representing conventional (a.k.a. dense) HDF5 datasets as DelayedArray objects.
H5SparseMatrix objects for representing HDF5 sparse matrices as DelayedMatrix objects.
DelayedMatrix objects in the DelayedArray package.
The H5ADMatrixSeed helper class.
readH5AD
and
writeH5AD
in
the zellkonverter package for
importing/exporting an h5ad
file as/from a
SingleCellExperiment object.
SparseArray objects in the SparseArray package.
library(zellkonverter)
h5ad_file <- system.file("extdata", "krumsiek11.h5ad",
package="zellkonverter")
X <- H5ADMatrix(h5ad_file)
X
class(X) # H5ADMatrix
is(X, "DelayedMatrix") # TRUE
class(seed(X)) # Dense_H5ADMatrixSeed
dim(X)
path(X)
is_sparse(X) # FALSE
## Use coercion to load the full dataset into memory:
as.matrix(X) # as ordinary array (usually not recommended)
## Not run:
## Works only if H5ADMatrix object is sparse!
as(X, "dgCMatrix") # as dgCMatrix
as(X, "SparseArray") # as SparseArray object (most efficient)
SparseArray(X) # equivalent to 'as(X, "SparseArray")'
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.