dotools_py.io.read_rds

Contents

dotools_py.io.read_rds#

dotools_py.io.read_rds(path_rds, path_h5ad, batch_key='batch')[source]#

Read Rds object with Seurat or SingleCellExperiment Object.

Note

When reading an RDS Object with counts and logcounts data, the counts will be returned in the X attribute, while the logcounts are returned as a layer.

Parameters:
path_rds str | PathLike[str] | Path

Path to RDS file with SingleCellExperiment or SeuratObject.

path_h5ad str | PathLike[str] | Path

Path to save AnnData Object.

batch_key str (default: 'batch')

Name in obs to save batch information.

Return type:

AnnData | None

Returns:

Returns an AnnData Object or None. The AnnData can also be saved under path_adata.

See also

dotools_py.io.save_rds()

Save an AnnData as SingleCellExperiment or Seurat Object

Example

>>> import dotools_py as do
>>> path_seurat = "/tmp/Seurat.rds"
>>> path_adata = "/tmp/adata.h5ad"
>>> adata = do.io.read_rds(path_rds=path_seurat, path_h5ad=path_adata)
>>> adata
AnnData object with n_obs × n_vars = 700 × 1851
    obs: 'nCount_originalexp', 'nFeature_originalexp', 'batch', 'condition', 'n_genes_by_counts',
         'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'total_counts_mt',
         'log1p_total_counts_mt', 'pct_counts_mt', 'total_counts_ribo', 'log1p_total_counts_ribo',
         'pct_counts_ribo', 'n_genes', 'n_counts', 'doublet_class', 'doublet_score', 'leiden', 'cell_type',
         'autoAnnot', 'celltypist_conf_score', 'annotation', 'annotation_recluster', 'ident'
    var: 'highly_variable'
    uns: 'X_name'
    obsm: 'X_cca', 'X_pca', 'X_umap'
    layers: 'logcounts', 'counts'
    obsp: 'connectivities', 'distances'