Towards Spatial Transcriptomics-guided Pathological Image Recognition with Batch-Agnostic Encoder

Kazuya Nishimura, Ryoma Bise, Yasuhiro Kojima

TL;DR

This paper introduces a novel multi-modal contrastive learning framework that leverages spatial transcriptomics (ST) to improve pathological image recognition. By integrating a batch-agnostic gene encoder trained via variational inference, the method successfully filters out severe experimental "batch effects" across patients, marking the first successful attempt to use ST for patch-level tissue subtype classification.

What Problem Does This Paper Address?

Pathological image recognition typically relies purely on visual features. However, spatial transcriptomics (ST) has emerged as a powerful technique that captures both histology images and high-dimensional gene expression data across spatial coordinates (spots), as shown in Figure 1a. This gene expression data contains rich information about cellular activities and cancer subtypes that could theoretically supercharge image classification models.

The catch? Batch effects. Because ST data is highly sensitive to non-biological factors like experimental conditions and patient-specific variations, the raw gene expression profiles from different patients look completely different. As visualized via UMAP in Figure 1b, the data naturally clusters by patient rather than by actual tissue subtype. Standard multi-modal contrastive learning frameworks (like CLIP) fail here because they end up learning these patient-specific experimental artifacts instead of consistent biological signals.

Fig. 1. (a) A pair of a whole slide image and spatial transcrip- tomics. Gene expression is captured on spots, which contain the expression levels of tens of thousands of genes and with spatial coordinates. (b) Visualization of data distribution us- ing UMAP projection on her2st dataset [7]. Left and right are colorized by subtype class labels for image and patient labels.

Methods

To solve this, the authors propose a two-step representation learning framework:

  1. Training a Batch-Agnostic Gene Encoder: Instead of using raw gene counts, they employ a single-cell Variational Autoencoder (scVI) or its semi-supervised variant (scANVI). By conditioning the VAE's decoder on patient labels ($b_i$), the encoder is forced to discard patient-specific variations to align its latent space ($z_i$) with a standard normal distribution. This leaves a clean, batch-agnostic representation of the gene expression.
  2. Batch-Agnostic Contrastive Learning: The gene encoder is frozen, and its robust embeddings are used to guide the training of an image encoder (ResNet50) via contrastive learning.

The authors experiment with three contrastive loss functions: standard Symmetric InfoNCE ($L_{SI}$), Weighted Symmetric InfoNCE ($L_{LWSI}$) (which accounts for spatial similarities of neighboring spots), and a newly proposed Separated Weighted Symmetric InfoNCE ($L_{LSWSI}$) to prevent individual modality trends from being obscured.

Fig. 2. Overview of our method. scVI or scANVI are trained with the gene expression, and the encoder is reused for con- trastive learning.

Datasets

The framework was evaluated on a publicly available HER2-positive breast cancer dataset (her2st).

  • Scope: 30 slides from 7 patients, yielding 11,555 image-gene expression pairs.
  • Annotations: 2,816 samples were expertly annotated with six subtype labels: invasive cancer, connective tissue, immune infiltrate, breast glands, cancer in situ, and adipose tissue.
  • Evaluation: Patient-level leave-one-out cross-validation.

Key Insights and Ideas

  • VAEs as Batch Filters for Contrastive Learning: Repurposing scVI/scANVI—tools traditionally reserved for single-cell data analysis—as frozen encoders in a multi-modal contrastive pipeline is a clever way to bridge the gap between noisy biological data and computer vision.
  • The Illusion of Image Conditioning: While using the semi-supervised scANVI (which includes image class labels during VAE training) significantly improved class separation in the training set, it did not dramatically outperform the unsupervised scVI on the test set (see Figure 3). The authors note that forcing gene expressions into human-defined visual categories can disrupt natural genetic representations, as visual boundaries don't always perfectly mirror molecular profiles.
Fig. 3. Visualization of feature space of our method with scVI and scANVI with LSI colorized by the subtype label.

Key Results

The downstream task evaluated patch-level tissue subtype classification. As shown in the results table (Figure 4), the proposed batch-agnostic framework significantly outperformed existing multi-modal methods:

  • Ours (scANVI + $L_{SI}$) achieved a macro-F1 score of 0.354, beating standard CLIP (0.217) and BLEEP (0.084).
  • It also surpassed the ImageNet pre-trained ResNet50 baseline (0.343 macro-F1) in macro-F1, demonstrating that spatial transcriptomics can indeed inject valuable biological context that pure vision models miss. However, the ResNet50 baseline maintained higher overall accuracy (0.677 vs 0.601), likely due to the limited size of the ST dataset compared to ImageNet.
Performance comparison of the proposed framework against baseline and state-of-the-art multi-modal contrastive methods.

Limitations and Future Work

The primary bottleneck is dataset scale. With only ~11k pairs, the dataset is tiny compared to traditional computer vision benchmarks. Furthermore, human-defined visual classes might not perfectly capture the underlying continuous nature of gene expression profiles.

Future work will require scaling up to larger, multi-organ datasets (such as hest-1k). However, doing so will introduce even wider data gaps across different organs and diseases, demanding even more sophisticated batch-correction and harmonization techniques.

Summary updated

BibTeX
@inproceedings{nishimura2025towards,
  author = {Kazuya Nishimura and Ryoma Bise and Yasuhiro Kojima},
  title = {{Towards Spatial Transcriptomics-guided Pathological Image Recognition with Batch-Agnostic Encoder}},
  booktitle = {ISBI},
  year = {2025},
  doi = {10.1109/isbi60581.2025.10980754},
}
Figure