Convert another AnnData
object to an HDF5AnnData
object
Arguments
- adata
An
AnnData
object to be converted toHDF5AnnData
- file
The file name (character) of the
.h5ad
file- compression
The compression algorithm to use when writing the HDF5 file. Can be one of
"none"
,"gzip"
or"lzf"
. Defaults to"none"
.- mode
The mode to open the HDF5 file:
a
creates a new file or opens an existing one for read/writer
opens an existing file for readingr+
opens an existing file for read/writew
creates a file, truncating any existing onesw-
/x
are synonyms, creating a file and failing if it already exists
Value
An HDF5AnnData
object with the same data as the input AnnData
object.
See also
Other object converters:
as_AnnData()
,
as_InMemoryAnnData
,
as_Seurat
,
as_SingleCellExperiment
Examples
ad <- AnnData(
X = matrix(1:5, 3L, 5L),
layers = list(
A = matrix(5:1, 3L, 5L),
B = matrix(letters[1:5], 3L, 5L)
),
obs = data.frame(row.names = LETTERS[1:3], cell = 1:3),
var = data.frame(row.names = letters[1:5], gene = 1:5),
)
ad$as_HDF5AnnData("test.h5ad")
#> AnnData object with n_obs × n_vars = 3 × 5
#> obs: 'cell'
#> var: 'gene'
#> layers: 'A', 'B'
# remove file
file.remove("test.h5ad")
#> [1] TRUE