scvi.model.DestVI

class scvi.model.DestVI(st_adata, cell_type_mapping, decoder_state_dict, px_decoder_state_dict, px_r, n_hidden, n_latent, n_layers, **module_kwargs)[source]

Multi-resolution deconvolution of Spatial Transcriptomics data (DestVI) [Lopez21].. Most users will use the alternate constructor (see example).

Parameters
st_adata : AnnDataAnnData

spatial transcriptomics AnnData object that has been registered via setup_anndata().

cell_type_mapping : ndarrayndarray

mapping between numerals and cell type labels

decoder_state_dict : OrderedDictOrderedDict

state_dict from the decoder of the CondSCVI model

px_decoder_state_dict : OrderedDictOrderedDict

state_dict from the px_decoder of the CondSCVI model

px_r : ndarrayndarray

parameters for the px_r tensor in the CondSCVI model

n_hidden : intint

Number of nodes per hidden layer.

n_latent : intint

Dimensionality of the latent space.

n_layers : intint

Number of hidden layers used for encoder and decoder NNs.

**module_kwargs

Keyword args for MRDeconv

Examples

>>> sc_adata = anndata.read_h5ad(path_to_scRNA_anndata)
>>> scvi.data.setup_anndata(sc_adata)
>>> sc_model = scvi.CondSCVI(sc_adata)
>>> st_adata = anndata.read_h5ad(path_to_ST_anndata)
>>> scvi.data.setup_anndata(st_adata)
>>> spatial_model = DestVI.from_rna_model(st_adata, sc_model)
>>> spatial_model.train(max_epochs=2000)
>>> st_adata.obsm["proportions"] = spatial_model.get_proportions(st_adata)
>>> gamma = spatial_model.get_gamma(st_adata)

Notes

See further usage examples in the following tutorials:

  1. Multi-resolution deconvolution of spatial transcriptomics

Attributes

device

history

Returns computed metrics during training.

is_trained

test_indices

train_indices

validation_indices

Methods

from_rna_model(st_adata, sc_model[, …])

Alternate constructor for exploiting a pre-trained model on a RNA-seq dataset.

get_gamma([indices, batch_size, return_numpy])

Returns the estimated cell-type specific latent space for the spatial data.

get_proportions([keep_noise, indices, …])

Returns the estimated cell type proportion for the spatial data.

get_scale_for_ct(label[, indices, batch_size])

Return the scaled parameter of the NB for every spot in queried cell types.

load(dir_path[, adata, use_gpu])

Instantiate a model from the saved output.

save(dir_path[, overwrite, save_anndata])

Save the state of the model.

to_device(device)

Move model to device.

train([max_epochs, lr, use_gpu, train_size, …])

Trains the model using MAP inference.