spatial-microenvironment-subset
БесплатноБез исполняемых скриптовНе проверенLoad when extracting a niche / microenvironment subset around a center cell-type by spatial radius from a labelled spatial AnnData, producing a smaller…
от mdbabumiamssm★ 36 звёзд на GitHubОб этом скилле
spatial-microenvironment-subset
When to use
The user has a labelled spatial AnnData (cell-type or domain labels in
obs[--center-key]) and wants to extract a niche around a chosen cell
population — i.e., the center cells PLUS every spot / cell within a
spatial radius of any center. Output is a downstream-ready AnnData
restricted to that microenvironment.
Single backend (radius-based KD-tree neighbourhood). Two radius modes:
--radius-microns (with --microns-per-coordinate-unit if your
coords aren't in microns) OR --radius-native (in the AnnData's
native coordinate units). Exactly one is required.
For global tissue-domain detection use spatial-domains. For
cross-condition niche comparison use spatial-condition.
Inputs & Outputs
| Input | Format | Required |
|---|---|---|
| Labelled spatial AnnData | .h5ad with obs[--center-key] and obsm["spatial"] |
yes (unless --demo) |
| Center label values | comma-separated string (--center-values) |
yes |
| Radius | one of --radius-microns OR --radius-native |
yes (mutually exclusive) |
| Optional target restriction | --target-key + --target-values |
optional |
| Output | Path | Notes |
|---|---|---|
| Subset AnnData | processed.h5ad |
rows = centers + within-radius neighbours; adds obs["microenv_is_center"], obs["microenv_role"], obs["microenv_within_radius"], obs["microenv_nearest_center"], obs["microenv_distance_native"], plus obs["microenv_distance_microns"] only when --microns-per-coordinate-unit was supplied (_lib/microenvironment.py:341/346) |
| Selected observations | tables/selected_observations.csv |
per-row role (center / neighbour) + distance |
| Centers retained | tables/center_observations.csv |
always |
| Label composition | tables/label_composition.csv |
label-prevalence before vs after subset |
| Run summary | tables/selection_summary.csv |
always |
| Figure | figures/microenvironment_selection.png |
spatial layout with selection overlay |
| Report | report.md + result.json |
always |
Flow
- Load AnnData (
--input) or build a demo. - Validate radius flags (
parser.erroron≤ 0); resolve--microns-per-coordinate-unitif needed. - Resolve center mask: rows where
obs[--center-key] ∈ --center-values(comma-split). - Build a KD-tree on
obsm["spatial"]; query each center for neighbours within radius. - Optionally restrict neighbour pool to
obs[--target-key] ∈ --target-values. - Build the subset (centers + qualified neighbours; optionally drop centers via
--exclude-centers). - Save subset AnnData with role + distance columns; emit composition / summary tables; render selection figure.
Gotchas
- All input + radius validation goes through
parser.error(exit code 2).spatial_microenvironment_subset.py:403for missing--input;:405for missing path;:407for non-positive--microns-per-coordinate-unit;:409for non-positive--radius-microns;:411for non-positive--radius-native. Wrappers expectingValueErrorneed to catch exit-2. --radius-micronsand--radius-nativeare mutually exclusive AND required.argparse.add_mutually_exclusive_group(required=True)enforces it before the manual checks at:409/:411. Using neither hits a differentparser.error(argparse-generated). Mixing the two raises argparse's standard "not allowed with" error.--microns-per-coordinate-unitis needed when coords aren't in microns. Visium typically already stores spatial coords in pixels; pass the platform-specific scale (e.g.,0.65µm / pixel for high-res Visium) to make--radius-micronsmeaningful. Without it, the radius is treated as if coords were already in microns.--center-valuesis required and--center-keyis auto-resolvable.--center-valuesalways required (no default);--center-keydefaults to None and the script auto-picks a sensible labelled obs column. For ambiguous AnnDatas, pass both explicitly.--exclude-centersdrops the center cells from the output. Useful when you want to characterise the niche around a population without the population itself biasing downstream stats. By default centers ARE retained —spatial_microenvironment_subset.py:461invokes the helper withinclude_centers=not args.exclude_centers;result.json["params"]["exclude_centers"]records the raw flag at:488.- No raise for empty selection. If the radius is too small or
--center-valuesmatches no rows, the script proceeds with an empty / center-only AnnData;tables/selection_summary.csvandresult.json["n_selected_observations"](line 195) record0. Always check before chaining downstream.
Key CLI
# Demo (synthetic spatial with cell-type labels)
python omicsclaw.py run spatial-microenvironment-subset --demo --output /tmp/spatial_microenv_demo
# T-cell niche, 50 µm radius (Visium with 0.65 µm/pixel scale)
python omicsclaw.py run spatial-microenvironment-subset \
--input annotated.h5ad
Установить spatial-microenvironment-subset в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл spatial-microenvironment-subset?
Load when extracting a niche / microenvironment subset around a center cell-type by spatial radius from a labelled spatial AnnData, producing a smaller AnnData of centers + their within-radius neighbours. Skip when running global tissue-domain detection (use spatial-domains) or for cross-condition comparison (use spatial-condition).
Как установить скилл spatial-microenvironment-subset?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл spatial-microenvironment-subset запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic