Developer#

Import scvi-tools as:

import scvi

Data Registration#

AnnDataFields delineate how scvi-tools refers to fields in AnnData objects. The AnnDataManager provides an interface for operating over a collection of AnnDataFields and an AnnData object.

data.AnnDataManager

Provides an interface to validate and process an AnnData object for use in scvi-tools.

data.AnnDataManagerValidationCheck

Validation checks for AnnorMudata scvi-tools compat.

data.fields.BaseAnnDataField

Abstract class for a single AnnData/MuData field.

data.fields.LayerField

An AnnDataField for layer or X attributes in the AnnData data structure.

data.fields.CategoricalObsField

An AnnDataField for categorical .obs attributes in the AnnData data structure.

data.fields.CategoricalVarField

An AnnDataField for categorical .var attributes in the AnnData data structure.

data.fields.NumericalJointObsField

An AnnDataField for a collection of numerical .obs fields in the AnnData data structure.

data.fields.NumericalJointVarField

An AnnDataField for a collection of numerical .var fields in the AnnData data structure.

data.fields.CategoricalJointObsField

An AnnDataField for a collection of categorical .obs fields in AnnData.

data.fields.CategoricalJointVarField

An AnnDataField for a collection of categorical .var fields in AnnData.

data.fields.ObsmField

An AnnDataField for an .obsm field in the AnnData data structure.

data.fields.VarmField

An AnnDataField for a .varm field in the AnnData data structure.

data.fields.ProteinObsmField

An AnnDataField for an protein data stored in an .obsm field of an AnnData object.

data.fields.StringUnsField

An AnnDataField for string .uns attributes in the AnnData data structure.

data.fields.LabelsWithUnlabeledObsField

An AnnDataField for labels which include explicitly unlabeled cells.

data.fields.BaseMuDataWrapperClass

A wrapper class that adds MuData support for an AnnDataField.

data.fields.MuDataWrapper

Wraps an AnnDataField with BaseMuDataWrapperClass.

data.fields.MuDataLayerField

data.fields.MuDataProteinLayerField

data.fields.MuDataNumericalObsField

data.fields.MuDataNumericalVarField

data.fields.MuDataCategoricalObsField

data.fields.MuDataCategoricalVarField

data.fields.MuDataObsmField

data.fields.MuDataVarmField

data.fields.MuDataNumericalJointObsField

data.fields.MuDataNumericalJointVarField

data.fields.MuDataCategoricalJointObsField

data.fields.MuDataCategoricalJointVarField

data.AnnTorchDataset

Extension of Dataset for AnnData objects.

Data Loaders#

DataLoaders for loading tensors from AnnData objects. DataSplitters for splitting data into train/test/val.

dataloaders.AnnDataLoader

DataLoader for loading tensors from AnnData objects.

dataloaders.ConcatDataLoader

DataLoader that supports a list of list of indices to load.

dataloaders.DataSplitter

Creates data loaders train_set, validation_set, test_set.

dataloaders.SemiSupervisedDataLoader

DataLoader that supports semisupervised training.

dataloaders.SemiSupervisedDataSplitter

Creates data loaders train_set, validation_set, test_set.

Distributions#

Parameterizable probability distributions.

distributions.Poisson

Poisson distribution.

distributions.NegativeBinomial

Negative binomial distribution.

distributions.NegativeBinomialMixture

Negative binomial mixture distribution.

distributions.ZeroInflatedNegativeBinomial

Zero-inflated negative binomial distribution.

distributions.JaxNegativeBinomialMeanDisp

Negative binomial parameterized by mean and inverse dispersion.

distributions.BetaBinomial

BETA Beta binomial distribution.

Model (Base)#

These classes should be used to construct user-facing model classes.

model.base.BaseModelClass

Abstract class for scvi-tools models.

model.base.BaseMinifiedModeModelClass

Abstract base class for scvi-tools models that can handle minified data.

model.base.VAEMixin

Univseral VAE methods.

model.base.RNASeqMixin

General purpose methods for RNA-seq analysis.

model.base.ArchesMixin

Universal scArches implementation.

model.base.UnsupervisedTrainingMixin

General purpose unsupervised train method.

model.base.PyroSviTrainMixin

Mixin class for training Pyro models.

model.base.PyroSampleMixin

Mixin class for generating samples from posterior distribution.

model.base.PyroJitGuideWarmup

A callback to warmup a Pyro guide.

model.base.PyroModelGuideWarmup

A callback to warmup a Pyro guide and model.

