scvi.external.stereoscope.RNADeconv#

class scvi.external.stereoscope.RNADeconv(n_genes, n_labels, **model_kwargs)[source]#

Bases: scvi.module.base._base_module.BaseModuleClass

Model of single-cell RNA-sequencing data for deconvolution of spatial transriptomics.

Reimplementation of the ScModel module of Stereoscope [Andersson20]: https://github.com/almaan/stereoscope/blob/master/stsc/models.py.

Parameters
n_genes : int

Number of input genes

n_labels : int

Number of input cell types

**model_kwargs

Additional kwargs

Attributes table#

Methods table#

generative(x, y)

Simply build the negative binomial parameters for every cell in the minibatch.

get_params()

Returns the parameters for feeding into the spatial data.

inference()

Run the inference (recognition) model.

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

Compute the loss for a minibatch of data.

sample(tensors[, n_samples, library_size])

Generate samples from the learned model.

Attributes#

T_destination#

RNADeconv.T_destination#

alias of TypeVar(‘T_destination’, bound=Mapping[str, torch.Tensor])

alias of TypeVar(‘T_destination’, bound=Mapping[str, torch.Tensor]) .. autoattribute:: RNADeconv.T_destination device ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

RNADeconv.device#

dump_patches#

RNADeconv.dump_patches: bool = False#

This allows better BC support for load_state_dict(). In state_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#

RNADeconv.training: bool#

Methods#

generative#

RNADeconv.generative(x, y)[source]#

Simply build the negative binomial parameters for every cell in the minibatch.

get_params#

RNADeconv.get_params()[source]#

Returns the parameters for feeding into the spatial data.

Return type

Tuple[ndarray]

Returns

type : ndarray list of tensor

inference#

RNADeconv.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#

RNADeconv.loss(tensors, inference_outputs, generative_outputs, kl_weight=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.

sample#

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

Generate samples from the learned model.