S4 — Deconvolution
Goal
Estimate cell-type proportions for each Visium spot using a reference scRNA-seq dataset with cell-type labels.
Prerequisites
- Reference scRNA-seq h5ad with cell-type labels in
obs(e.g., columnlevel_3). - Clustered Visium h5ad from S2 (or raw loaded h5ad — DestVI works on raw counts).
Steps
- DestVI (preferred):
deconvolve_spatial_destvi(ref_h5ad=..., st_h5ad=..., cell_type_key=..., output_dir=..., plot_path=..., n_latent=..., max_epochs=..., destvi_max_epochs=...)- Defaults:
n_latent=30,max_epochs=400(CondSCVI),destvi_max_epochs=500. - Requires
scvi-toolsinstalled.
- Defaults:
- SPOTlight (alternative):
deconvolve_spatial_spotlight(ref_h5ad=..., st_h5ad=..., cell_type_key=..., output_dir=..., plot_path=..., r_script_path=...)- Requires R + SPOTlight package (see
install_r_packages_spatial.R).
- Requires R + SPOTlight package (see
Outputs
results/07_deconvolution/<sample>_proportions.csv(spots × cell types)results/07_deconvolution/<sample>_proportions_*.png(spatial proportion maps, stacked bar)
Biological Interpretation
- Report dominant cell types and their spatial localization.
- Cross-check with tissue type: e.g., gastric cancer should show epithelial/tumor cells in tumor regions, immune cells at infiltrate margins.
- Flag any surprising dominant cell type (e.g., >50% of a cell type not expected in the tissue).
Stop for Review
Present interpretation using the template from the parent spatial-transcriptomics skill. Wait for 通过 / 调整 / 跳过 before proceeding to S5.


