bioRxivBioinformaticsPreprint
Nicheformer: a foundation model for single-cell and spatial omics
Anna Christina SchaariD, Alejandro Tejada-LapuertaiD, Giovanni PallaiD, Robert M. GutgeselliD, Lennard HalleiD, Mariia MinaevaiD, Larsen VornholziD, Leander DonyiD, Francesca DrummeriD, Mojtaba BahramiiD, Fabian Joachim TheisiD
Abstract
Tissue makeup relies fundamentally on the cellular microenvironment. Spatial single-cell genomics allows probing the underlying cellular interactions in an unbiased, scalable fashion. To learn a unified cell representation that accounts for local dependencies in the cellular microenvironment, we propose Nicheformer, a transformer-based foundation model that combines human and mouse dissociated single-cell and targeted spatial transcriptomics data. Pretrained on over 57 million dissociated and 53 million spatially resolved cells across 73 tissues on cellular reconstruction, the model is fine-tuned on spatial tasks for spatial omics data to decode spatially resolved cellular information. Nicheformer excels in linear-probing and fine-tuning scenarios for a novel set of downstream tasks, in particular spatial composition prediction and spatial label prediction. We further show that existing foundation models trained on dissociated single-cell data alone are not capable of recapitulating the spatial complexity of cells in their microenvironments, indicating that multiscale models are required to understand complex local dependencies at scale. Nicheformer enables the prediction of the spatial context of dissociated cells, allowing the transfer of rich spatial information to scRNA-seq datasets. Overall, Nicheformer sets the stage for the next generation of machine-learning models in spatial single-cell analysis. Extended AbstractTissue makeup and the corresponding orchestration of vital biological activities, ranging from development and differentiation to immune response and regeneration, rely fundamentally on the cellular microenvironment and the interactions between cells. Spatial single-cell genomics allows probing such interactions in an unbiased and, increasingly, scalable fashion. To learn a unified cell representation that accounts for local dependencies in the cellular microenvironment and the underlying cell interactions, we propose to generalize recent foundation modeling approaches for disassociated single-cell transcriptomics to the spatial omics setting. Our model, Nicheformer, is a transformer-based foundation model that combines human and mouse dissociated single-cell and targeted spatial transcriptomics data to learn a cellular representation useful for a large variety of downstream tasks. Nicheformer is pretrained on over 57 million dissociated and 53 million spatially resolved cells across 73 tissues from both human and mouse. Subsequently, the model is fine-tuned on spatial tasks for spatial omics data to decode spatially resolved cellular information. We demonstrate the usefulness of Nicheformer in both linear-probing as well as fine-tuning scenarios on a novel set of spatially-relevant downstream tasks such as spatial density prediction or niche and region label prediction. In particular, we show that Nicheformer enables the prediction of the spatial context of dissociated cells, allowing the transfer of rich spatial information to scRNA-seq datasets. We define a series of novel spatial prediction problems and observe consistent top performance of Nicheformer, demonstrating the advantage of the improved model capacity of the underlying transformer. Additionally, we benchmarked Nicheformer in these tasks against scGPT1, Geneformer2, scVI3 and PCA and show that the Nicheformer architecture excels in these tasks. Altogether, our large-scale resource of more than 110 million cells in a partial spatial context, together with the set of novel spatial learning tasks and the Nicheformer model itself, will pave the way for the next generation of machine-learning models for spatial single-cell analysis.
- organism: human
- organism: mouse
- assay: spatial transcriptomics
- assay: scRNA-seq
- assay: snRNA-seq
- research focus: cell type annotation
- research focus: database / resource
- research focus: benchmarking
- research focus: spatial domain detection
- approach: transformer / foundation model
- approach: deep learning
In-depth summary
Claude Opus 5.5 · xhigh effort · 7 Nov 2026 · from the full text of version 2 (26 Oct 2024) · CC BY 4.0
Pretrained on 57 million dissociated and 53 million spatial human and mouse cells, a 49.3M-parameter transformer predicts niche, region, neighborhood composition and density, and carries spatial labels onto scRNA-seq.
Dissociating cells for scRNA-seq discards tissue context, and per the paper prior single-cell foundation models ignore spatial relationships in training, except CellPLM (9 million dissociated, 2 million spatial cells; no spatial fine-tuning beyond gene imputation). Nicheformer pretrains jointly on dissociated and image-based spatial transcriptomes with assay, modality and organism tokens, and introduces spatial tasks testing whether expression encodes tissue context.
Key results
ShownLinear probes on frozen Nicheformer embeddings, and more so the fine-tuned model, beat Geneformer, scGPT, scVI and PCA embeddings at predicting niche and region labels on held-out MERFISH mouse brain sections.
Macro F1 on held-out sections of one male brain (4.3 million cells, 500 genes; 7 niche and 17 region labels), against scVI and PCA trained on the dataset or a 1% SpatialCorpus subset; values are in Fig. 4B, not the text. On CosMx human liver zonation (6 niche labels), fine-tuning was best but linear probing trailed dataset-trained scVI and PCA, improving after extra pretraining on liver training data. · Nicheformer allows transferring…; MERFISH mouse brain; CosMx human liver; Figure legends
SuggestedClassifiers trained on MERFISH mouse brain labels assign dissociated mouse motor cortex scRNA-seq cells to plausible spatial cell types, niches and regions, with errors for deep-layer glutamatergic neurons and non-neuronal regions.
On 7,416 10x v3 cells, predictions used the nine motor-cortex-related types out of 33; all non-neuronal cells received their mapped type, but some L6b, L6 CT and L5/6 NP cells were labeled midbrain glutamatergic. All neurons were assigned isocortex, yet 84.7% of non-neuronal cells (n=133) fell outside isocortex or adjacent regions; some Glut neurons got the wrong niche. · Nicheformer allows transferring…; Single-cell RNA-seq of the primary motor cortex; Figure legends
ShownNicheformer embeddings predict local cell type composition better than other embeddings in mouse brain and human lung, with fine-tuning best; in human liver, scVI is competitive at larger radii.
Mean absolute error at radii averaging 10, 20, 50 and 100 neighbors on MERFISH mouse brain, CosMx human liver and lung: fine-tuned Nicheformer lowest, its linear probe next, ahead of probes on Geneformer, scGPT, scVI and PCA; at larger liver radii, scVI trained on a SpatialCorpus subset matched fine-tuned Nicheformer. Best-predicted brain types were among the 8 most abundant of 33; the 4 worst among the 14 rarest. · Nicheformer predicts neighborhood compositions…; Neighborhood composition; Figure legends
ShownA linear probe on frozen Nicheformer embeddings predicts per-cell neighborhood density in human lung and colon Xenium sections, including higher predicted density in lung tumor regions, where scVI and PCA probes fail.
Lower mean absolute error and higher R than scVI and PCA probes, whose R values were negative (worse than random), on Xenium lung (healthy vs invasive adenocarcinoma; 25 µm radius) and colon (healthy vs stage 2A adenocarcinoma; 17 µm). Observed mean density was 12.3 (colon) and 12.1 (lung) cells in cancer vs 10.7 in each healthy section. · Nicheformer infers cellular niche density in…; Xenium human lung; Xenium human colon; Neighborhood cell density prediction
SuggestedAttention weights differ between male and female MERFISH mouse brain cells in the anteroventral periventricular nucleus (AVPV), although sex was never given as an input, and point to genes not known to be sexually dimorphic.
From 2,000 cells per sex, maximal attention differences for ten sexually dimorphic genes rose in layers 9 and 10, mainly in HY GABA cells, compared with random control genes; six of the ten genes with the largest attention differences (Adgrf5, Nfib, Pou6f2, Rgs4, Serpine2, Spock3) have no reported dimorphic brain expression. One male and one female brain were compared. · Nicheformer learns sex-related difference in…; Nicheformer attention analysis; Figure legends
Methods, data and reproducibility
Cells are tokenized as genes ranked by expression relative to a technology-specific non-zero mean, prefixed by assay, modality and organism tokens; a 12-layer, 16-head transformer (512-dimensional, 49.3M parameters, 1,500-token context) is pretrained by masked token prediction. Mean-pooled last-layer gene tokens are evaluated by linear probing or fine-tuning on spatial label, composition and density tasks.
- SpatialCorpus-110M: dissociated data (CellXGene Census, sfaira, GEO, HCA) plus image-based spatial data (MERFISH, Xenium, CosMx, ISS; 60 datasets, 15 organs) · human and mouse · n = 57.06 million dissociated + 53.83 million spatial cells
- MERFISH whole mouse brain (Yao et al.), 500-gene panel, one male brain; label and composition tasks · mouse · n = 4.3 million cells, 59 sections
- Male and female MERFISH mouse brain datasets from the corpus, AVPV region, for attention analysis · mouse · n = 2,000 cells per sex
- CosMx human liver, healthy and hepatocellular carcinoma sections, 1000-plex panel · human · n = 332,877 and 460,441 cells
- CosMx human lung, 1000-plex panel, eight fields of view · human · n = 5 donors; 301,611, 89,975, 227,110, 71,304 and 81,236 cells
- Xenium human lung, healthy and invasive adenocarcinoma sections (289-plex panel plus 100 genes) · human · n = 295,883 and 531,165 cells
- Xenium human colon FFPE, non-diseased and stage 2A adenocarcinoma sections (325-plex panel plus 100 genes) · human · n = 275,822 and 587,115 cells
- Mouse primary motor cortex scRNA-seq (Yao et al.), 10x v3 subset, 19 cell types · mouse · n = 7,416 cells, 21,884 genes
- Methods & tools
- Nicheformer, CZ CellXGene Discover Census (2023-07-15), sfaira, scvi-tools 1.1.2 (scVI), scikit-learn 1.4.1 (PCA), scanpy 1.10.1, Geneformer 0.0.1, scGPT 0.2.1, pyEnsembl and BioMart (Ensembl release 104), scIB, Ontology Lookup Service, MERFISH, Xenium, CosMx, ISS
- Data & accessions
- https://www.10xgenomics.com/datasets
- Software & environment
- Versions stated: scvi-tools 1.1.2, scikit-learn 1.4.1, scanpy 1.10.1, Geneformer 0.0.1, scGPT 0.2.1, CellXGene Census 2023-07-15, Ensembl release 104; hyperparameters in Suppl. Tables 1 and 5. No container or requirements file is described.
- Assay conditions & compute
- Pretraining took about 10 days on three nodes with four Nvidia A100 40GB GPUs each (12 GPUs), bfloat16 mixed precision.
- Reproducibility gaps
- The data-script repository is described both as available and as forthcoming; several Allen Institute and collaborator spatial datasets were provided prior to publication; no download location for pretrained weights is stated; dataset IDs are only in supplementary tables.
Limitations (6)
- Accuracy depends on how abundant and transcriptionally diverse the cells and tissues are; rare midbrain and hypothalamic types and the underrepresented liver were predicted worse. · stated by the authors
- Physical cell locations are deliberately not used in pretraining, so the model cannot fully exploit spatial context; spatial neighbor graphs are left for future versions. · stated by the authors
- Interpretability is not fully explored, the model has not been scaled in parameters, pretraining time or data, and the spatial task set is not a comprehensive benchmark. · stated by the authors
- The MERFISH gene panel was designed to separate cell types rather than sexes, which constrains the attention-based sex-difference analysis. · stated by the authors
- Density tasks use random cell hold-outs within the same Xenium sections, so test cells share neighborhoods with training cells; Geneformer and scGPT were not compared on density. · noted in this summary
- Transfer to scRNA-seq is judged on one mouse motor cortex dataset against a manual cell type mapping, without a summary accuracy score, and that dataset is in the pretraining corpus. · noted in this summary
Read this if you want to add spatial niche, region or neighborhood information to dissociated scRNA-seq data, or are building or benchmarking single-cell foundation models that combine dissociated and image-based spatial transcriptomics.
- Citations
- 66
Reproducibility ledger
Nobody has reported trying to reproduce this paper yet. Did you replicate an experiment or run the code? Your report saves the next lab a week.
Sign in to file a reproducibility report.
Related papers
- OmniCell: Unified Foundation Modeling of Single-Cell and Spatial Transcriptomics for Cellular and Molecular Insights
Jiangshuan Pang, Ping Sun Qiu, … Xun Xu·bioRxiv·Jun 23, 2026
- AIDO.Tissue: Spatial Cell-Guided Pretraining for Scalable Spatial Transcriptomics Foundation Model
Jing Gong, Yixuan Wang, … Eric P. Xing·bioRxiv·Jul 4, 2025
- stFormer: a foundation model for spatial transcriptomics
Shenghao Cao, Kaiyuan Yang, … Ye Yuan·bioRxiv·Sep 27, 2024
- NicheTrans: Spatial-aware Cross-omics Translation
Zhikang Wang, Qi Zou, … Zhiyuan Yuan·Nature MethodsPeer-reviewed·Jul 9, 2026
- SpatialFormer: Universal Spatial Representation Learning from Subcellular Molecular to Multicellular Landscapes
Jun Wang, Yuanhua Huang, Ole Winther·Nature Computational SciencePeer-reviewed·Jul 30, 2026
- NexuST: A Hierarchical Foundation Model for Spatial Transcriptomics
Haiping Liu, Qian Zhao, … Hongpeng Zhou·bioRxiv·Sep 28, 2026