ICML
SPATIA / README.md
TonyK's picture
Update README.md
90724a5 verified
|
Raw
History Blame Contribute Delete
6.83 kB
metadata
license: mit
datasets:
  - mims-harvard/SPATIA_MIST
tags:
  - ICML

SPATIA: Multimodal Model for Prediction and Generation of Spatial Cell Phenotypes

Overview

SPATIA is a multi-scale model for spatial transcriptomics that learns cell-level embeddings by fusing image-derived morphological tokens and transcriptomic tokens via cross-attention, aggregates them at niche and tissue levels, and generates cell morphology images conditioned on predicted state transitions using flow matching.

This repository hosts pretrained model weights, precomputed embeddings, evaluation results, and tutorial notebooks for reproducing the paper's prediction and generation experiments.


Repository Structure

mims-harvard/SPATIA/
β”œβ”€β”€ embeddings/
β”‚   └── spatia_embeddings.npy          # Precomputed cell embeddings (98.5 MB)
β”œβ”€β”€ notebooks/
β”‚   β”œβ”€β”€ prediction_tasks_showcase.ipynb # Clustering & annotation benchmarks
β”‚   └── spatia_generation_inference.ipynb  # Flow-matching image generation
β”œβ”€β”€ pretrained/
β”‚   β”œβ”€β”€ best_model.pt                  # Pretrained SPATIA-scGPT weights (220 MB)
β”‚   β”œβ”€β”€ args.json                      # Training configuration
β”‚   β”œβ”€β”€ vocab.json                     # Gene vocabulary (30k+ genes)
β”‚   └── all_dict_mean_std.csv          # Gene expression normalization statistics
β”œβ”€β”€ results/
β”‚   β”œβ”€β”€ table2_summary.csv             # Clustering benchmarks (Table 2)
β”‚   └── table4_clustering_summary.csv  # scRNA-seq clustering (Table 4)
β”œβ”€β”€ .gitattributes                     # Git LFS tracking rules
└── README.md

Components

pretrained/ β€” Model Weights & Config

Pretrained SPATIA-scGPT checkpoint for cell representation learning.

File Description
best_model.pt Model weights (12-layer transformer, 512-dim, trained on MIST atlas)
args.json Full training hyperparameters (lr, batch size, masking ratios, etc.)
vocab.json Gene-to-token vocabulary mapping
all_dict_mean_std.csv Per-gene mean and std for input normalization

Usage:

import torch

# Load pretrained weights
checkpoint = torch.load("pretrained/best_model.pt", map_location="cpu")
model.load_state_dict(checkpoint)

embeddings/ β€” Precomputed Cell Embeddings

spatia_embeddings.npy contains cell embeddings extracted from the pretrained SPATIA model on the MIST atlas. These embeddings fuse morphological and transcriptomic information and can be used directly for downstream tasks without requiring a GPU.

Usage:

import numpy as np

embeddings = np.load("embeddings/spatia_embeddings.npy")
print(embeddings.shape)  # (num_cells, embedding_dim)

notebooks/ β€” Tutorial Notebooks

Notebook Description
prediction_tasks_showcase.ipynb Reproduces clustering (Leiden) and cell-type annotation benchmarks from Tables 2 & 4. Runs on frozen embeddings β€” no GPU needed.
spatia_generation_inference.ipynb Loads the generation model checkpoint, runs ODE-based flow matching to generate perturbation cell images, and evaluates with FID, SSIM, and morphology metrics.

Run locally:

pip install jupyter
jupyter notebook notebooks/prediction_tasks_showcase.ipynb

results/ β€” Evaluation Results

Precomputed benchmark results from the paper, ready for comparison.

File Content
table2_summary.csv Cell clustering (ARI, NMI) across Xenium & CosMx platforms for 6 models (PCA, scGPT, scFoundation, Nicheformer, UCE, SPATIA)
table4_clustering_summary.csv scRNA-seq clustering benchmarks (ARI, NMI) for PCA, scGPT, Geneformer

.gitattributes β€” Git LFS Configuration

Configures Git Large File Storage for binary files (.pt, .npy, .h5, .ckpt, etc.). Required for cloning β€” install Git LFS before pulling:

git lfs install
git clone https://huggingface.co/mims-harvard/SPATIA

Or download individual files via the HuggingFace Hub:

from huggingface_hub import hf_hub_download

# Download pretrained weights
model_path = hf_hub_download(repo_id="mims-harvard/SPATIA", filename="pretrained/best_model.pt")

# Download embeddings
emb_path = hf_hub_download(repo_id="mims-harvard/SPATIA", filename="embeddings/spatia_embeddings.npy")

Quick Start

from huggingface_hub import snapshot_download

# Download everything
snapshot_download(repo_id="mims-harvard/SPATIA", local_dir="./SPATIA")

# Or download only what you need
from huggingface_hub import hf_hub_download

# For prediction tasks (no GPU needed):
hf_hub_download(repo_id="mims-harvard/SPATIA", filename="embeddings/spatia_embeddings.npy", local_dir="./SPATIA")
hf_hub_download(repo_id="mims-harvard/SPATIA", filename="notebooks/prediction_tasks_showcase.ipynb", local_dir="./SPATIA")

Related Resources


Citation

@article{kong2026spatia,
  title={Spatia: Multimodal model for prediction and generation of spatial cell phenotypes},
  author={Kong, Zhenglun and Qiu, Mufan and Boesen, John and Lin, Xiang and Yun, Sukwon and Chen, Tianlong and Kellis, Manolis and Zitnik, Marinka},
  booktitle = {Proceedings of the 43th International Conference on Machine Learning},
  year={2026}
}

Contact

Zitnik Lab, Harvard Medical School