Spatially Gene Expression Prediction Using Dual-Scale Contrastive Learning

Mingcheng Qu, Yuncong Wu, Donglin Di, Yue Gao, Tonghua Su, Yang Song, Lei Fan

Abstract

Spatial Transcriptomics (ST) provides critical insights into the spatial organization of gene expression within tissues, yet its high cost and technical complexity limit its widespread adoption. While deep learning models have attempted to predict gene expression directly from standard pathology Whole Slide Images (WSIs), existing methods often fail to capture the complex spatial dependencies and multi-scale biological interactions inherent in tissue samples. We present NH²2ST (Neighbor-guided Hypergraph Histopathology to ST), a novel framework that utilizes a dual-branch architecture and hypergraph modeling to align pathology images with genetic data. By leveraging cross-modal contrastive learning and neighborhood-aware features, NH²2ST achieves a significant improvement in prediction accuracy, outperforming state-of-the-art methods by over 20%.

Introduction

Spatial Transcriptomics has revolutionized our understanding of tissue architecture by mapping gene activity to specific anatomical locations. However, the financial and logistical barriers to performing ST at scale remain high. A promising alternative is the use of computational models to infer gene expression from Hematoxylin and Eosin (H&E) stained pathology images, which are ubiquitous and inexpensive.

The primary challenge in this field is that biological function is not isolated to individual cells or small tissue patches; it is inherently "social." Genes in one region are often co-expressed with those in neighboring areas, and tissue structures span across multiple patches. Current AI models frequently treat tissue patches in isolation, failing to capture these higher-order spatial relationships. NH²2ST addresses these limitations by modeling multi-scale spatial contexts through hypergraphs and aligning image-gene modalities via contrastive learning.

Methodology

NH²2ST introduces a dual-branch architecture designed to capture both local and global spatial features during the training phase.

1. The Query Branch

This branch focuses on the target tissue patch. It employs a Pathology Encoder (based on ResNet18) and a dedicated ST Encoder to extract features from the image and gene modalities, respectively. A cross-attention mechanism is then utilized to allow these features to interact, refining the image representations based on mutual information shared with the genetic data.

2. The Neighbor Branch (Auxiliary)

To capture the broader biological context, the Neighbor Branch analyzes the $K$ nearest neighboring patches. Unlike standard graphs that connect nodes via simple pairwise edges, NH²2ST utilizes Hypergraphs. In a hypergraph, a single edge can connect multiple nodes simultaneously, which more accurately represents how groups of genes are co-expressed across a continuous tissue region. This allows the model to learn from "neighborhood effects" that simpler architectures miss.

3. Dual-Scale Contrastive Learning

The framework employs the InfoNCE loss to align the image and gene modalities at two scales: the single-patch level and the neighborhood level. This contrastive approach ensures the model learns a shared latent space where pathology features are directly mapped to their corresponding genetic signatures. During inference, the neighbor branch is removed, allowing the model to predict gene expression using only the pathology image patches through a specialized Predictor Translator.

Experimental Results

The model was rigorously evaluated across six diverse datasets, including ST-Net (breast cancer), Skin (squamous cell carcinoma), STimage-1K4M (Human PCW and Mouse samples), and HEST-1k (INT and ZEN subsets). These datasets represent a wide array of species, organs, and disease states.

Quantitative Performance

NH²2ST consistently outperformed existing state-of-the-art models such as TRIPLEX and BLEEP. On the PCW dataset, the model achieved a Pearson Correlation Coefficient (PCC) of 0.560, representing a substantial improvement over previous benchmarks. Across various metrics, the model demonstrated a boost of approximately 20% in prediction accuracy, indicating a much stronger linear correlation between predicted and actual gene expression levels.

Qualitative Analysis

Visual comparisons of expression heatmaps reveal that NH²2ST produces patterns that closely mirror the "ground truth" labels. While patch-only methods often result in noisy or fragmented predictions, NH²2ST maintains spatial consistency, particularly in regions of high gene expression, reflecting its ability to capture the underlying biological structure of the tissue.

Discussion and Future Work

The success of NH²2ST highlights the importance of two key factors: the use of hypergraphs to model higher-order biological interactions and the necessity of cross-modal alignment. By pulling the pathology encoder toward both predictive accuracy and modal coherence, the framework creates a more robust feature extractor.

However, some limitations remain. Currently, the neighbor branch is utilized only during training to simplify inference; future research could explore methods to safely incorporate neighborhood data during actual prediction without introducing noise. Additionally, the model's performance is sensitive to the alignment between pathology images and ST spots. Improvements in data preprocessing and the handling of "batch effects" in genomic data will be essential for the further evolution of WSI-to-gene expression translation.

Summary updated

BibTeX
@inproceedings{qu2025spatially,
  author = {Mingcheng Qu and Yuncong Wu and Donglin Di and Yue Gao and Tonghua Su and Yang Song and Lei Fan},
  title = {{Spatially Gene Expression Prediction Using Dual-Scale Contrastive Learning}},
  booktitle = {International Conference on Medical Image Computing and Computer-Assisted Intervention},
  year = {2025},
  doi = {10.1007/978-3-032-05182-0\_56},
}
Figure