Writing
July 5, 2026 · 6 min read

Genes as queries: the trick behind DeepSpot-M's virtual spatial transcriptomics

DeepSpot-M reframes spatial gene-expression prediction from histology as a query over gene embeddings instead of a fixed output list, letting it generalize zero-shot to genes and cancer types never seen in training.

spatial-transcriptomicsfoundation-modelscomputational-pathologyzero-shot-learningmultimodal-ai

Routine histology — a stained tissue slide under a microscope — gets produced for nearly every cancer diagnosis on Earth. Spatial transcriptomics, which measures gene expression in situ while preserving where each cell sits in the tissue, gets produced for almost none of them: it's expensive, slow, and technically demanding enough that most hospitals will never run it as standard of care. A new preprint out of ETH Zurich and the University Hospital Zurich, DeepSpot-M, tries to close that gap by predicting spatial gene expression directly from the H&E slide you already have.

I want to spend this post on the part of the paper that's interesting to me as a model builder, not a biologist: the reformulation that lets DeepSpot-M predict genes it never saw during training. That's not a minor implementation detail — it's the same move that made open-vocabulary vision models and retrieval-augmented systems work, applied here to a genuinely hard biological prediction problem.

The failure mode this replaces

Prior histology-to-expression models treat gene expression prediction as ordinary multi-output regression: a pathology encoder pools a tissue tile into one embedding, and a fixed output head with one neuron per gene reads off predicted expression. That works, but it hard-codes two limits into the model. First, you can only ever predict the genes you trained on, usually a few hundred chosen upfront as a fixed panel. Second, because each cohort's spatial transcriptomics data is idiosyncratic — different capture efficiency, different tissue, different institution — models trained on one cohort transfer poorly to the next. The result, in the authors' framing, is that existing methods stay restricted to predefined genes and small cohorts.

Genes as queries, not output slots

DeepSpot-M's fix is to stop treating a gene as a column in an output vector and start treating it as a query. Each gene is represented by an embedding pulled from foundation models trained independently on DNA sequence, RNA and transcript structure, protein sequence, single-cell expression atlases, and biomedical text — five separate views of what that gene is, all computed outside the spatial assay itself. Because that representation doesn't depend on the gene having appeared in an ST dataset, the model can score genes it was never trained to predict: expression becomes a function of (tissue patch, gene embedding) rather than (tissue patch) mapped to one fixed vector.

Comparing a fixed gene-panel output head against DeepSpot-M's cross-attention gene-query decoder

Three architectural choices that make it work

Concretely, a 224×224 H&E tile is tokenized by a LoRA-adapted pathology foundation model into a grid of spatial patch embeddings, kept as a set of tokens with spatial identity intact rather than pooled into a single vector. A cross-attention gene decoder then lets each gene's query embedding attend directly to those patch tokens, so a gene tied to immune infiltration can attend to different regions of a tile than a gene tied to epithelial structure. A gene-router hypernetwork turns each gene's frozen biological embedding into a gene-specific output projection on the fly, instead of storing a separate learned weight per gene. None of the three components needs retraining to add a new gene — the model just needs that gene's embedding.

What that generalization actually buys

The authors trained on 730,000 paired histology–transcriptomic profiles from roughly 500 10x Visium samples across 14 cancer types — by their account, one of the largest oncology spatial transcriptomics datasets assembled to date. Tested on five held-out datasets from the multi-centre MOSAIC Window program (four cancer types entirely absent from training, one glioblastoma cohort testing transfer within a seen cancer type), DeepSpot-M outperformed models trained specifically on those cohorts. More tellingly, genes withheld entirely from training were predicted at accuracy comparable to genes the model had actually seen during training — direct evidence that the query formulation, not just more data, is doing the generalization work. A test-time adaptation step further lets the model adapt to a new single-cell spatial assay from as little as one slide, using the sample's own partial measurements as supervision.

Scaling it to a population-level atlas

The paper's biggest number shows up downstream: applying DeepSpot-M to The Cancer Genome Atlas, the team generated a virtual spatial transcriptomics atlas covering 28,664 slides across 32 cancer types, recovering a pan-cancer map of malignancy from histology alone, at a scale no wet-lab spatial protocol could reach. Because the query interface is gene-agnostic, the same model, with no architecture changes, also supports transcriptome restoration, cross-species non-coding RNA inference, in silico variant-effect mapping, and natural-language querying over expression.

The caveat, and the bigger idea

This is a preprint, not yet peer reviewed, and the authors are explicit that it shouldn't guide clinical practice. Virtual predictions from histology are a hypothesis-generation tool, not a replacement for measured expression, and the usual failure modes of foundation-model transfer — distribution shift across scanners, staining protocols, and patient populations — still need scrutiny before anything like this reaches a pathologist's workflow.

But the underlying pattern is worth sitting with regardless of domain. Anywhere a model's output space used to be a fixed, enumerable list — genes, SKUs, tool calls, document classes — swapping that list for an embedding you can query tends to unlock the same thing: prediction over things the model never explicitly trained on. I've seen this exact tradeoff play out in agentic tool-use systems, where hard-coding a tool registry caps what an agent can ever call, versus embedding tool descriptions and retrieving over them at inference time. DeepSpot-M is a clean, well-benchmarked instance of that same idea, applied somewhere the enumerable list was twenty thousand genes and the payoff is a biomarker map you couldn't have measured directly in the first place.

References
  1. 01DeepSpot-M: a multimodal foundation model for transcriptome-wide virtual spatial transcriptomics from histology (Nonchev et al., medRxiv preprint)