Open Census
# FIXME: census <- cellxgene.census::open_soma(census_version = "stable")
ctx <- cellxgene.census::new_SOMATileDBContext_for_census(NULL, "vfs.s3.region" = "us-west-2", mirror = NULL)
census <- cellxgene.census::open_soma(uri = "s3://bruce-tmp/emb-build-2023-12-13/2023-12-15/soma/", tiledbsoma_ctx = ctx)Seurat
cns_seurat <- cellxgene.census::get_seurat(
census, "homo_sapiens",
obs_value_filter = "tissue_general == 'central nervous system'",
obs_column_names = c("cell_type"),
obsm_layers=c("scvi")
)
cns_seurat <- Seurat::RunUMAP(
cns_seurat, reduction = "scvi",
dims=1:ncol(Embeddings(cns_seurat, "scvi"))
)
(Seurat::DimPlot(cns_seurat, reduction = "umap", group.by = "cell_type") +
theme(legend.text = element_text(size = 8)))SingleCellExperiment
cns_sce <- cellxgene.census::get_single_cell_experiment(
census, "homo_sapiens",
obs_value_filter = "tissue_general == 'central nervous system'",
obs_column_names = c("cell_type"),
obsm_layers=c("geneformer")
)
# BiocManager::install("scater")
cns_sce <- scater::runUMAP(cns_sce, dimred = "geneformer")
scater::plotReducedDim(cns_sce, dimred = "UMAP", colour_by = "cell_type")Low-level sparseMatrix access
query <- census$get("census_data")$get("homo_sapiens")$axis_query(
"RNA", obs_query = tiledbsoma::SOMAAxisQuery$new(value_filter = "tissue == 'tongue'")
)
embeddings <- query$to_sparse_matrix("obsm", "geneformer")
str(embeddings)
#> Formal class 'dgTMatrix' [package "Matrix"] with 6 slots
#> ..@ i : int [1:190464] 0 0 0 0 0 0 0 0 0 0 ...
#> ..@ j : int [1:190464] 0 1 2 3 4 5 6 7 8 9 ...
#> ..@ Dim : int [1:2] 372 512
#> ..@ Dimnames:List of 2
#> .. ..$ : chr [1:372] "51784858" "51784859" "51784860" "51784861" ...
#> .. ..$ : chr [1:512] "0" "1" "2" "3" ...
#> ..@ x : num [1:190464] 0.1104 -1.2031 1.0078 0.0131 1.2422 ...
#> ..@ factors : list()