stGP: Characterizing dynamic tissue architectures by identifying cell-type-specific spatiotemporal gene programs
This repository contains the code for stGP (spatiotemporal Gene Programs).
stGP is a statistical framework for identifying interpretable cell-type-specific spatiotemporal gene programs (stGPs) from multi-sample spatiotemporal transcriptomic data measured across biological time by deciphering temporal trajectory and dynamic spatial patterns.
stGP's effectiveness relies on our innovations in the integration of Gaussian process priors and interpretable matrix factorization:
- stGP represents gene expression within each cell type as a small set of latent programs with non-negative gene loadings, making each program interpretable as a weighted gene set shared across samples. Variance components quantify the relative contributions of time and space to each program.
- stGP decomposes per-cell program activity into a sample-level temporal component that captures coordinated responses over biological time (e.g., age or stage), and a within-section spatial component that characterizes dynamic program deployment across tissue coordinates without requiring cross-section registration.
- For multi-program inference, stGP adopts a blockwise backfitting scheme that sequentially extracts rank-1 components from residuals, with automatic model selection to determine the number of programs.
To install the released stgp package from PyPI into your current Python
environment:
pip install stgpTo reproduce the notebook from the GitHub repository, you can also install the stGP environment from GitHub:
git clone https://github.com/YangLabHKUST/stGP.git
cd stGP
conda env create -f stGP.yml
conda activate stGP
pip install -e .Normally the installation time will be less than twenty minutes. We have tested our package on Linux (Ubuntu 22.04.5 LTS).
The tutorials for using stGP and codes for reproducing the analysis results presented in our paper are available on the tutorial website (https://stgp-tutorial.readthedocs.io).
- Human aging DLPFC contating the benchmarking study and niche validation
- Mouse aging brain to discover the proximity effect
- Mouse injured kidney with paired biological replicates
You may also use the notebooks and codes in this repository to reproducing the figures in the manuscript.
The full benchmarking codes and results are released at a separate repository: https://github.com/Jamesyu420/stop-reproduce.
The aging mouse brain MERFISH dataset4 can be accessed from Zenodo at (https://doi.org/10.5281/zenodo.13883177). The aging human brain DLPFC MERFISH dataset5 can be obtained from (https://publications.wenglab.org/SomaMut/). The mouse kidney injury and repair Xenium dataset7 is available from (https://doi.org/10.6084/m9.figshare.28761695.v1).
If you find stGP or any of the source code in this repository useful for your work, please cite:
Characterizing dynamic tissue architectures by identifying cell-type-specific spatiotemporal gene programs with stGP. Baichen Yu, Ziyue Tan, Xiaomeng Wan, Hansheng Wang, and Can Yang. Working paper, 2026.
The software is developed and maintained by Baichen Yu.
Please feel free to contact Baichen Yu or Prof. Can Yang if any inquiries.
