scviva.model.base.SpatialDeconvolutionMixin#

class scviva.model.base.SpatialDeconvolutionMixin[source]#

Mixin for spatial deconvolution result formatting and visualization.

Applied to: DestVI only.

Requires the model to implement: - self.cell_type_mapping: np.ndarray of cell type label strings - self.get_proportions(adata): returns np.ndarray of shape (n_spots, n_cell_types)

Methods table

get_proportions_df([adata])

Return cell type proportions as a tidy DataFrame.

plot_cell_type_map([adata, cell_type, basis, ax])

Plot spatial map of a single cell type's proportion.

Methods

SpatialDeconvolutionMixin.get_proportions_df(adata=None)[source]#

Return cell type proportions as a tidy DataFrame.

Parameters:
adata AnnData | None

AnnData object. If None, uses the model’s registered adata.

Return type:

DataFrame

Returns:

DataFrame of shape (n_spots, n_cell_types) with cell type names as columns. Rows sum to 1.

SpatialDeconvolutionMixin.plot_cell_type_map(adata=None, cell_type=None, basis='spatial', ax=None, **kwargs)[source]#

Plot spatial map of a single cell type’s proportion.

Parameters:
adata AnnData | None

AnnData object. If None, uses the model’s registered adata.

cell_type str | None

Name of the cell type to visualize. Must be in self.cell_type_mapping.

basis str

Key in adata.obsm for spatial coordinates.

ax

Matplotlib axes. If None, a new figure is created.

**kwargs

Forwarded to scanpy.pl.embedding().