Introduction
anndataR
works with Python AnnData
objects through reticulate.
You can load Python objects, apply Python functions to them, and convert
them to Seurat
or SingleCellExperiment
objects.
Basic Integration with scanpy
Install required Python packages if needed:
reticulate::py_install("scanpy")
library(anndataR)
library(reticulate)
sc <- import("scanpy")
Load a dataset directly from scanpy:
adata <- sc$datasets$pbmc3k_processed()
print(adata)
Apply scanpy functions directly:
sc$pp$filter_cells(adata, min_genes = 200L)
sc$pp$normalize_total(adata, target_sum = 1e4)
sc$pp$log1p(adata)
Conversion to R objects
Convert to Seurat
:
seurat_obj <- adata$as_Seurat()
print(seurat_obj)
Convert to SingleCellExperiment
:
sce_obj <- adata$as_SingleCellExperiment()
print(sce_obj)
Multi-modal data with mudata
Install required Python packages if needed:
reticulate::py_install("mudata")
md <- import("mudata")
Load a MuData
object from file:
cache <- BiocFileCache::BiocFileCache(ask = FALSE)
h5mu_file <- BiocFileCache::bfcrpath(
cache,
"https://github.com/gtca/h5xx-datasets/raw/b1177ac8877c89d8bb355b072164384b4e9cc81d/datasets/minipbcite.h5mu"
)
mdata <- md$read_h5mu(h5mu_file)
Access individual modalities and convert them: