We’ve found that by using anndata for R, interacting with other anndata-based Python packages becomes super easy!
Let’s use a 10x dataset from the 10x genomics website. You can download it to an anndata object with scanpy as follows:
library(anndata)
library(reticulate)
sc <- import("scanpy")
url <- "https://cf.10xgenomics.com/samples/cell-exp/6.0.0/SC3_v3_NextGem_DI_CellPlex_CSP_DTC_Sorted_30K_Squamous_Cell_Carcinoma/SC3_v3_NextGem_DI_CellPlex_CSP_DTC_Sorted_30K_Squamous_Cell_Carcinoma_count_sample_feature_bc_matrix.h5"
ad <- sc$read_10x_h5("dataset.h5", backup_url = url)
ad
The resuling dataset is a wrapper for the Python class but behaves very much like an R object:
But you can still call scanpy functions on it, for example to perform preprocessing.