deepspotm

Define DeepSpot-M for virtual spatial transcriptomics from H&E tiles.

DeepSpot-M (Nonchev et al., medRxiv 2026) is a multimodal foundation model that maps a 224x224 H&E histology tile to transcriptome-wide spatial gene expression. This module wraps the standalone deepspotm package as a tiatoolbox ModelABC, so the model can be run through the tiatoolbox.models.engine.deep_feature_extractor.DeepFeatureExtractor engine over a whole-slide image. Each output “feature” column is a predicted gene, so the engine writes an (n_tiles, n_genes) expression matrix together with the matching tile coordinates.

The model weights live in the gated ratschlab/DeepSpotM Hugging Face repo: accept the terms and authenticate (huggingface-cli login) before use. The deepspotm package is an optional dependency and is imported lazily, so it is only required when this model is instantiated:

pip install tiatoolbox[deepspotm]

Example

>>> from tiatoolbox.models.architecture.deepspotm import DeepSpotM
>>> from tiatoolbox.models.engine.deep_feature_extractor import (
...     DeepFeatureExtractor,
... )
>>> # A marker panel keeps the output lean; omit ``genes`` for the full
>>> # transcriptome-wide (~19k gene) panel.
>>> model = DeepSpotM(source="scgpt", genes=["EPCAM", "CD3D", "PTPRC"])
>>> extractor = DeepFeatureExtractor(model=model, batch_size=32)
>>> output = extractor.run(
...     ["slide.svs"],
...     patch_mode=False,
...     patch_input_shape=(224, 224),
...     input_resolutions=[{"units": "mpp", "resolution": 0.5}],
...     save_dir="deepspotm_output",
... )

Module attributes

DEEPSPOTM_SOURCES

Gene-embedding sources shipped with DeepSpot-M; one is selected at load time.

Classes

DeepSpotM

DeepSpot-M model for virtual spatial transcriptomics from H&E.