nicheformer.Nicheformer
A transformer foundation model for single-cell and spatial transcriptomics of human and mouse cells.
Molecules, proteins and genomics · 489 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Parameters
- 49.3M
- Operations
- 489
- Framework
- PyTorch
- Recurrent
- No
- Published
- Nature Methods (2025)
- Cited by
- 66 (as of 22 October 2026)
- Authors
- Anna C. Schaar, Alejandro Tejada-Lapuerta, Giovanni Palla and others
- Source
- GitHub: theislab/nicheformer
- License
- BSD-3-Clause
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m7738
- Graph hash
- 2bc1c60229b42e0a45774b20c4dd21832eb0ebf48832a31ea2f185b11ba92734
- Skeleton hash
- 4806fb5a880b472970452236a03861132ba55bcf10a69101c51b4ed69affecd5
- Architecture hash
- 12f45e62ecf43055c7d75e37ef0fabb88130e4b1aa1eea868bc2fc39c12b8f3b
- Diagram SHA-256
- f61d632fdf9ac0001b563d050e0428c84b3b6e2516f2358ba44b2c7417becb5c
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
Nicheformer is a transformer-based foundation model for single-cell biology, trained on both human and mouse dissociated single-cell and targeted spatial transcriptomics data. Its pretraining collection, SpatialCorpus-110M, holds over 57 million dissociated and 53 million spatially resolved cells across 73 tissues. The aim is for the model to learn cell representations that capture spatial context.
Each cell's expression vector is converted into a ranked sequence of gene tokens. Human and mouse data share one vocabulary of 20,310 gene tokens, built by concatenating orthologous protein-coding genes with species-specific ones. Contextual tokens for species, modality and technology are added so that the model can learn their distinct characteristics. The tokenized cells go into the transformer, which is trained to predict masked tokens. The architecture takes a 1,500-token context and has 12 transformer encoder units with 16 attention heads per layer and a feed-forward network size of 1,024, producing a 512-dimensional embedding. The paper reports 49.3 million parameters in total.
For downstream use, the authors either fine-tune the model or apply linear probing, where embeddings from the frozen model pass through a task-specific linear layer. The downstream tasks they designed include spatial composition prediction and spatial label prediction. The paper also reports that models trained only on dissociated data fail to recover the complexity of spatial microenvironments.
Key idea. Nicheformer is a transformer foundation model pretrained on over 110 million human and mouse cells from dissociated and spatially resolved single-cell assays to learn spatially aware cell representations.
- nicheformer
- single-cell foundation model
- spatial transcriptomics
- spatial omics
- single-cell transcriptomics
- cell embedding
- spatialcorpus-110m
- gene expression transformer
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@article{Schaar_2024, title={Nicheformer: a foundation model for single-cell and spatial omics}, url={http://dx.doi.org/10.1101/2024.04.15.589472}, DOI={10.1101/2024.04.15.589472}, publisher={openRxiv}, author={Schaar, Anna Christina and Tejada-Lapuerta, Alejandro and Palla, Giovanni and Gutgesell, Robert and Halle, Lennard and Minaeva, Mariia and Vornholz, Larsen and Dony, Leander and Drummer, Francesca and Bahrami, Mojtaba and Theis, Fabian J}, year={2024}, month=Apr }