Reads a H5AD file and returns a SingleCellExperiment object.
readH5AD(
file,
X_name = NULL,
use_hdf5 = FALSE,
reader = c("python", "R"),
verbose = NULL,
...
)
String containing a path to a .h5ad
file.
Name used when saving X
as an assay. If NULL
looks for an
X_name
value in uns
, otherwise uses "X"
.
Logical scalar indicating whether assays should be loaded as HDF5-based matrices from the HDF5Array package.
Which HDF5 reader to use. Either "python"
for reading with
the anndata Python package via reticulate or "R"
for
zellkonverter's native R reader.
Logical scalar indicating whether to print progress messages.
If NULL
uses getOption("zellkonverter.verbose")
.
Arguments passed on to AnnData2SCE
layers
Arguments specifying how
these slots are converted. If TRUE
everything in that slot is converted, if
FALSE
nothing is converted and if a character vector only those items or
columns are converted.
uns
Arguments specifying how
these slots are converted. If TRUE
everything in that slot is converted, if
FALSE
nothing is converted and if a character vector only those items or
columns are converted.
var
Arguments specifying how
these slots are converted. If TRUE
everything in that slot is converted, if
FALSE
nothing is converted and if a character vector only those items or
columns are converted.
obs
Arguments specifying how
these slots are converted. If TRUE
everything in that slot is converted, if
FALSE
nothing is converted and if a character vector only those items or
columns are converted.
varm
Arguments specifying how
these slots are converted. If TRUE
everything in that slot is converted, if
FALSE
nothing is converted and if a character vector only those items or
columns are converted.
obsm
Arguments specifying how
these slots are converted. If TRUE
everything in that slot is converted, if
FALSE
nothing is converted and if a character vector only those items or
columns are converted.
varp
Arguments specifying how
these slots are converted. If TRUE
everything in that slot is converted, if
FALSE
nothing is converted and if a character vector only those items or
columns are converted.
obsp
Arguments specifying how
these slots are converted. If TRUE
everything in that slot is converted, if
FALSE
nothing is converted and if a character vector only those items or
columns are converted.
raw
Arguments specifying how
these slots are converted. If TRUE
everything in that slot is converted, if
FALSE
nothing is converted and if a character vector only those items or
columns are converted.
skip_assays
Logical scalar indicating whether to skip conversion of
any assays in sce
or adata
, replacing them with empty sparse matrices
instead.
A SingleCellExperiment object is returned.
Setting use_hdf5 = TRUE
allows for very large datasets to be efficiently
represented on machines with little memory. However, this comes at the cost
of access speed as data needs to be fetched from the HDF5 file upon request.
When first run, this function will instantiate a conda environment containing all of the necessary dependencies. This will not be performed on any subsequent run or if any other zellkonverter function has been run prior to this one.
Setting reader = "R"
will use an experimental native R reader instead of
reading the file into Python and converting the result. This avoids the need
for a Python environment and some of the issues with conversion but is still
under development and is likely to return slightly different output.
writeH5AD()
, to write a SingleCellExperiment object to a
H5AD file.
AnnData2SCE()
, for developers to convert existing AnnData instances to a
SingleCellExperiment.
library(SummarizedExperiment)
file <- system.file("extdata", "krumsiek11.h5ad", package = "zellkonverter")
sce <- readH5AD(file)
class(assay(sce))
#> [1] "matrix" "array"
sce2 <- readH5AD(file, use_hdf5 = TRUE)
class(assay(sce2))
#> [1] "DelayedMatrix"
#> attr(,"package")
#> [1] "DelayedArray"
sce3 <- readH5AD(file, reader = "R")