Title: | experimental inferface from R to scvi-tools |
---|---|
Description: | This package defines interfaces from R to scvi-tools. A vignette works through the totalVI tutorial for analyzing CITE-seq data. Another vignette compares outputs of Chapter 12 of the OSCA book with analogous outputs based on totalVI quantifications. Future work will address other components of scvi-tools, with a focus on building understanding of probabilistic methods based on variational autoencoders. |
Authors: | Vincent Carey [aut, cre] |
Maintainer: | Vincent Carey <[email protected]> |
License: | Artistic-2.0 |
Version: | 1.7.0 |
Built: | 2024-10-31 05:26:50 UTC |
Source: | https://github.com/bioc/scviR |
produce a heatmap from a specialized CITE-seq SingleCellExperiment
adtProfiles(x, lb = -3, ub = 3, do_z = FALSE)
adtProfiles(x, lb = -3, ub = 3, do_z = FALSE)
x |
SingleCellExperiment instance that has an 'se.averaged' component in its metadata |
lb |
numeric(1) lower bound on 'breaks' sequence for ComplexHeatmap::pheatmap, defaults to -3 |
ub |
numeric(1) upper bound on 'breaks' sequence for ComplexHeatmap::pheatmap, defaults to 3 |
do_z |
logical(1) if TRUE, divide the residuals by their standard deviation across clusters, defaults to false |
ComplexHeatmap::pheatmap instance
side effect of pheatmap::pheatmap call
See the OSCA book ch12.5.2 for the application.
ch12sce <- getCh12Sce() adtProfiles(ch12sce) adtProfiles(ch12sce, do_z = TRUE)
ch12sce <- getCh12Sce() adtProfiles(ch12sce) adtProfiles(ch12sce, do_z = TRUE)
basic interface to anndata
anndataR()
anndataR()
basiliskRun result with import from reticulate, typically a Module
ad <- anndataR() ad ad$read
ad <- anndataR() ad ad$read
python declarations
bsklenv
bsklenv
An object of class BasiliskEnvironment
of length 1.
grab scvi-tools-processed PBMC CITE-seq data in anndata format (gzipped) from Open Storage Network
cacheCiteseq5k10kPbmcs()
cacheCiteseq5k10kPbmcs()
invisibly, the path to the .h5ad file
Original h5ad files obtained using scvi-tools 0.18.0 scvi.data.pbmcs_10x_cite_seq, then processed according to steps in the scviR vignette, which follow the [scvi-tools tutorial](https://colab.research.google.com/github/scverse/scvi-tutorials/blob/0.18.0/totalVI.ipynb) by Gayoso et al.
It may be advantageous to set 'options(timeout=3600)' or to allow an even greater time for internet downloads, if working at a relatively slow network connection.
h5path <- cacheCiteseq5k10kPbmcs() cmeta <- rhdf5::h5ls(h5path) dim(cmeta) head(cmeta, 17)
h5path <- cacheCiteseq5k10kPbmcs() cmeta <- rhdf5::h5ls(h5path) dim(cmeta) head(cmeta, 17)
grab scvi-tools VAE instance built on the PBMC datasets following the tutorial
cacheCiteseq5k10kTutvae()
cacheCiteseq5k10kTutvae()
invisibly, the path to the .zip file holding the fitted VAE and associated data
VAE construction followed tutorial at 'https://docs.scvi-tools.org/en/stable/tutorials/notebooks/totalVI.html'.
It may be advantageous to set 'options(timeout=3600)' or to allow an even greater time for internet downloads, if working at a relatively slow network connection.
zpath <- cacheCiteseq5k10kTutvae() td <- tempdir() utils::unzip(zpath, exdir = td) vaedir <- paste0(td, "/vae2_ov") scvi <- scviR() adm <- anndataR() hpath <- cacheCiteseq5k10kPbmcs() adata <- adm$read(hpath) mod <- scvi$model$`_totalvi`$TOTALVI$load(vaedir, adata) #, use_gpu = FALSE) mod
zpath <- cacheCiteseq5k10kTutvae() td <- tempdir() utils::unzip(zpath, exdir = td) vaedir <- paste0(td, "/vae2_ov") scvi <- scviR() adm <- anndataR() hpath <- cacheCiteseq5k10kPbmcs() adata <- adm$read(hpath) mod <- scvi$model$`_totalvi`$TOTALVI$load(vaedir, adata) #, use_gpu = FALSE) mod
ADT-based cluster labels for 7472 cells in OSCA chapter 12 analysis
clusters.adt
clusters.adt
factor
mRNA-based cluster labels for 7472 cells in OSCA chapter 12 analysis
clusters.rna
clusters.rna
factor
app to explore diversity in RNA-subclusters within ADT clusters
exploreSubcl(sce, inlist, adtcls)
exploreSubcl(sce, inlist, adtcls)
sce |
a SingleCellExperiment with altExp with ADT quantification |
inlist |
list of SingleCellExperiments (SCEs) formed by scran::quickSubCluster |
adtcls |
vector of ADT cluster assignments |
shinyApp instance
TSNE should already be available in 'altExp(sce)'; follow OSCA book 12.5.2. If using example, set 'ask=FALSE'.
sce <- getCh12Sce() all.sce <- getCh12AllSce() data(clusters.adt) runApp(exploreSubcl(sce, all.sce, clusters.adt)) # trips up interactive pkgdown?)
sce <- getCh12Sce() all.sce <- getCh12AllSce() data(clusters.adt) runApp(exploreSubcl(sce, all.sce, clusters.adt)) # trips up interactive pkgdown?)
get list of cluster-specific SCE for 10k PBMC annotated as in OSCA book chapter 12
getCh12AllSce()
getCh12AllSce()
SimpleList of SingleCellExperiment instances
This is a list of SingleCellExperiment instances with data on a total of 7472 cells from a 10x CITE-seq experiment. An altExp component in each list element includes antibody-derived tag (ADT) counts on 17 proteins. The data are acquired and processed as described in ch 12 of the OSCA book, circa February 2023. List elements correspond to mRNA-based sub-clusters of ADT-based clusters.
ch12_allsce <- getCh12AllSce() vapply(ch12_allsce, ncol, numeric(1))
ch12_allsce <- getCh12AllSce() vapply(ch12_allsce, ncol, numeric(1))
get SCE for 10k PBMC annotated as in OSCA book chapter 12
getCh12Sce(clear_cache = FALSE)
getCh12Sce(clear_cache = FALSE)
clear_cache |
logical(1) will delete relevant entries in available cache before continuing, defaults to FALSE |
SingleCellExperiment instance
This is a SingleCellExperiment instance with data on 7472 cells from a 10x CITE-seq experiment. An altExp component includes antibody-derived tag (ADT) counts on 17 proteins. The data are acquired and processed as described in ch 12 of the OSCA book, circa February 2023. A metadata element (se.averaged) includes the result of averaging protein abundance estimates within ADT-based clusters, as is done to give rise to Figure 12.8 of the OSCA book.
ch12sce <- getCh12Sce() ch12sce
ch12sce <- getCh12Sce() ch12sce
helper to get the processed anndata for CITE-seq PBMCs from scvi-tools tutorial
getCiteseq5k10kPbmcs()
getCiteseq5k10kPbmcs()
python reference to anndata
It may be advantageous to set 'options(timeout=3600)' or to allow an even greater time for internet downloads, if working at a relatively slow network connection.
getCiteseq5k10kPbmcs()
getCiteseq5k10kPbmcs()
helper to get the tutorial VAE for PBMCs from scvi-tools tutorial
getCiteseqTutvae(use_gpu = FALSE)
getCiteseqTutvae(use_gpu = FALSE)
use_gpu |
logical(1), defaulting to FALSE, passed to TOTALVI.load |
python reference to anndata
March 2024 use_gpu ignored
getCiteseqTutvae()
getCiteseqTutvae()
get an anndata reference to 5k10k protein after totalVI from tutorial
getPro5k10kAdata()
getPro5k10kAdata()
python reference to anndata
It may be advantageous to set 'options(timeout=3600)' or to allow an even greater time for internet downloads, if working at a relatively slow network connection.
getPro5k10kAdata()
getPro5k10kAdata()
get lmFit for heterogeneity across subclusters
getSubclLM(inlist, clname)
getSubclLM(inlist, clname)
inlist |
list of SingleCellExperiments (SCEs) formed by scran::quickSubCluster |
clname |
character(1) name of cluster SCE to assess |
limma::lmFit output
It is assumed that 'logcounts' is an assay element, and that 'subcluster' is a colData element of each SCE in inlist
all.sce <- getCh12AllSce() lm3 <- getSubclLM(all.sce, "3") names(lm3)
all.sce <- getCh12AllSce() lm3 <- getSubclLM(all.sce, "3") names(lm3)
get lmFit F-stat based collection of n genes most varying in mean across subclusters
getSubclusteringFeatures(inlist, clname, n = 20)
getSubclusteringFeatures(inlist, clname, n = 20)
inlist |
list of SingleCellExperiments (SCEs) formed by scran::quickSubCluster |
clname |
character(1) name of cluster SCE to assess |
n |
numeric(1) number to preserve |
list with two elements, feat = rowData corresponding to variable genes, stats = topTable result
Symbol will be taken from feat and placed in stats component if available
all.sce <- getCh12AllSce() scl <- getSubclusteringFeatures(all.sce, "3", 10) names(scl)
all.sce <- getCh12AllSce() scl <- getSubclusteringFeatures(all.sce, "3", 10) names(scl)
get anndata reference to full totalVI processing of 5k10k data
getTotalVI5k10kAdata()
getTotalVI5k10kAdata()
python reference to anndata
full <- getTotalVI5k10kAdata() full
full <- getTotalVI5k10kAdata() full
get matrices of normalized quantifications from full totalVI 5k10k from tutorial
getTotalVINormalized5k10k()
getTotalVINormalized5k10k()
list of matrices
nmlist <- getTotalVINormalized5k10k() vapply(nmlist, dim, numeric(2))
nmlist <- getTotalVINormalized5k10k() vapply(nmlist, dim, numeric(2))
basic interface to MuData
MuDataR()
MuDataR()
basiliskRun result with import from reticulate, typically a Module
md <- MuDataR() md head(names(md))
md <- MuDataR() md head(names(md))
helper to get text from python help utility – may need handling through basilisk
pyHelp2(object)
pyHelp2(object)
object |
a reference to a python module typically with class 'python.builtin.module' |
character vector of lines from python help result
shiny app that helps access documentation on python-accessible components
scanpyHelper()
scanpyHelper()
shinyApp instance
basic interface
scanpyR()
scanpyR()
basiliskRun result with import from reticulate, typically a Module
sc <- scanpyR() sc sc$pp
sc <- scanpyR() sc sc$pp
shiny app that helps access documentation on python-accessible components
scviHelper()
scviHelper()
shinyApp instance
basic interface
scviR()
scviR()
basiliskRun result with import from reticulate, typically a Module
scvi <- scviR() scvi scvi$model
scvi <- scviR() scvi scvi$model