layer: str
Provide an optional layer key.
n_layers: int
Number of layers in the neural network.
n_latent: int
Dimensionality of the latent space in the neural network.
n_hidden: int
Number of nodes per hidden layer.
batch_size: int
Training batch size.
max_epochs: int
Number of epochs to train the neural network.
import scanpy as sc
batch_key = "BATCH"
scvi.settings.seed = 42
scvi.model.SCVI.setup_anndata(adata, batch_key=batch_key)
model = scvi.model.SCVI(adata, n_layers=2, n_latent=30, n_hidden=128, gene_likelihood="nb")
model.train(use_gpu = True, batch_size=128, max_epochs=400)
#evaluate latent representation
SCVI_LATENT_KEY = "X_scVI"
adata.obsm[SCVI_LATENT_KEY] = model.get_latent_representation()
sc.pp.neighbors(adata, use_rep=SCVI_LATENT_KEY)
sc.tl.leiden(adata)
SCVI_MDE_KEY = "X_scVI_MDE"
adata.obsm[SCVI_MDE_KEY] = scvi.model.utils.mde(adata.obsm[SCVI_LATENT_KEY])