Paper2MCP v2 Verified Deliverable

Interpretable AI model reveals spatial codes of cell recruitment in tissues.

期刊:Nature Biomedical Engineering (2026-10-13) · DOI:10.1038/s41551-026-01804-6 · 开源许可:MIT (allowed)

上游仓库:https://github.com/yaober/SPACER @ d7673b8df8f7

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

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

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

# 2. 接入 Claude Code / Antigravity / Cursor (Stdio MCP)
claude mcp add spacer -- "$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 个工具)

prepare_spatial_bags MCP Verified ✓

Construct cell-centered multi-instance learning (MIL) spatial neighborhood bags from an .h5ad spatial transcriptomics dataset or CSV manifest using SPACER BagsDataset and preprocess_data.

Selftest Summary: Constructed 132 MIL batches (264 bags: 132 positive, 132 negative) for engage_cell='tcell' (T) with 140 selected genes.
Metrics: {"n_batches": 132, "n_bags": 264, "n_positive_bags": 132, "n_negative_bags": 132, "n_genes_selected": 140, "mean_instances_per_bag": 36.34, "engage_cell": "tcell", "mapped_column": "T"}
train_spacer_single MCP Verified ✓

Train the interpretable SPACER MIL model in single-dataset mode (train.py) to learn spatial distance decay, gene weighting, and per-gene SPACER recruitment scores.

Selftest Summary: Trained SPACER MIL model (positive, softmax) for 5 epochs: best Val Loss=0.0730, final Val AUROC=0.9975. Top genes: ['TAP2', 'HLA-C', 'IFI6', 'HLA-B', 'HLA-A'].
Metrics: {"num_epochs": 5, "final_train_loss": 0.08599, "final_val_loss": 0.13131, "best_val_loss": 0.07295, "final_val_auroc": 0.9975, "learned_a": -1.4163, "learned_b": 1.7962, "learned_alpha": 2.611, "learned_beta": -4.2838, "top_5_genes": ["TAP2", "HLA-C", "IFI6", "HLA-B", "HLA-A"]}
train_spacer_joint MCP Verified ✓

Train SPACER across multiple spatial transcriptomics cohorts in federated joint mode (FedAvg + FedProx) sharing global SPACER gene scores while keeping spatial/expression scalars local.

Selftest Summary: Completed joint SPACER training across 2 clients for 3 communication rounds (fedprox_mu=0.01). Top global genes: ['TAP2', 'HLA-B', 'HLA-A', 'HLA-C', 'IFI6'].
Metrics: {"n_clients": 2, "comm_rounds": 3, "local_epochs": 1, "fedprox_mu": 0.01, "top_5_global_genes": ["TAP2", "HLA-B", "HLA-A", "HLA-C", "IFI6"], "max_spacer_score": 0.9917}
predict_spatial_recruitment MCP Verified ✓

Score tumor cell neighborhoods in a spatial .h5ad slide using a trained SPACER MIL checkpoint to predict cell engagement probability and evaluate AUROC if ground-truth labels exist.

Selftest Summary: Scored 241/280 cells (mean prob=0.5611, AUROC=0.9868).
Metrics: {"n_cells_total": 280, "n_cells_scored": 241, "mean_predicted_prob": 0.5611, "median_predicted_prob": 0.9394, "auroc": 0.9868, "accuracy": 0.9129}
interpret_spacer_codes MCP Verified ✓

Extract and visualize interpretable spatial and molecular recruitment codes (per-gene SPACER scores and spatial distance decay kernel) from a trained SPACER MIL checkpoint.

Selftest Summary: Extracted SPACER spatial & molecular codes across 120 genes: half-decay distance=4.23 (a=-1.81, b=1.22). Top genes: ['TAP2', 'IFI6', 'HLA-C', 'ANXA9', 'CHD5'].
Metrics: {"a_distance_decay": -1.80777, "effective_decay_rate_exp_a": 0.16402, "half_decay_distance": 4.226, "b_expression_sharpness": 1.21836, "alpha_scale": 3.05418, "beta_bias": -4.61538, "gene_weighting": "softmax", "n_genes_scored": 120, "top_5_genes": ["TAP2", "IFI6", "HLA-C", "ANXA9", "CHD5"], "top_gene_score": 0.9802}

三、实测复现结果图展示

fig1_training_convergence.png
fig2_spatial_recruitment_codes.png
fig3_spatial_prediction_map.png