bulkrna-batch-correcti…
Load when correcting batch effects in bulk expression using R sva ComBat or the legacy Python parametric approximation. Skip…
Load when extracting gene programs (NMF / cNMF factorisation) and per-cell program usage
$ npx -y skills add tiangzlab/omicsclaw --skill sc-gene-programs --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/sc-gene-programsContext preview
The summary Claude sees to decide when to auto-load this skill.
Load when extracting gene programs (NMF / cNMF factorisation) and per-cell program usage
name: sc-gene-programs description: 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); inferring TF → target regulons (use sc-grn). tags: - singlecell - scrna - gene-programs - nmf - cnmf - factorisation
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:
factors) for stable programs. Auto-falls back to `nmf` if the `cnmf` package isn't installed.
Output: `tables/program_usage.csv` (cells × K), `tables/program_weights.csv` (programs × genes), `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`.
Use `load_skill` from the notebook SDK; write returned objects with `write_output`. This runnable example is also in `examples/example_step.py`. The CLI remains available for standalone reports and galleries.
# Extract six NMF programs from the log-normalized PBMC68k snapshot.
# Reads pbmc68k_reduced.
# Calls sc-gene-programs: find_programs, top_program_genes, usage_figure.
from skills._sdk.notebook import load_demo, load_skill, write_output
programs = load_skill('sc-gene-programs')
adata = load_demo('pbmc68k_reduced').raw.to_adata()
result = programs.find_programs(adata, method='nmf')
top = programs.top_program_genes(result, n=10)
write_output(result, 'intermediate/programs.h5ad')
write_output(top, 'tables/top_program_genes.csv')
write_output(programs.usage_figure(result), 'figures/program_usage.png')
assert result.obsm['X_gene_programs'].shape == (adata.n_obs, 6)
assert (result.obsm['X_gene_programs'] >= 0).all()
assert top['program'].nunique() == 6
assert set(top.gene).issubset(adata.var_names)Input is a non-negative AnnData expression matrix; `layer` selects another matrix. PCA and neighbors are not required. `find_programs` returns a copy with `obsm["X_gene_programs"]` and tables exposed by the API helpers.
The CLI writes `processed.h5ad`, `report.md`, `result.json`, `tables/program_usage.csv` (cells × programs), `tables/program_weights.csv` (programs × genes), and `tables/top_program_genes.csv`. cNMF additionally writes `tables/program_tpm.csv`. Gallery figures are `mean_program_usage.png` and, for multiple programs, `program_correlation.png`. Figure source tables, including program correlations, live under `figure_data/`.
1. Auto-fallback check: try `import cnmf`; if it fails, switch to `nmf` and record the fallback. 2. Load AnnData (`--input`) or build a demo. 3. Preflight: pick source matrix per `--layer` (auto-prefer `layers["counts"]` for cnmf when `--layer` is unset); reject negative values; warn if `n_genes < 50` or running NMF on raw counts without `--layer counts`. 4. Run cNMF (consensus NMF with `--n-iter` iterations per factorization) or sklearn NMF (single run, `--seed`). 5. Build top-genes-per-program table; compute per-program correlation matrix. 6. Detect degenerate output → record diagnostics; do NOT raise. 7. Save tables, figures, `processed.h5ad`, `report.md`, `result.json`.
# Demo (cNMF on synthetic data, falls back to NMF if cnmf missing) python skills/singlecell/scrna/sc-gene-programs/sc_gene_programs.py --demo --output /tmp/sc_gp_demo # cNMF with 8 programs on raw counts python skills/singlecell/scrna/sc-gene-programs/sc_gene_programs.py \ --input clustered.h5ad --output results/ \ --method cnmf --n-programs 8 --n-iter 200 --layer counts # NMF on log-normalised .X (faster, less stable) python skills/singlecell/scrna/sc-gene-programs/sc_gene_programs.py \ --input normalized.h5ad --output results/ \ --method nmf --n-programs 10 --top-genes 50
Python packages this skill's script needs. They are not installed for you — check before a long run.
`anndata`, `cnmf`, `matplotlib`, `numpy`, `pandas`, `scanpy`, `scikit-learn`, `scipy`
<!-- api:begin generated from _api.py; regenerate with run.py api <skill dir> --write -->
Conversational & memory-enabled AI research partner for multi-omics analysis. CLI + Desktop App (installers in Releases). From biological idea to full research paper.
Load when correcting batch effects in bulk expression using R sva ComBat or the legacy Python parametric approximation. Skip…
Load when discovering bulk gene co-expression modules and hub genes with R WGCNA. Skip direct expression contrasts (use…
Load when comparing gene expression between two conditions in bulk RNA-seq count data. Skip
Load when estimating cell-type proportions in bulk RNA-seq samples from a single-cell or
Load when running pathway / GO term enrichment on a bulk RNA-seq DE result list. Skip when
Load when converting Ensembl, Entrez or symbol IDs in a bulk RNA count matrix using an explicit mapping or a small human demo…