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.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.NumericalJointObsField

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

data.fields.CategoricalJointObsField

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

data.fields.ObsmField

An AnnDataField for an .obsm 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.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.MuDataCategoricalObsField

data.fields.MuDataObsmField

data.fields.MuDataNumericalJointObsField

data.fields.MuDataCategoricalJointObsField

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.AnnTorchDataset

Extension of torch dataset to get tensors from anndata.

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.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.

Model (Base)#

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

model.base.BaseModelClass

Abstract class for scvi-tools models.

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.DifferentialComputation

Unified class for differential computation.

Module#

Existing module classes with respective generative and inference procedures.

module.AutoZIVAE

Implementation of the AutoZI model [Clivio19].

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 model.

module.VAEC

Conditional Variational auto-encoder model.

module.AmortizedLDAPyroModule

An amortized implementation of Latent Dirichlet Allocation [Blei03] implemented in Pyro.

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 single-cell RNA-sequencing data for deconvolution of spatial transriptomics.

external.stereoscope.SpatialDeconv

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

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.PyroBaseModuleClass

Base module class for Pyro models.

module.base.LossRecorder

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

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

nn.Decoder

Decodes data from latent space to data space.

nn.one_hot

One hot a tensor of categories.

Train#

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

train.AdversarialTrainingPlan

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

train.PyroTrainingPlan

Lightning module task to train Pyro scvi-tools modules.

train.SemiSupervisedTrainingPlan

Lightning module task for SemiSupervised Training.

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

Save the best module state and restore into model.

train.LoudEarlyStopping

Wrapper of Pytorch Lightning EarlyStopping callback that prints the reason for stopping on teardown.

Utilities#

Utility functions used by scvi-tools.

utils.track

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

utils.setup_anndata_dsp

A derived class of the DocstringProcessor class which provides useful parameters for the documentation of setup_anndata methods.

utils.attrdict

A dictionary that allows for attribute notation (e.g.