Authors: Yue Zhao, Elaheh Alizadeh, Yang Liu, Xu Ming, J Matthew Mahoney*, Sheng Li*
Contact: Matt.Mahoney@jax.org; Sli68423@usc.edu
In this work, we developed a framework to use Vision Transformer (ViT) to help map their tissue context, e.g., transcriptomic signatures to imaging signatures. The framework, SPiRiT (Spatial Omics Prediction and Reproducibility integrated Transformer), systematically links spatial single-cell gene expressions with the morphology of the local cellular microenvironment via ViT models. SPiRiT predicts single-cell spatial gene expression from histopathological images of human and whole mouse pup, evaluated by 10x Genomics Xenium datasets. Furthermore, the framework quantifies the confidence level of the High Attention Region (HAR) interpreting the trained ViT by measuring the consistency of attention maps of the same H&E image used in the training step or validation step.
To make SPiRiT easy to use and fully reproducible, we provide a ready-to-run Docker container that includes the full environment, dependencies, and scripts used in the manuscript. This allows anyone to recreate all experimental results with minimal setup.
docker run --memory=500g --platform=linux/amd64 -it \
yuz12012/spirit_container:latest bashNote: We recommend assigning substantial memory (e.g.,
--memory=500g) since SPiRiT processes large histology and gene-expression datasets.
Inside the container:
conda activate torch_envThis activates the SPiRiT runtime environment containing all required packages (PyTorch, OpenCV, NumPy, SciPy, etc.).
cd /workspaceThis directory contains:
Xenium/– Xenium breast cancer analysisHER2/– HER2 spatial transcriptomics analysis- Model code and utility functions
- Output folders for experiment results
Run the Xenium experiment:
python Xenium/SPiRiT_xenium.pyAll outputs (figures, predictions, and tables) will be saved to:
/workspace/output
Run the full HER2 pipeline:
python HER2/CVPrediction.py
python HER2/WangCorrelation.py
python HER2/Visualization.pyHER2 experiment results will be saved to:
/workspace/output/spirit_cv
| Dataset | Commands | Output Directory |
|---|---|---|
| Xenium Breast Cancer | python Xenium/SPiRiT_xenium.py |
/workspace/output |
| HER2 ST Dataset | python HER2/CVPrediction.pypython HER2/WangCorrelation.pypython HER2/Visualization.py |
/workspace/output/spirit_cv |