scvi.external.stereoscope.SpatialDeconv#
- class scvi.external.stereoscope.SpatialDeconv(n_spots, sc_params, prior_weight='n_obs')[source]#
Bases:
BaseModuleClass
Model of single-cell RNA-sequencing data for deconvolution of spatial transriptomics.
Reimplementation of the STModel module of Stereoscope [Andersson20]: https://github.com/almaan/stereoscope/blob/master/stsc/models.py.
- Parameters:
- n_spots :
int
Number of input spots
- sc_params :
Tuple
[ndarray
] Tuple of ndarray of shapes [(n_genes, n_labels), (n_genes)] containing the dictionnary and log dispersion parameters
- prior_weight : {‘n_obs’, ‘minibatch’}
Literal
[‘n_obs’, ‘minibatch’] (default:'n_obs'
) Whether to sample the minibatch by the number of total observations or the monibatch size
- n_spots :
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. |
Run the inference (recognition) model. |
|
|
Compute the loss for a minibatch of data. |
|
Generate samples from the learned model. |
Attributes#
T_destination#
alias of TypeVar(‘T_destination’, bound=Mapping
[str
, Tensor
])
.. autoattribute:: SpatialDeconv.T_destination
device
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- SpatialDeconv.device#
dump_patches#
- SpatialDeconv.dump_patches: bool = False#
This allows better BC support for
load_state_dict()
. Instate_dict()
, the version number will be saved as in the attribute _metadata of the returned state dict, and thus pickled. _metadata is a dictionary with keys that follow the naming convention of state dict. See_load_from_state_dict
on how to use this information in loading.If new parameters/buffers are added/removed from a module, this number shall be bumped, and the module’s _load_from_state_dict method can compare the version number and do appropriate changes if the state dict is from before the change.
training#
Methods#
generative#
get_ct_specific_expression#
get_proportions#
inference#
- SpatialDeconv.inference()[source]#
Run the inference (recognition) model.
In the case of variational inference, this function will perform steps related to computing variational distribution parameters. In a VAE, this will involve running data through encoder networks.
This function should return a dictionary with str keys and
Tensor
values.
loss#
- SpatialDeconv.loss(tensors, inference_outputs, generative_outputs, kl_weight=1.0, n_obs=1.0)[source]#
Compute the loss for a minibatch of data.
This function uses the outputs of the inference and generative functions to compute a loss. This many optionally include other penalty terms, which should be computed here.
This function should return an object of type
LossRecorder
.