Spatial transcriptomics foundation model learning subcellular transcript positions and cell-niche context from 17 million Xenium single cells.
No providers recorded yet. Browse all providers
Imaging-based spatial transcriptomics platforms such as 10x Xenium do not report a cell as a vector of gene counts. They report individual transcript molecules, each with coordinates, which are then assigned to segmented cells. Almost every analysis pipeline immediately throws that coordinate information away by summing transcripts into a count matrix, at which point the data is treated like dissociated single-cell RNA-seq with an (x, y) label attached. Two distinct signals are lost: where a transcript sits inside its own cell, and what the cell's immediate neighbours look like.
SpatialFormer, from University of Copenhagen with collaborators at the University of Hong Kong and the Technical University of Denmark, is built to keep both. It is a hybrid architecture: convolutional layers encode the subcellular spatial distribution of each gene's transcripts, while a transformer operates over gene tokens to model the cell as a whole and its niche. Pretraining is done pairwise — the model sees two cells at a time and learns to relate them — across 700 million cell pairs drawn from 17 million spatially resolved single cells on 71 Xenium slides.
Compared with existing single-cell foundation models such as scGPT and Geneformer, which take expression vectors as input, and with spatially aware models such as Nicheformer, SpatialFormer's distinguishing input is subcellular geometry. That choice reflects what imaging-based platforms actually measure, and it means the representation carries information a count matrix cannot express.
The pretraining corpus spans 71 Xenium slides across 13 tissue types, totalling roughly 4.5 billion transcripts, over a vocabulary of 6,036 genes. The architecture combines convolutional encoding of subcellular distributions, a GraphSAGE graph neural network, and a transformer encoder accelerated with FlashAttention 2. Fine-tuning is supported through LoRA adapters, which keeps adaptation cheap relative to full-model updates. The published evaluation covers single-cell batch correction across slides, cell-type annotation, and co-localization detection; perturbation analysis identified gene pairs essential to immune cell-cell communication in pulmonary fibrosis, epithelial-myoepithelial co-localization, and tumour transition signals in breast cancer. Code is MIT-licensed and installable from PyPI as spatialformer, with checkpoints distributed through Zenodo and Figshare and tutorial notebooks provided in Colab.
The model suits groups running Xenium or comparable imaging-based panels who need to integrate multiple slides, transfer cell-type labels without hand-annotating each section, or ask which ligand-receptor-like gene pairs mediate contact between specific cell types in a tissue. Because embeddings are extracted from a frozen checkpoint, it fits into standard single-cell workflows as a representation step ahead of clustering, annotation, or differential analysis, with LoRA fine-tuning available where a task needs adaptation.
Published in Nature Computational Science, SpatialFormer stakes out subcellular molecular geometry as a pretraining signal that spatial omics models had largely left unused. Its main scope limit is the platform it was trained on: a 6,036-gene vocabulary derived from targeted Xenium panels does not cover the transcriptome, so applying it to sequencing-based spatial assays or to panels with different gene sets requires care. The released package, pretrained weights, and tutorial notebooks lower the barrier to reusing the representation, though the practical value of subcellular geometry depends on segmentation quality, which remains the weakest link in imaging-based spatial transcriptomics.
Much of this page is generated or calculated automatically. Flag anything that looks off and we will re-run it.