Spatial Transcriptomics as Images for Large-Scale Pretraining

Yishun Zhu, Jiaxin Qi, Jian Wang, Yuhua Zheng, Jianqiang HuangarXiv 2026

TL;DR

This paper introduces a novel paradigm for large-scale spatial transcriptomics (ST) pretraining by treating ST data as croppable, multi-channel images. By cropping fixed-size spatial patches and applying variance-weighted gene selection, the method preserves local spatial context while massively scaling up the number of training samples, significantly outperforming existing spot- and slice-based foundation models on downstream tasks.

What Problem Does This Paper Address?

Spatial Transcriptomics (ST) is a breakthrough technology that maps gene expression profiles to precise 2D coordinates on tissue sections. To unlock its full potential, researchers want to train large-scale foundation models on massive ST datasets. However, they face a fundamental dilemma: What constitutes a single training sample?

Existing methods fall into two extreme camps:

  1. Spot-based pretraining: Treats each sequencing spot independently. While this generates plenty of training samples, it discards crucial spatial relationships, essentially collapsing ST data into standard single-cell data.
  2. Slice-based pretraining: Treats an entire tissue slice as a single sample. This preserves global context but results in massive computational overhead and a very limited number of training examples.

This paper bridges this gap by finding a scalable, image-like middle ground that retains local spatial structures without blowing up the computational budget.

Figure 1. Illustration of data organization strategies for large-scale spatial transcriptomics pretraining. (a) Spot-based method: each spot is treated as an independent K-dimensional gene-expression vector, discarding spatial relationships. (b) Slice-based method: each whole tissue slice is treated as a single training sample, lead- ing to very large inputs and few examples. (c) Ours: spatial tran- scriptomics is treated as croppable multi-channel images by ex- tracting fixed-size spatial patches (h × w) with selected gene sub- sets along the channel dimension (k), preserving local spatial con- text while greatly increasing the number of training samples.

Methods

The authors propose a three-step sample construction framework to format ST slices into multi-channel images:

  • Coordinate Normalization: Staggered or irregular sequencing layouts are compacted into a tight, discrete grid ($H' \times W'$) based on relative coordinate rankings, preserving local adjacency without fabricating data.
  • Random Window Cropping: Fixed-size ($h \times w$) spatial patches are randomly cropped from the compacted grid. These patches act like local image crops, preserving neighborhood topology and drastically increasing the number of training examples.
  • Channel (Gene) Selection: To map thousands of variable genes down to a fixed channel size ($m$), the authors introduce a variance-weighted stochastic selection strategy. This stabilizes input dimensionality while ensuring biologically informative, highly variable genes are emphasized.

Using this representation, they train a Masked Autoencoder (MAE) architecture with a Vision Transformer (ViT) backbone, optimizing a masked reconstruction loss on the generated patches.

Datasets

  • Pre-training Dataset: A large corpus curated from public databases (CELLXGENE and GEO) containing 1,089,785 high-quality spots spanning multiple human and embryonic organ systems, covering both healthy and pathological states.
  • Downstream Evaluation Datasets: Six distinct human ST datasets providing region- or cell-type-level ground truth labels: DLPFC (dorsolateral prefrontal cortex), Lymph Node A1 (LNA), Lymph Node D1 (LND), Breast Cancer (BrC), Tonsil (Ton), and Colorectal (Col).

Key Insights and Ideas

  • The Spatial "Sweet Spot": Through extensive tuning, the authors found that a $16 \times 16$ patch size provides the optimal spatial scale. Smaller patches ($8 \times 8$) lack sufficient context, while larger patches ($30 \times 30$) introduce excessive background noise and tissue heterogeneity, which harms performance.
  • Stochastic Selection Beats Fixed Subsets: Instead of relying on a static set of globally highly variable genes (HVGs), locally sampling genes based on their variance within the cropped window yields more stable pretraining and better downstream generalization.
  • Data Efficiency Over Raw Volume: Remarkably, the proposed patch-based model pretrained on 1 million spots outperformed a leading slice-based foundation model (sToFM) that was pretrained on 88 million spots. This demonstrates that how data is organized for pretraining can be more critical than raw data volume.

Key Results

  • Spatial Domain Detection: When evaluating downstream tasks using an MLP classifier, the proposed method achieved an average test accuracy of 0.662 and an Adjusted Rand Index (ARI) of 0.428. This significantly beats spot-based scGPT (0.375 Acc / 0.081 ARI) and neighbor-aware scGPT-spatial (0.603 Acc / 0.342 ARI).
  • Outperforming Slice-Based SToFM: The model outperformed sToFM (which scored an average accuracy of 0.542) across the board, despite sToFM's massive pretraining advantage.
  • Masked Region Reconstruction: In tasks requiring the model to predict missing spatial regions, the proposed image-like framework consistently yielded lower Mean Squared Error (MSE) and Mean Absolute Error (MAE) compared to spatial baselines.

Limitations and Future Work

The authors note that choosing larger patch configurations ($h, w, m$) inherently increases memory and computational overhead during training. Additionally, while random window cropping significantly expands the sample pool compared to slice-based methods, it still yields fewer total training units than purely spot-level approaches.

For future directions, this image-like formulation opens the door to seamlessly integrating multimodal data—such as pairing the multi-channel gene patches directly with aligned H&E histology images using standard computer vision architectures.

Summary updated

BibTeX
@misc{zhu2026spatial,
  author = {Yishun Zhu and Jiaxin Qi and Jian Wang and Yuhua Zheng and Jianqiang Huang},
  title = {{Spatial Transcriptomics as Images for Large-Scale Pretraining}},
  year = {2026},
  eprint = {2603.13432},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.13432},
}
Figure