spatial-integrate
БесплатноБез исполняемых скриптовНе проверенLoad when removing batch effects across multiple spatial samples on a multi-batch spatial AnnData via Harmony, BBKNN, or Scanorama before downstream analysis…
от mdbabumiamssm★ 36 звёзд на GitHubОб этом скилле
spatial-integrate
When to use
The user has a multi-sample spatial AnnData (sample / donor labels in
obs["batch"] or another --batch-key) and wants batch effects in
the gene-expression embedding removed before downstream domain /
cluster / DE analysis. Three methods:
harmony(default) — soft k-means in PCA space; producesobsm["X_pca_harmony"]. Tunable via--harmony-theta/--harmony-lambda/--harmony-max-iter. Requiresharmonypy.bbknn— batch-balanced neighbour graph; produces a fusedobsp["distances"]ready for UMAP / clustering. Tunable via--bbknn-neighbors-within-batch/--bbknn-n-pcs/--bbknn-trim. Requiresbbknn.scanorama— corrected expression matrix inobsm["X_scanorama"]. Tunable via--scanorama-knn/--scanorama-sigma/--scanorama-alpha/--scanorama-batch-size. Requiresscanorama.
For physical slice-coordinate alignment use spatial-register. For
single-batch data skip this skill and go to spatial-domains /
spatial-de directly.
Inputs & Outputs
| Input | Format | Required |
|---|---|---|
| Multi-batch AnnData | .h5ad with obs[--batch-key] (default batch) and obsm["X_pca"] |
yes (unless --demo) |
| Output | Path | Notes |
|---|---|---|
| Integrated AnnData | processed.h5ad |
adds obsm["X_pca_harmony"] (harmony) / obsm["X_scanorama"] (scanorama) / obsp["distances"] rebuild (bbknn) |
| Integration metrics | tables/integration_metrics.csv |
always |
| Batch sizes | tables/batch_sizes.csv |
always |
| Observations | tables/integration_observations.csv |
best-effort (when batch metric flags present) |
| Report | report.md + result.json |
always |
Flow
- Load AnnData (
--input) or build a 3-batch demo via the bundledspatial-preprocess --demo(spatial_integrate.py:803-815chains via subprocess). parser.errorvalidates per-method numeric ranges (--harmony-theta≥ 0;--harmony-lambda> 0 or -1;--harmony-max-iter≥ 1;--bbknn-*≥ 1;--scanorama-*per-flag bounds).- Dispatch to method:
harmony→ writeobsm["X_pca_harmony"].bbknn→ rebuildobsp["distances"]+obsp["connectivities"].scanorama→ writeobsm["X_scanorama"].
- Compute integration metrics (e.g., LISI / silhouette scores when supported).
- Save
processed.h5ad, tables, figures,report.md,result.json.
Gotchas
- All numeric flag validation goes through
parser.error(exit code 2).spatial_integrate.py:837-857covers the harmony / bbknn / scanorama numeric ranges. Wrappers expectingValueErrorneed to catch exit-2 separately. - Demo chains through
spatial-preprocessvia subprocess.spatial_integrate.py:803raisesFileNotFoundError(f"OmicsClaw runner not found at {main_runner}")whenomicsclaw.pyis missing;:814raisesRuntimeError("spatial-preprocess --demo failed (exit ...)")when the chained run fails;:819raisesFileNotFoundError(f"Expected {processed}")when the demo output isn't where expected. Real runs skip this chain. - Each method writes a DIFFERENT
obsm/obspkey. harmony →obsm["X_pca_harmony"], scanorama →obsm["X_scanorama"], bbknn → modifiesobsp["distances"]/obsp["connectivities"]in place (no newobsmkey). Downstream skills that consume the integrated embedding via--use-repmust branch on method. obsm["X_pca"]is required as input for harmony / bbknn (used as starting embedding). If the input AnnData skippedspatial-preprocess, harmony / bbknn fail at runtime. Runspatial-preprocessfirst, or check forX_pcapresence.--harmony-lambdaaccepts-1to enable auto-lambda estimation.spatial_integrate.py:839documents this special case in the flag check. Other harmony numerics must be strictly positive.- UMAP snapshot key validation.
spatial_integrate.py:67raisesKeyError(f"UMAP snapshot '{umap_key}' not found in adata.obsm")when a "before" UMAP comparison is requested but the key is missing. Affects the integration-metrics figure only.
Key CLI
# Demo (synthetic 3-batch chained from spatial-preprocess --demo)
python omicsclaw.py run spatial-integrate --demo --output /tmp/spatial_int_demo
# Default Harmony on real multi-sample data
python omicsclaw.py run spatial-integrate \
--input multi_sample.h5ad --output results/ \
--method harmony --batch-key sample
# BBKNN with custom neighbour budget
python omicsclaw.py run spatial-integrate \
--input multi_sample.h5ad --output results/ \
--method bbknn --batch-key donor \
--bbknn-neighbors-within-batch 5 --bbknn-n-pcs 30
# Scanorama with strong correction
python omicsclaw.py run spatial-integrate \
--input multi_sample.h5ad --output results/ \
--method scanorama --batch-key library_id \
--scanorama-sigma 30 --scanorama-alpha 0.05
See also
references/parameters.md— every CLI flag, per-method tunablesreferences/methodology.md— when Harmony / BBKNN / Scanorama wins;
Установить spatial-integrate в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл spatial-integrate?
Load when removing batch effects across multiple spatial samples on a multi-batch spatial AnnData via Harmony, BBKNN, or Scanorama before downstream analysis. Skip when aligning physical slice coordinates (use spatial-register) or for single-batch data (no integration needed — go straight to spatial-domains).
Как установить скилл spatial-integrate?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл spatial-integrate запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic