scvi.module.MRDeconv#
- class scvi.module.MRDeconv(n_spots, n_labels, n_hidden, n_layers, n_latent, n_genes, decoder_state_dict, px_decoder_state_dict, px_r, dropout_decoder, dropout_amortization=0.05, mean_vprior=None, var_vprior=None, mp_vprior=None, amortization='both', l1_reg=0.0, beta_reg=5.0, eta_reg=0.0001, extra_encoder_kwargs=None, extra_decoder_kwargs=None)[source]#
Bases:
BaseModuleClass
Model for multi-resolution deconvolution of spatial transriptomics.
- Parameters:
n_spots (
int
) – Number of input spotsn_labels (
int
) – Number of cell typesn_hidden (
int
) – Number of neurons in the hidden layersn_layers (
int
) – Number of layers used in the encoder networksn_latent (
int
) – Number of dimensions used in the latent variablesn_genes (
int
) – Number of genes used in the decoderdropout_decoder (
float
) – Dropout rate for the decoder neural network (same dropout as in CondSCVI decoder)dropout_amortization (
float
(default:0.05
)) – Dropout rate for the amortization neural networkdecoder_state_dict (
OrderedDict
) – state_dict from the decoder of the CondSCVI modelpx_decoder_state_dict (
OrderedDict
) – state_dict from the px_decoder of the CondSCVI modelpx_r (
ndarray
) – parameters for the px_r tensor in the CondSCVI modelmean_vprior (
ndarray
(default:None
)) – Mean parameter for each component in the empirical prior over the latent spacevar_vprior (
ndarray
(default:None
)) – Diagonal variance parameter for each component in the empirical prior over the latent spacemp_vprior (
ndarray
(default:None
)) – Mixture proportion in cell type sub-clustering of each component in the empirical prioramortization (
Literal
['none'
,'latent'
,'proportion'
,'both'
] (default:'both'
)) – which of the latent variables to amortize inference over (gamma, proportions, both or none)l1_reg (
float
(default:0.0
)) – Scalar parameter indicating the strength of L1 regularization on cell type proportions. A value of 50 leads to sparser results.beta_reg (
float
(default:5.0
)) – Scalar parameter indicating the strength of the variance penalty for the multiplicative offset in gene expression values (beta parameter). Default is 5 (setting to 0.5 might help if single cell reference and spatial assay are different e.g. UMI vs non-UMI.)eta_reg (
float
(default:0.0001
)) – Scalar parameter indicating the strength of the prior for the noise term (eta parameter). Default is 1e-4. (changing value is discouraged.)extra_encoder_kwargs (
dict
|None
(default:None
)) – Extra keyword arguments passed intoFCLayers
.extra_decoder_kwargs (
dict
|None
(default:None
)) – Extra keyword arguments passed intoFCLayers
.
Attributes table#
Methods table#
|
Build the deconvolution model for every cell in the minibatch. |
|
Returns cell type specific gene expression at the queried spots. |
|
Returns the loadings. |
|
Returns the loadings. |
Run the inference model. |
|
|
Compute the loss. |
|
Sample from the posterior. |
Attributes#
- MRDeconv.training: bool#
Methods#
- MRDeconv.generative(x, ind_x, batch_index=None, transform_batch=None)[source]#
Build the deconvolution model for every cell in the minibatch.
- MRDeconv.get_ct_specific_expression(x=None, ind_x=None, y=None)[source]#
Returns cell type specific gene expression at the queried spots.
- Parameters:
x (
Tensor
(default:None
)) – tensor of dataind_x (
Tensor
(default:None
)) – tensor of indicesy (
int
(default:None
)) – integer for cell types