Paper2MCP v2 Verified Deliverable

SpatialFormer: universal spatial representation learning from subcellular molecular to multicellular landscapes.

期刊:Nature Computational Science (2026-07-30) · DOI:10.1038/s43588-026-01016-7 · 开源许可:MIT (allowed)

上游仓库:https://github.com/TerminatorJ/Spatialformer @ b3f57ea858ac

Pytest: passed MCP Stdio Selftest: passed Relocated Fresh Install: passed

一、一键安装与 MCP 接入(本地 / 远程统一接口)

# 1. 解压并自动构建隔离环境 + 运行真实数据自测
unzip spatialformer-mcp.zip && cd spatialformer-mcp
bash install.sh
.venv/bin/python selftest.py

# 2. 接入 Claude Code / Antigravity / Cursor (Stdio MCP)
claude mcp add spatialformer -- "$PWD/.venv/bin/python" "$PWD/server.py"

# 3. 或启动远程 Streamable HTTP MCP 服务端供团队/网页直接调用
.venv/bin/python server.py --transport http --host 0.0.0.0 --port 8000

二、已验证科学工具清单(5 个工具)

tokenize_spatial_cells MCP Verified ✓

Tokenize single-cell or paired-cell spatial transcriptomics AnnData into ranked SpatialFormer gene token batches.

Selftest Summary: Tokenized 120 single samples from 120 cells (77/77 genes matched vocab; mean seq len=22.49).
Metrics: {"n_cells": 120, "n_samples": 120, "vocab_size": 6065, "matched_genes": 77, "mean_seq_len": 22.49, "max_seq_len": 37, "n_batches": 8, "mode": "single"}
extract_spatial_embeddings MCP Verified ✓

Extract single-cell SpatialFormer embeddings (X_SpaF), UMAP visualization, and cell-type/batch integration metrics.

Selftest Summary: Extracted SpatialFormer (gene) embeddings of shape (120, 32) for 120 cells (cell-type silhouette=-0.0264) (batch silhouette=0.087).
Metrics: {"n_cells": 120, "embed_dim": 32, "method": "gene", "celltype_silhouette": -0.0264, "batch_silhouette": 0.087}
annotate_cell_types MCP Verified ✓

Train and evaluate SpatialFormer's downstream SimpleMLP cell-type classifier on X_SpaF embeddings.

Selftest Summary: Annotated 30 held-out cells across 4 cell types (accuracy=0.8333, weighted F1=0.8289).
Metrics: {"n_train": 90, "n_test": 30, "n_classes": 4, "test_accuracy": 0.8333, "weighted_precision": 0.828, "weighted_recall": 0.8333, "weighted_f1": 0.8289, "final_train_loss": 0.3304}
predict_cell_colocalization MCP Verified ✓

Predict pairwise cell-cell spatial colocalization probabilities and pair embeddings using SpatialFormer.

Selftest Summary: Predicted spatial colocalization for 40 cell pairs (mean P(colocalized)=0.5369, ROC-AUC=0.6525).
Metrics: {"n_pairs": 40, "mean_pos_prob": 0.5369, "predicted_positive_fraction": 0.625, "reverse_check": false, "accuracy": 0.575, "roc_auc": 0.6525}
compute_subcellular_gene_graph MCP Verified ✓

Construct subcellular spatial transcript KD-tree/Louvain graphs and gene-gene co-occurrence matrices with optional coordinate perturbation.

Selftest Summary: Built subcellular spatial graph for cell TILD117LF_aaaaigjn-1 (439 transcripts, 61 reference genes) yielding 251 co-occurring pairs.
Metrics: {"cell_id": "TILD117LF_aaaaigjn-1", "n_transcripts": 439, "n_unique_genes": 61, "n_cooccurring_pairs": 251, "mean_gene_degree": 8.23, "perturbation_jaccard": 0.9269}

三、实测复现结果图展示

spatialformer_annotation_and_colocalization.png
spatialformer_umap_embeddings.png
subcellular_gene_cooccurrence.png