bioalpha.h5ad_map.SparseDatasetMap.as_format
- SparseDatasetMap.as_format(spformat: Literal['csr', 'csc'], file: H5ADMapFile, key: str | None = None, force: bool = False)
Convert backed sparse matrix to other format without load full matrix to memory.
- Parameters:
spformat (
"csr"
|"csc"
) – Format that will convert to. Ifspformat == self.format_str
, do nothing.file (
h5py.File
) – Output handle that backed matrix will saved on.key (
str
, default =None
) – Key saved tofile
. Default isspformat
.
- Returns:
spmatrix – Converted backed sparse matrix.
- Return type:
SparseDatasetMap
Examples
>>> with H5ADMap("matrix.h5ad") as adata: ... adata.X.as_format("csc", adata.layers) ... print(adata)
- AnnData object with n_obs x n_vars = 1751246 x 45526 backed at “./matrix.h5ad”
layers: “csc”