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 [Andersson et al., 2020]: almaan/stereoscope.

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 (Literal['n_obs', 'minibatch'] (default: 'n_obs')) – Whether to sample the minibatch by the number of total observations or the monibatch size

Attributes table#

training

Methods table#

generative(x, ind_x)

Build the deconvolution model for every cell in the minibatch.

get_ct_specific_expression(y)

Returns cell type specific gene expression at the queried spots.

get_proportions([keep_noise])

Returns the loadings.

inference()

Inference.

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

Loss computation.

sample(tensors[, n_samples, library_size])

Sample from the model.

Attributes#

SpatialDeconv.training: bool#

Methods#

SpatialDeconv.generative(x, ind_x)[source]#

Build the deconvolution model for every cell in the minibatch.

SpatialDeconv.get_ct_specific_expression(y)[source]#

Returns cell type specific gene expression at the queried spots.

Parameters:

y – cell types

SpatialDeconv.get_proportions(keep_noise=False)[source]#

Returns the loadings.

Return type:

ndarray

SpatialDeconv.inference()[source]#

Inference.

SpatialDeconv.loss(tensors, inference_outputs, generative_outputs, kl_weight=1.0, n_obs=1.0)[source]#

Loss computation.

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

Sample from the model.