scvi.module.MRDeconv#

class scvi.module.MRDeconv(n_spots, n_labels, n_batch, n_hidden, n_layers, n_latent, n_genes, decoder_state_dict, px_decoder_state_dict, px_r, per_ct_bias, dropout_decoder, dropout_amortization=0.03, augmentation=True, n_samples_augmentation=2, n_states_per_label=3, eps_v=0.002, mean_vprior=None, var_vprior=None, mp_vprior=None, amortization='both', prior_mode='mog', add_celltypes=1, n_latent_amortization=None, extra_encoder_kwargs=None, extra_decoder_kwargs=None)[source]#

Bases: EmbeddingModuleMixin, BaseModuleClass

Model for multi-resolution deconvolution of spatial transriptomics.

Parameters:
n_spots int

Number of input spots

n_labels int

Number of cell types

n_hidden int

Number of neurons in the hidden layers

n_layers int

Number of layers used in the encoder networks

n_latent int

Number of dimensions used in the latent variables

n_genes int

Number of genes used in the decoder

px_r Tensor

parameters for the px_r tensor in the CondSCVI model

per_ct_bias Tensor

estimates of per cell-type expression bias in the CondSCVI model

decoder_state_dict OrderedDict

state_dict from the decoder of the CondSCVI model

px_decoder_state_dict OrderedDict

state_dict from the px_decoder of the CondSCVI model

dropout_decoder float

Dropout rate for the decoder neural network (same dropout as in CondSCVI decoder)

dropout_amortization float (default: 0.03)

Dropout rate for the amortization neural network

n_samples_augmentation int (default: 2)

Number of samples used in the augmentation

n_states_per_label int (default: 3)

Number of states per cell-type in each spot

eps_v float (default: 0.002)

Epsilon value for each cell-type proportion used during training.

n_states_per_augmented_label

Number of states per cell-type in each spot during augmentation

mean_vprior ndarray (default: None)

Mean parameter for each component in the empirical prior over the latent space

var_vprior ndarray (default: None)

Diagonal variance parameter for each component in the empirical prior over the latent space

mp_vprior ndarray (default: None)

Mixture proportion in cell type sub-clustering of each component in the empirical prior amortization

prior_mode Literal['mog', 'normal'] (default: 'mog')

Mode of the prior distribution for the latent space. Either “mog” for mixture of gaussians or “normal” for normal distribution.

add_celltypes int (default: 1)

Number of additional cell types compared to single cell data to add to the model

n_latent_amortization int | None (default: None)

Number of dimensions used in the latent variables for the amortization encoder neural network

extra_encoder_kwargs dict | None (default: None)

Extra keyword arguments passed into FCLayers.

extra_decoder_kwargs dict | None (default: None)

Extra keyword arguments passed into FCLayers.

Attributes table#

Methods table#

generative(z, ind_x, library, batch_index)

Build the deconvolution model for every cell in the minibatch.

inference(x_augmented, batch_index[, ...])

Runs the inference (encoder) model.

loss(tensors, inference_outputs, ...[, ...])

Compute the loss.

sample(tensors[, n_samples, library_size])

Sample from the posterior.

Attributes#

MRDeconv.training: bool#

Methods#

MRDeconv.generative(z, ind_x, library, batch_index)[source]#

Build the deconvolution model for every cell in the minibatch.

MRDeconv.inference(x_augmented, batch_index, n_samples=1, prior_sampled=None, ratios_ct_augmentation=None, ratio_augmentation=None)[source]#

Runs the inference (encoder) model.

MRDeconv.loss(tensors, inference_outputs, generative_outputs, kl_weight=1.0, ct_sparsity_weight=2.0, weighting_augmentation=100.0, weighting_smoothing=100.0, eta_reg=1.0, beta_reg=1.0, weighting_kl_latent=0.001, reconst_weight=3.0)[source]#

Compute the loss.

MRDeconv.sample(tensors, n_samples=1, library_size=1)[source]#

Sample from the posterior.