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.
message(
"Python packages scanpy and mudata are required to run this vignette. Code chunks will not be evaluated."
)
#> Python packages scanpy and mudata are required to run this vignette. Code chunks will not be evaluated.Basic Integration with scanpy
Install required Python packages if needed:
reticulate::py_require("scanpy")
library(anndataR)
library(reticulate)
sc <- import("scanpy")Load a dataset directly from scanpy:
adata <- sc$datasets$pbmc3k_processed()
adataApply 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 SingleCellExperiment (see
vignette("usage_singlecellexperiment")):
sce_obj <- adata$as_SingleCellExperiment()
sce_objConvert to Seurat (see
vignette("usage_seurat")):
seurat_obj <- adata$as_Seurat()
seurat_objMulti-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: