Paper2MCP v2 Verified Deliverable

Mapping cell-type-specific spatial gene programs uncovers tissue architecture and microenvironment organization

期刊:Nature Communications (2026-10-14) · DOI:10.1038/s41467-026-78447-3 · 开源许可:MIT (allowed)

上游仓库:https://github.com/YangLabHKUST/MacSGP @ 378224c4945f

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

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

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

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

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

prepare_macsgp_inputs MCP Verified ✓

Prepare MacSGP inputs: per-cell-type marker gene selection, cell-type basis from a scRNA-seq reference, library sizes and a spatial kNN graph.

Selftest Summary: Prepared 400 spots x 90 marker genes, basis for 3 cell types (Astro, Neuron, Oligo), kNN graph with 6.72 neighbours/spot.
Metrics: {"n_spots": 400, "n_genes_selected": 90, "celltypes": ["Astro", "Neuron", "Oligo"], "n_directed_edges": 2688, "avg_neighbors_per_spot": 6.72, "graph_backend": "scipy cKDTree kNN (symmetrised, self-loop included)"}
deconvolve_celltypes MCP Verified ✓

MacSGP stage 1: graph-neural-network cell-type deconvolution giving per-spot proportions, spot effects and gene platform effects.

Selftest Summary: Deconvolved 400 spots into 3 cell types; mean proportions: Astro=0.42, Neuron=0.39, Oligo=0.19.
Metrics: {"n_spots": 400, "celltypes": ["Astro", "Neuron", "Oligo"], "mean_proportion": {"Astro": 0.4212070405483246, "Neuron": 0.38687801361083984, "Oligo": 0.19191494584083557}, "dominant_celltype_spots": {"Neuron": 200, "Astro": 200}, "training_steps": 150, "seed": 1}
map_spatial_gene_programs MCP Verified ✓

MacSGP stage 2: cell-type-specific spatial gene programs as low-rank factor (spatial pattern) x loading (gene weights), with top genes and Moran I of each factor.

Selftest Summary: Fitted 1 SGP(s) for 3 cell types over 400 spots x 90 genes; loss -6340.1 -> -6410.4.
Metrics: {"n_spots": 400, "n_genes": 90, "celltypes": ["Astro", "Neuron", "Oligo"], "n_sgps": 1, "loss_first": -6340.05322265625, "loss_last": -6410.4453125, "per_celltype": {"Astro": {"n_spots_present": 222, "factor_std_SGP1": 0.7609557390886513, "program_detected_SGP1": true, "morans_I_SGP1": 1.0160510011784174, "loading_abs_max_SGP1": 0.3029933571815491, "top_genes_SGP1": ["g049", "g050", "g041", "g053", "g043", "g054", "g044", "g036", "g059", "g030"]}, "Neuron": {"n_spots_present": 258, "factor_std_SGP1": 0.5566451006177915, "program_detected_SGP1": true, "morans_I_SGP1": 0.9974273063869572, "loading_abs_max_SGP1": 0.434862345457077, "top_genes_SGP1": ["g019", "g020", "g022", "g012", "g016", "g010", "g011", "g021", "g018", "g023"]}, "Oligo": {"n_spots_present": 135, "factor_std_SGP1": 0.001979690592546698, "program_detected_SGP1": false, "morans_I_SGP1": null, "loading_abs_max_SGP1": 0.006628225091844797, "top_genes_SGP1": ["g072", "g084", "g076", "g062", "g066", "g064", "g079", "g060", "g061", "g083"]}}, "sign_note": "factor and loading signs are arbitrary; interpret their product"}
benchmark_sgp_recovery MCP Verified ✓

Run the whole MacSGP pipeline on a benchmark with planted spatial gene programs and score recovery against the truth (factor |r|, planted-gene recall, proportion r, negative control).

Selftest Summary: Planted-SGP benchmark: 2 cell types with a planted program, mean |r| of recovered vs planted factor = 0.98.
Metrics: {"mean_abs_factor_r": 0.982639140827632, "per_celltype": [{"celltype": "Neuron", "proportion_pearson_r": 0.9613075732565405, "planted_program": true, "factor_signed_r": -0.9812578211722088, "factor_abs_r": 0.9812578211722088, "n_planted_genes": 15, "planted_gene_recall_at_k": 1.0, "loading_abs_mean": 0.19745159149169922}, {"celltype": "Astro", "proportion_pearson_r": 0.9523740706420719, "planted_program": true, "factor_signed_r": -0.9840204604830551, "factor_abs_r": 0.9840204604830551, "n_planted_genes": 15, "planted_gene_recall_at_k": 0.8, "loading_abs_mean": 0.16946159303188324}, {"celltype": "Oligo", "proportion_pearson_r": 0.591483936786463, "planted_program": false, "factor_signed_r": null, "factor_abs_r": null, "n_planted_genes": 0, "planted_gene_recall_at_k": null, "loading_abs_mean": 0.002759132534265518}]}

三、实测复现结果图展示

01_sgp_factor_recovery.png
02_deconvolution_proportions.png
03_sgp_loading.png