spatialvi.external.DestVI#
- class spatialvi.external.DestVI(st_adata, sc_model, **kwargs)[source]#
Bases:
objectWrapper for scvi-tools DestVI model.
DestVI performs multi-resolution spatial deconvolution, estimating both cell type proportions and continuous sub-cell-type variation within spatial transcriptomics spots.
This is a thin wrapper around the scvi-tools implementation that provides a consistent interface with spatialvi-tools.
- Parameters:
Examples
>>> import spatialvi >>> # First train CondSCVI on reference >>> sc_adata = spatialvi.data.synthetic_scrna() >>> DestVI.setup_anndata(sc_adata, labels_key="cell_type") >>> sc_model = spatialvi.external.CondSCVI(sc_adata) >>> sc_model.train() >>> # Then train DestVI on spatial >>> st_adata = spatialvi.data.synthetic_spatial() >>> model = DestVI.from_rna_model(st_adata, sc_model) >>> model.train() >>> proportions = model.get_proportions()
Methods
__init__(st_adata, sc_model, **kwargs)from_rna_model(st_adata, sc_model, **kwargs)Create DestVI from a trained CondSCVI model.
get_gamma([adata, indices, batch_size])Get sub-cell-type variation (gamma) per cell type.
get_latent_representation([adata, indices, ...])Get latent representation.
get_proportions([adata, indices, ...])Get estimated cell type proportions.
get_scale_for_ct(cell_type[, adata, ...])Get cell type-specific expression scale.
load(dir_path[, adata])Load model from disk.
save(dir_path, **kwargs)Save model to disk.
setup_anndata(adata[, layer, labels_key])Setup AnnData for DestVI (reference single-cell data).
train([max_epochs, lr, accelerator, devices])Train the model.
- classmethod setup_anndata(adata, layer=None, labels_key=None, **kwargs)[source]#
Setup AnnData for DestVI (reference single-cell data).
- Parameters:
- Return type:
- classmethod from_rna_model(st_adata, sc_model, **kwargs)[source]#
Create DestVI from a trained CondSCVI model.
- train(max_epochs=2500, lr=0.001, accelerator='auto', devices='auto', **kwargs)[source]#
Train the model.
- Parameters:
- Return type:
- get_proportions(adata=None, indices=None, batch_size=None, return_dataframe=True)[source]#
Get estimated cell type proportions.
- get_gamma(adata=None, indices=None, batch_size=None)[source]#
Get sub-cell-type variation (gamma) per cell type.
- get_scale_for_ct(cell_type, adata=None, indices=None, batch_size=None)[source]#
Get cell type-specific expression scale.