dotools_py.io.save_rds

Contents

dotools_py.io.save_rds#

dotools_py.io.save_rds(path_rds, batch_key='batch', adata=None, path_h5ad=None, out_type='seurat')[source]#

Save AnnData as Seurat or SingleCellExperiment Object.

Parameters:
path_rds str | PathLike[str] | Path

Path to save RDS Object.

batch_key str (default: 'batch')

Name in obs with batch information.

adata AnnData (default: None)

AnnData object

path_h5ad str | PathLike[str] | Path (default: None)

Path to AnnData Object including the filename.

out_type Literal['seurat', 'sce'] (default: 'seurat')

Specify the type of object that the AnnData should be converted to.

Return type:

None

Returns:

Returns None. Generate an RDS file in path_rds containing the Seurat or SingleCellExperiment Object.

See also

dotools_py.io.read_rds()

Read a SingleCellExperiment or Seurat Object save as RDS

Example

>>> import dotools_py as do
>>> import os
>>> adata = do.dt.example_10x_processed()
>>> do.io.save_rds(path_rds="/tmp/Seurat.rds", adata=adata, object_type="seurat", batch_key="batch")
>>> os.path.exists("/tmp/Seurat.rds")
True

Example (R)#

seu <- readRDS("/tmp/Seurat.rds")
seu

Output:
    An object of class Seurat
    1851 features across 700 samples within 1 assay
    Active assay: RNA (1851 features, 191 variable features)
    2 layers present: counts, data
    3-dimensional reductions calculated: cca, pca, umap