spatial-condition
БесплатноБез исполняемых скриптовНе проверенLoad when comparing two or more experimental conditions (treatment vs control) on a multi-sample preprocessed spatial AnnData via PyDESeq2 pseudobulk or…
от mdbabumiamssm★ 36 звёзд на GitHubОб этом скилле
spatial-condition
When to use
The user has a preprocessed multi-sample spatial AnnData with
obs[condition_key] (e.g. treatment/control), obs[sample_key]
(biological replicate id), and a cluster column (default leiden),
and wants per-cluster differential expression between conditions.
Two backends:
pydeseq2(default) — pseudobulk per(sample, cluster), PyDESeq2 NB/GLM. Requires raw counts inlayers["counts"](oradata.rawas fallback). Honours replicate structure correctly.wilcoxon— spot-level Wilcoxon rank-sum (scanpy.tl.rank_genes_groups). Cheap fallback when no replicate structure exists, but ignores pseudoreplication.
For per-cluster DE within a single condition use spatial-de. For
spatially variable genes use spatial-genes.
Inputs & Outputs
| Input | Format | Required |
|---|---|---|
| Preprocessed multi-sample spatial AnnData | .h5ad with obsm["spatial"], obs[condition_key], obs[sample_key], obs[cluster_key] (default leiden) |
yes (unless --demo) |
| Raw counts | adata.layers["counts"] (preferred) or adata.raw (fallback) |
yes for pydeseq2 |
| Output | Path | Notes |
|---|---|---|
| Annotated AnnData | processed.h5ad |
obs[condition_key] + obs[cluster_key] cast to Categorical (obs[sample_key] is read but not cast) |
| Pseudobulk DE | tables/pseudobulk_de.csv |
gene × cluster × contrast (long-form) |
| Per-cluster summary | tables/per_cluster_summary.csv |
up/down counts per cluster |
| Skipped contrasts | tables/skipped_contrasts.csv |
clusters that failed replicate-count check |
| Run summary | tables/condition_run_summary.csv |
params used per-method |
| Report | report.md + result.json |
always |
Flow
- Load AnnData (
--input) or build a 12-sample demo (--demo). - Validate
obs[condition_key]+obs[sample_key]exist (_lib/condition.py:91-95raisesValueErrorif missing); castcondition_key+cluster_keyto Categorical (spatial_condition.py:84-86). - For
pydeseq2: aggregate raw counts per(sample, cluster)pseudobulk; requirelayers["counts"]or fall back toadata.raw. - Per cluster: skip the contrast if either condition has <
--min-samples-per-conditionsamples; log totables/skipped_contrasts.csv. - Fit DE model per surviving (cluster, contrast); apply
--fdr-threshold+--log2fc-threshold. - Compute UMAP / spatial summaries; render plots; save tables and
processed.h5ad.
Gotchas
pydeseq2falls back silently when raw counts are missing._lib/condition.py:60-86(_get_counts_matrix) prefersadata.layers["counts"], falls back toadata.raw, then toadata.X— each fallback only logs a warning. Ifadata.Xis log-normalised, pseudobulk sums are statistically invalid (log(a)+log(b) != log(a+b)). Always preprocess solayers["counts"]is populated.wilcoxonskips this codepath entirely — it normalises internally.- Single-condition / no-replicate clusters are silently skipped.
tables/skipped_contrasts.csvlists clusters with <--min-samples-per-conditionsamples per condition. Always inspect that file — clusters not inpseudobulk_de.csvwere dropped, not "no DE genes". --condition-keyand--sample-keymust be different columns.spatial_condition.py:1024-1025rejects viaparser.errorwhen they match. A common mistake is usingconditionfor both — pseudobulk needs the sample axis distinct from the condition axis.obs[condition_key]andobs[cluster_key]cast to Categorical in place.spatial_condition.py:84-86overwrites both columns withpd.Categorical(...). Order is sorted-unique unless--reference-conditionpins the reference level — non-alphabetical custom orderings on input are lost.obs[sample_key]is NOT cast.obsm["X_pca"]is recomputed inside the script when needed.spatial_condition.py:1170writesobsm["X_pca"] = adata_hvg.obsm["X_pca"]for the UMAP / PCA reporting view; this is a diagnostic recompute, not a published embedding.- PyDESeq2 needs ≥ 2 samples per condition.
--min-samples-per-conditiondefaults to 2. If your study has one slice per condition, either pool spots into pseudo-replicates upstream or fall back to--method wilcoxon.
Key CLI
# Demo (synthetic 12-sample data)
python omicsclaw.py run spatial-condition --demo --output /tmp/cond_demo
# PyDESeq2 pseudobulk (default)
python omicsclaw.py run spatial-condition \
--input preprocessed.h5ad --output results/ \
--method pydeseq2 \
--condition-key treatment --sample-key sample_id --cluster-key leiden \
--reference-condition control \
--min-samples-per-condition 3 --fdr-threshold 0.05 --log2fc-threshold 1.0
# Wilcoxon spot-level (cheap fallback when no replicates)
python omicsclaw.py run spatial-condition \
--input preprocessed.h5ad --output results/ \
--method wilcoxon --condition-key treatment --sample-key sample_id \
--wilcoxon-alternative two-sided
See also
- `references/
Установить spatial-condition в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл spatial-condition?
Load when comparing two or more experimental conditions (treatment vs control) on a multi-sample preprocessed spatial AnnData via PyDESeq2 pseudobulk or Wilcoxon DE — needs `obs[condition_key]`, `obs[sample_key]`, and cluster labels. Skip when running per-cluster DE on one condition (use `spatial-de`) or comparing two slices without replicates.
Как установить скилл spatial-condition?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл spatial-condition запускает скрипты?
Нет, скилл состоит только из инструкций (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