spatialvi.external.Starfysh#
- class spatialvi.external.Starfysh(adata_spatial, adata_ref, cell_type_key, spatial_key='spatial', n_factors=5, n_hidden=128, use_histology=False)[source]#
Bases:
objectStarfysh model for spatial deconvolution with histology.
Starfysh deconvolves spatial transcriptomics spots into cell type proportions using reference single-cell data. It can optionally integrate histology images for improved accuracy.
- Parameters:
adata_ref¶ (
AnnData) – Reference single-cell AnnData with cell type annotations.cell_type_key¶ (
str) – Key in adata_ref.obs for cell type labels.spatial_key¶ (
str) – Key in adata_spatial.obsm for spatial coordinates.n_factors¶ (
int) – Number of archetypal factors per cell type.use_histology¶ (
bool) – Whether to integrate histology features.adata_spatial (AnnData)
adata_ref (AnnData)
cell_type_key (str)
spatial_key (str)
n_factors (int)
n_hidden (int)
use_histology (bool)
Examples
>>> import spatialvi >>> adata_sp = spatialvi.data.synthetic_spatial() >>> adata_sc = spatialvi.data.synthetic_scrna() >>> model = Starfysh(adata_sp, adata_sc, cell_type_key="cell_type") >>> model.fit() >>> proportions = model.get_proportions()
- __init__(adata_spatial, adata_ref, cell_type_key, spatial_key='spatial', n_factors=5, n_hidden=128, use_histology=False)[source]#
Methods
__init__(adata_spatial, adata_ref, cell_type_key)fit([max_epochs, lr, batch_size, ...])Fit the Starfysh model.
get_proportions([return_dataframe])Get estimated cell type proportions.
Get reconstructed expression.
to_adata()Store results in spatial AnnData.
- fit(max_epochs=500, lr=0.001, batch_size=256, early_stopping=True, patience=20, device='auto')[source]#
Fit the Starfysh model.