SpatialGT Pretrained Model

SpatialGT learns neighborhood-conditioned expression dependencies from spatial transcriptomics data. This repository contains its pretrained checkpoint for section-specific adaptation, expression reconstruction, denoising and virtual perturbation inference.

SpatialGT architecture

Model and training data

  • Parameters: 240,040,539.
  • Gene representations: a trainable 3,072-dimensional embedding table, projected to a 512-dimensional hidden space. Spot representations are expression-weighted sums of projected gene embeddings.
  • Spatial model: eight transformer blocks with eight attention heads, reconstructing a masked center spot from its eight nearest neighbors.
  • Pretraining corpus: 1,137 human tissue sections and over 25 million spots across Visium, Visium HD, Xenium, MERFISH and Slide-seqV2.
  • Inputs: log-normalized expression, vocabulary-aligned gene IDs and a spatial-neighbor graph constructed from spot coordinates.
  • Outputs: continuous center-spot expression predictions in log-normalized expression space, with an output head covering the 59,483-entry vocabulary.

The gene embedding table is stored in the checkpoint. The matching vocab.json maps gene names to model token IDs and is included in the GitHub repository.

Usage

Clone SpatialGT and follow its environment setup instructions. Run the following from the repository root:

import torch
from huggingface_hub import hf_hub_download
from pretrain.Config import Config
from pretrain.checkpoint import load_model_checkpoint

weights = hf_hub_download(
    repo_id="Bgoood/SpatialGT-Pretrained",
    filename="checkpoint/model.safetensors",
)
config = Config()
config.vocab_file = "vocab.json"
device = "cuda:0" if torch.cuda.is_available() else "cpu"
model = load_model_checkpoint(weights, config, device=device)
model.eval()

The GitHub repository provides preprocessing, fine-tuning, random-mask reconstruction and perturbation scripts, together with an interactive Agent UI. Virtual perturbation uses the trained expression model within the dual-line inference procedure.

Repository files

  • checkpoint/model.safetensors: pretrained model weights.
  • checkpoint/training_args.bin and checkpoint/trainer_state.json: training configuration and state.
  • checkpoint/optimizer.pt, checkpoint/scheduler.pt and checkpoint/rng_state_*.pth: optimizer, scheduler and random-number states.

Inference uses checkpoint/model.safetensors and the GitHub vocabulary.

Manuscript

Yucheng Xu, Junning Feng, Yawen Lu and Yanlin Zhang. SpatialGT predicts spatially resolved tissue responses to local transcriptomic perturbations.

License

MIT License.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support