model.base.DifferentialComputation

Unified class for differential computation.

model.base.EmbeddingMixin

EXPERIMENTAL Mixin class for initializing and using embeddings in a model.

Module#

Existing module classes with respective generative and inference procedures.

module.AutoZIVAE

Implementation of the AutoZI model [Clivio et al., 2019].

module.Classifier

Basic fully-connected NN classifier.

module.LDVAE

Linear-decoded Variational auto-encoder model.

module.MRDeconv

Model for multi-resolution deconvolution of spatial transriptomics.

module.PEAKVAE

Variational auto-encoder model for ATAC-seq data.

module.MULTIVAE

Variational auto-encoder model for joint paired + unpaired RNA-seq and ATAC-seq data.

module.SCANVAE

Single-cell annotation using variational inference.

module.TOTALVAE

Total variational inference for CITE-seq data.

module.VAE

Variational auto-encoder [Lopez et al., 2018].

module.VAEC

Conditional Variational auto-encoder model.

module.AmortizedLDAPyroModule

An amortized implementation of Latent Dirichlet Allocation [Blei et al., 2003].

module.JaxVAE

Variational autoencoder model.

External module#

Module classes in the external API with respective generative and inference procedures.

external.gimvi.JVAE

Joint variational auto-encoder for imputing missing genes in spatial data.

external.cellassign.CellAssignModule

Model for CellAssign.

external.stereoscope.RNADeconv

Model of scRNA-seq for deconvolution of spatial transriptomics.

external.stereoscope.SpatialDeconv

Model of single-cell RNA-sequencing data for deconvolution of spatial transriptomics.

external.tangram.TangramMapper

Tangram Mapper Model.

external.scbasset.ScBassetModule

PyTorch implementation of ScBasset [Yuan and Kelley, 2022].

external.contrastivevi.ContrastiveVAE

Variational inference for contrastive analysis of RNA-seq data.

external.velovi.VELOVAE

Variational auto-encoder model.

Module (Base)#

These classes should be used to construct module classes that define generative models and inference schemes.

module.base.BaseModuleClass

Abstract class for scvi-tools modules.

module.base.BaseMinifiedModeModuleClass

Abstract base class for scvi-tools modules that can handle minified data.

module.base.PyroBaseModuleClass

Base module class for Pyro models.

module.base.JaxBaseModuleClass

Abstract class for Jax-based scvi-tools modules.

module.base.EmbeddingModuleMixin

EXPERIMENTAL Mixin class for initializing and using embeddings in a module.

module.base.LossOutput

Loss signature for models.

module.base.auto_move_data

Decorator for Module methods to move data to correct device.

Neural networks#

Basic neural network building blocks.

nn.FCLayers

A helper class to build fully-connected layers for a neural network.

nn.Encoder

Encode data of n_input dimensions into a latent space of n_output dimensions.

nn.Decoder

Decodes data from latent space to data space.

nn.DecoderSCVI

Decodes data from latent space of n_input dimensions into n_output dimensions.

nn.one_hot

One hot a tensor of categories.

nn.Embedding

EXPERIMENTAL Embedding layer with utility methods for extending.

Train#

TrainingPlans define train/test/val optimization steps for modules.

train.AdversarialTrainingPlan

Train vaes with adversarial loss option to encourage latent space mixing.

train.SemiSupervisedTrainingPlan

Lightning module task for SemiSupervised Training.

train.LowLevelPyroTrainingPlan

Lightning module task to train Pyro scvi-tools modules.

train.PyroTrainingPlan

Lightning module task to train Pyro scvi-tools modules.

train.JaxTrainingPlan

Lightning module task to train Pyro scvi-tools modules.

train.Trainer

Lightweight wrapper of Pytorch Lightning Trainer.

train.TrainingPlan

Lightning module task to train scvi-tools modules.

train.TrainRunner

TrainRunner calls Trainer.fit() and handles pre and post training procedures.

train.SaveBestState

DEPRECATED Save the best module state and restore into model.

train.SaveCheckpoint

BETA Saves model checkpoints based on a monitored metric.

train.LoudEarlyStopping

Loud early stopping callback.

Utilities#

Utility functions used by scvi-tools.

utils.track

Progress bar with 'rich' and 'tqdm' styles.

utils.setup_anndata_dsp

Class that is intended to process docstrings.

utils.attrdict

A dictionary that allows for attribute-style access.

model.get_max_epochs_heuristic

Compute a heuristic for the default number of maximum epochs.