STPath: a generative foundation model for integrating spatial transcriptomics and whole-slide images

Tinglin Huang, Tianyu Liu, Mehrtash Babadi, Rex Ying, Wengong JinNpj Digit. Medicine 2025

Abstract

Spatial transcriptomics (ST) has shown remarkable promise in pathology applications, shedding light on the spatial organization of gene expression and its relationship to the tumor microenvironment. However, its clinical adoption remains constrained due to the limited scalability of current sequencing technologies. While recent methods attempt to infer ST from whole slide images (WSIs) using pretrained image encoders, they remain restricted by limited gene coverage, organ-specific training, and the need for dataset-specific fine-tuning. In light of this, we introduce STPath, a generative foundation model pretrained on a large-scale collection of WSIs paired with ST profiles. This extensive pretraining enables STPath to directly predict gene expression across 38,984 genes and 17 organs without requiring downstream fine-tuning. STPath integrates multiple data modalities, including histological images, gene expressions, organ type, and sequencing technology information, within a novel geometry-aware Transformer architecture. Unlike previous methods that directly map WSIs to gene expression, STPath is trained using a masked gene expression prediction objective guided by tailored noise schedules, effectively balancing between capturing gene-gene dependencies and performing high-quality predictions. We evaluate STPath across 6 tasks spanning 23 datasets and 14 biomarkers, including gene expression prediction, spot imputation, spatial clustering, biomarker prediction, gene mutation prediction, and survival prediction. These results demonstrate STPath’s strong ability to infer spatially resolved gene expression and reveal crucial pathological structures within tissue samples, underscoring its promise for scalable ST-based pathology applications.

Introduction

Spatial Transcriptomics (ST) is a transformative technology that maps gene expression directly onto tissue architecture, providing a high-resolution view of the tumor microenvironment. However, ST remains expensive and low-throughput, hindering its routine clinical use. While researchers have attempted to infer gene expression from standard, inexpensive H&E-stained Whole Slide Images (WSIs), existing methods often suffer from narrow gene coverage, organ specificity, and the need for extensive fine-tuning. STPath addresses these challenges by acting as a universal foundation model that generalizes across organs and technologies without task-specific retraining.

Methods and Data

STPath is a generative framework that treats tissue spots as tokens in a sequence. It integrates four distinct data tracks: visual features (extracted via the Gigapath foundation model), gene expression levels, organ types, and sequencing technology information. The model utilizes a geometry-aware Transformer backbone with a "frame averaging" mechanism to ensure E(2)-invariance, keeping predictions consistent regardless of tissue orientation.

STPath framework overview, including dataset composition and the geometry-aware Transformer architecture.

The model was pretrained on a massive corpus of 983 slides covering 38,984 genes across 17 organs, curated from the HEST-1K and STImage-1k4m resources. Using a masked modeling objective with a Beta-distribution-based noise schedule, STPath learns to "fill in the blanks" of hidden gene expressions using both visual cues and neighboring spot data. This approach allows the model to perform both pure image-to-gene prediction and "in-context prompting," where a small amount of known expression data improves overall slide prediction.

Key Insights and Results

STPath is the first model to demonstrate strong zero-shot performance across diverse organs and thousands of genes. A significant finding is the power of in-context prompting: providing the actual expression for just 5% of spots allows the model to drastically improve its predictions for the remaining 95% of the slide.

Performance evaluation of STPath across multiple cancer types and prompting scenarios.

Quantitatively, STPath achieved a 6.9% improvement in Pearson correlation over state-of-the-art models on the HEST-Bench benchmark. Beyond visualization, STPath’s predicted features serve as a "feature multiplier" for clinical tasks. Adding these features improved survival prediction C-indices for models like UNI and Gigapath by 6.1% and 5.6%, respectively. In unsupervised settings, the model predicted TP53 mutation status in breast cancer with an AUC of 0.73 and successfully recovered complex biological structures, such as cortical layers and tumor-stroma boundaries.

Discussion and Future Work

While STPath shows immense promise, performance varies in organs with scarce training data, such as the kidney. Future research will focus on scaling the pretraining corpus and integrating additional spatial omics modalities, such as scATAC-seq, to provide an even more holistic view of tissue biology. By bridging histology and high-dimensional molecular data, STPath offers a scalable path toward advanced ST-based pathology applications.

Summary updated

BibTeX
@article{huang2025stpath,
  author = {Tinglin Huang and Tianyu Liu and Mehrtash Babadi and Rex Ying and Wengong Jin},
  title = {{STPath: a generative foundation model for integrating spatial transcriptomics and whole-slide images}},
  journal = {Npj Digit. Medicine},
  year = {2025},
  doi = {10.1038/s41746-025-02020-3},
}
Figure