sc-gene-programs
БесплатноБез исполняемых скриптовНе проверенLoad when extracting gene programs (NMF / cNMF factorisation) and per-cell program usage scores from a non-negative scRNA AnnData. Skip when ranking marker…
от mdbabumiamssm★ 36 звёзд на GitHubОб этом скилле
sc-gene-programs
When to use
The user has a non-negative scRNA AnnData (raw counts or log-normalised expression) and wants to decompose it into K gene programs (latent factors) plus a per-cell usage matrix. Two methods:
cnmf(default) — consensus NMF (multiple runs + clustering of factors) for stable programs. Auto-falls back tonmfif thecnmfpackage isn't installed.nmf— sklearn NMF, single run.
Output: tables/program_usage.csv (cells × K), tables/program_weights.csv
(genes × K), tables/top_program_genes.csv (top-N genes per program).
For per-cluster marker discovery use sc-markers; for TF → target
regulons use sc-grn; for per-cell pathway scores against curated
gene sets use sc-pathway-scoring.
Inputs & Outputs
| Input | Format | Required |
|---|---|---|
| Non-negative AnnData | .h5ad (raw counts in layers["counts"] or log-normalised in .X) |
yes (unless --demo) |
| Output | Path | Notes |
|---|---|---|
| Annotated AnnData | processed.h5ad |
adds obsm["X_gene_programs"] (cells × K usage matrix; sc_gene_programs.py:469). The program_usage name only applies to the tables/program_usage.csv file, NOT to the obsm key. |
| Per-cell usage | tables/program_usage.csv |
cells × K matrix |
| Gene weights | tables/program_weights.csv |
genes × K matrix |
| Top genes | tables/top_program_genes.csv |
top---top-genes per program |
| Figures | figures/mean_program_usage.png, figures/program_correlation.png |
always |
| Report | report.md + result.json |
always |
Flow
- Auto-fallback check: try
import cnmf; if it fails, silently switch--methodtonmf. - Load AnnData (
--input) or build a demo. - Preflight: pick source matrix per
--layer(auto-preferlayers["counts"]for cnmf when--layeris unset); reject negative values; warn ifn_genes < 50or running NMF on raw counts without--layer counts. - Run cNMF (consensus NMF with
--n-iterruns) or sklearn NMF (single run,--seed). - Build top-genes-per-program table; compute per-program correlation matrix.
- Detect degenerate output → record diagnostics; do NOT raise.
- Save tables, figures,
processed.h5ad,report.md,result.json.
Gotchas
cnmfsilently auto-falls back tonmfif cnmf is not installed.sc_gene_programs.py:407-409catchesImportErrorfromimport cnmf, logs a warning, setsargs.method = "nmf"(sosummary["method"]at:527already reflects the post-fallback value).summary["backend"]at:528records the same. Inspect either before quoting "we used cNMF".- Negative values reject the run.
sc_gene_programs.py:132raisesSystemExit("NMF/cNMF requires non-negative input, but the data matrix contains negative values. This usually means the data has been z-score scaled. ...")with a multi-option fix message. Most common cause: feeding asc.pp.scale-d AnnData where.Xis mean-centred. Pass--layer countsor re-runsc-preprocessingwithout scaling. cnmfauto-preferslayers["counts"]; nmf doesn't.sc_gene_programs.py:111-112switches tolayers["counts"]for cnmf if--layeris unset and the layer exists. nmf without--layeruses.Xdirectly. If your raw counts live elsewhere, pass--layer <name>explicitly to avoid silent fallback to.X.- Missing
--layervalue alsoSystemExits.sc_gene_programs.py:118raisesSystemExit("Layer '<name>' not found in adata.layers. Available layers: <list>. ...")when an explicit--layerdoesn't resolve. Wrappers expectingValueErrorneed to catchSystemExit. --inputmandatory unless--demo.sc_gene_programs.py:418raisesSystemExit("Provide --input or use --demo").- Degenerate output is a soft fail. When the factorisation collapses to fewer effective programs than
--n-programs,sc_gene_programs.py:533-534recordssummary["degenerate_output"] = Trueand listsdegenerate_issues— but the script returns 0. Always inspectresult.json["n_programs"](line 529, the effective count) before chaining downstream.
Key CLI
# Demo (cNMF on synthetic data, falls back to NMF if cnmf missing)
python omicsclaw.py run sc-gene-programs --demo --output /tmp/sc_gp_demo
# cNMF with 8 programs on raw counts
python omicsclaw.py run sc-gene-programs \
--input clustered.h5ad --output results/ \
--method cnmf --n-programs 8 --n-iter 200 --layer counts
# NMF on log-normalised .X (faster, less stable)
python omicsclaw.py run sc-gene-programs \
--input normalized.h5ad --output results/ \
--method nmf --n-programs 10 --top-genes 50
See also
references/parameters.md— every CLI flag, NMF / cNMF tunablesreferences/methodology.md— when consensus NMF wins; layer-selection guidereferences/output_contract.md—obsm["X_gene_programs"]/tables/program_*.csvschemas- Adjacent skills:
sc-preprocessing(upstream — produces a non-negative.Xorlayers["counts"]),sc-markers(parallel — clus
Установить sc-gene-programs в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл sc-gene-programs?
Load when extracting gene programs (NMF / cNMF factorisation) and per-cell program usage scores from a non-negative scRNA AnnData. Skip when ranking marker genes per cluster (use sc-markers) or for inferring TF → target regulons (use sc-grn).
Как установить скилл sc-gene-programs?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sc-gene-programs запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic