# Deepspot M

Generate transcriptome-wide virtual spatial transcriptomics from H&E histology with...

- Repository: https://github.com/synthetic-sciences/openscience (4321 stars)
- Category: Documents
- License: PolyForm-Noncommercial-1.0.0
- Last updated: 2026-10-30
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add synthetic-sciences/openscience --skill deepspot-m -g -a claude-code -y`
Codex: `npx skills add synthetic-sciences/openscience --skill deepspot-m -g -a codex -y`
Cursor: `npx skills add synthetic-sciences/openscience --skill deepspot-m -g -a cursor -y`
Gemini CLI: `npx skills add synthetic-sciences/openscience --skill deepspot-m -g -a gemini-cli -y`

## Description

Generate transcriptome-wide virtual spatial transcriptomics from H&E histology with DeepSpot-M. Use when you need spatial gene expression in log1p-CPM for 224x224 tiles at about 20x, want to query protein-coding genes by symbol instead of a fixed panel, or want to run prediction across a whole slide after tiling with histolab.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# DeepSpot-M

## Overview

DeepSpot-M is a multimodal foundation model that maps a 224x224 H&E histology tile to
spatial gene expression in log1p-CPM. The output is virtual spatial transcriptomics: one
value per queried gene per tile, laid out on the grid the tiles came from.

A LoRA-adapted pathology foundation backbone (Midnight) tokenises the tile. A
cross-attention gene decoder lets each gene query attend to the patch tokens, and a gene
router hypernetwork builds gene-specific projections from frozen biological embeddings
(Evo 2, Orthrus, ProtT5, scGPT, Apertus). Genes enter the model as queryable embeddings
rather than fixed output slots, so the released model covers a ~19k protein-coding gene
panel including genes unseen in training. The panel ships with the weights as
`tokens.csv` and is exposed as `model.gene_names`; genes outside it cannot be queried in
this release.

Applied to TCGA, the model produced a virtual spatial transcriptomics atlas of 28,664
slides across 32 cancer types.

## Licensing

The code is PolyForm Noncommercial 1.0.0 and the weights are CC-BY-NC-SA-4.0. Use it for
noncommercial research and check both licences before redistributing outputs.

## Installation

```bash
uv pip install deepspotm==1.0.0
```

Version 1.0.0 targets Python 3.10 to 3.13 and pulls in PyTorch. Install the PyTorch build
that matches your CUDA version first if you want GPU inference.

## Model access

The weights are gated:

1. Open <https://huggingface.co/ratschlab/DeepSpotM> and request access.
2. Once access is granted, authenticate the machine that will download them:

```bash
huggingface-cli login
```

`from_pretrained` reads that cached token, so a login is needed once per machine.

## Quick start

```python
from deepspotm import DeepSpotM

model, image_processor = DeepSpotM.from_pretrained("ratschlab/DeepSpotM", source="scgpt")

vals = model.predict_genes(image_processor(pil_tile).unsqueeze(0), ["EPCAM", "CD3D"])
```

The rest: https://github.com/synthetic-sciences/openscience/blob/HEAD/backend/cli/skills/biology/deepspot-m/SKILL.md
