/lucid-coder:tf-activityfrom lucid-coder
TF or pathway activity from a prior-knowledge network (CollecTRI, PROGENy or any source-target-weight TSV) with decoupler 2.x ULM or MLM. Two inputs: a log-normalised single-cell h5ad (score each cell, then each group against the rest) or a DE table (score one contrast's gene statistic). Writes an activity table, the sources dropped under tmin, a heatmap and violin plot (cells) or a bar plot (contrast), a report and a reproducibility bundle. Fire on "TF activity", "transcription factor activity", "CollecTRI", "PROGENy", "pathway activity", "decoupler ulm", "decoupler mlm", "which TFs drive this contrast". Do NOT fire for gene-set over-representation or GSEA (fgsea, ORA), for ATAC motif deviation or motif enrichment (chromVAR, ArchR, MOCHA), for building or downloading the network itself, or for raw counts that are not normalised.
Ships in lucid-coder. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
You are the dispatcher for tf-activity. The script does the analysis; you collect its arguments, run it, and explain its outputs.
Run scripts/tf_activity.py. Never re-implement the analysis, change a
threshold, or pick a value the user has not given. If a required argument is
unknown, ask the user (these are grill questions), or run --demo only when the
user asks for a demo.
Then read result.json and relay chat_summary_lines and preferred_artifacts.
If the script prints ERROR: ... and exits 2, tell the user the message and the
argument it names. Do not work around it.
| Input | Format | Required content | Example |
|---|---|---|---|
--network | TSV | columns source, target, numeric weight; no duplicate source-target pair; other columns ignored | collectri_human.tsv; examples/demo_network.tsv |
--adata (cells) | .h5ad | log-normalised X (normalize_total + log1p); not raw counts, not scaled | sc-embed's data/embedded.h5ad; examples/demo.h5ad |
--groupby (cells) | obs column | at least 2 groups, each with at least 2 cells | leiden, cell_type; demo group |
--de-table (contrast) | TSV | column gene, unique, and the --stat-col column; one contrast per file | pseudobulk-de's tables/de_results.tsv; examples/demo_de.tsv |
Gene names in the data must match the network's target names (symbols for
CollecTRI and PROGENy). Rows of the DE table with a missing or non-finite stat
are dropped and counted in the summary. Gene names, cell ids and DE-table genes
must be unique (skillkit.check_unique).
The skill does not download. Export each network once with decoupler and pass the file (needs network access; CollecTRI's licence is academic by default):
import decoupler as dc
dc.op.collectri(organism="human", remove_complexes=False, license="academic").to_csv(
"collectri_human.tsv", sep="\t", index=False
)
dc.op.progeny(organism="human", top=500, thr_padj=0.05, license="academic").to_csv(
"progeny_human_top500.tsv", sep="\t", index=False
)
Ask these through the analysis contract: ${CLAUDE_PLUGIN_ROOT}/skills/lucid-coder/references/contracts.md.
Each row is a grill question. Ask the user; never fill one in.
| Argument | Meaning | Grill question | Demo-only value |
|---|---|---|---|
--input | cells or contrast | Score each cell of an h5ad, or one DE contrast? | cells |
--network | network TSV | Which exported network file (CollecTRI for TFs, PROGENy for pathways)? | examples/demo_network.tsv |
--method | ulm or mlm | Univariate (ULM, one source at a time) or multivariate (MLM, sources fitted jointly)? (tut: ULM in 41 kai notebooks, MLM in 12.) | ulm |
--tmin | minimum targets per source | How many of a source's targets must be in the data for it to be scored? (tut: kai leaves decoupler's default in all but 2 notebooks.) | 5 |
--n-top | top sources in the figures | How many top sources per group (cells) or in total (contrast) go in the figures? | 2 |
--reference | genome build and annotation release of the gene names | Which genome build and annotation were the genes counted against (e.g. GRCh38, GENCODE 44)? | synthetic demo genes, no genome build |
--context | biological context of the data | Species, tissue or cell type, condition and dataset? | synthetic demo: 3 groups x 60 cells, no real tissue |
--seed | seed | Which seed? (Recorded; no step draws random numbers.) | 0 |
--adata (cells) | input h5ad | Which h5ad holds the log-normalised cells? | examples/demo.h5ad |
--groupby (cells) | obs column of groups | Which obs column holds the clusters or labels? | group |
--rank-method (cells) | t-test_overestim_var, t-test or wilcoxon | Which test compares each group's cell scores with the rest? (tut: t-test_overestim_var in 11 of 11 kai notebooks; a tutorial value, not a default.) | t-test_overestim_var |
--limit (cells) | heatmap colour saturation | At which absolute mean activity should the heatmap colours saturate? | 3 |
--de-table (contrast) | DE table | Which DE table holds the contrast? | examples/demo_de.tsv |
--stat-col (contrast) | statistic column | Which column to score: the Wald or t stat, or log2_fc? (tut: stat in all 11 kai notebooks that name a column; log fold change in 2.) | stat |
--contrast (contrast) | contrast label | What label names this contrast in the tables? | g1_vs_g2 |
--outdir | new output directory | Which new directory gets the outputs? It must not exist. | tf_activity_demo |
The last column is demo-only, not defaults. --demo alone pins the cells
values; --demo --input contrast pins the contrast values. With --demo, only
--outdir and --input may also be given. Arguments marked (cells) or
(contrast) are required in that mode and refused in the other.
python scripts/tf_activity.py --input cells \
--adata results/2026-10-27_embed/data/embedded.h5ad --groupby leiden \
--network ref/collectri_human.tsv --method ulm --tmin 5 \
--rank-method t-test_overestim_var --n-top 5 --limit 3 \
--reference "GRCh38, GENCODE 44" --seed 0 \
--context "human PBMC, IFN-beta vs control, Kang 2018" \
--outdir results/2026-10-27_tf_cells
python scripts/tf_activity.py --input contrast \
--de-table results/2026-10-27_pbde/tables/de_results.tsv --stat-col stat \
--contrast disease_vs_healthy --network ref/progeny_human_top500.tsv \
--method mlm --tmin 5 --n-top 10 --reference "GRCh38, GENCODE 44" --seed 0 \
--context "human PBMC, IFN-beta vs control, Kang 2018" \
--outdir results/2026-10-27_tf_de
# Demo (only when the user asks for one)
python scripts/tf_activity.py --demo --outdir demo_out
python scripts/tf_activity.py --demo --input contrast --outdir demo_contrast
X; refused when negative, all
integers, or above 20 at the maximum (log1p of counts scaled to a fixed total
cannot reach it; CPM or linear data do). Layers, including sc-embed's
counts, are not read. Contrast mode reads no h5ad.X and layers are untouched on disk.decoupler dc.mt.ulm / dc.mt.mlm run with their package defaults apart from
tmin; dc.tl.rankby_group(reference="rest"); BH within group (cells) or
across sources (contrast); empty=False in contrast mode.
ERROR: <message>, exit 2.n_targets; in cells mode a gene counts only when some cell has a nonzero
value, because decoupler drops all-zero genes); sources under --tmin go to
sources_dropped.tsv. None left stops the run (no_sources). result.json
reports n_matched distinct network targets in the data out of
n_in_resource distinct targets (demo: 93 of 99).dc.mt.ulm or dc.mt.mlm (tmin=--tmin).
dc.tl.rankby_group(..., reference="rest", method=--rank-method) per group. score is the group
mean; stat, pvalue, padj are the group-vs-rest test, BH within group.
They are descriptive: every row carries unit = "cells (not replicates)".--stat-col vector
(empty=False). BH across sources. decoupler returns BH p for ULM and raw p
for MLM; the script rebuilds the other one (ULM raw p from the t value with
genes - 2 df), and a test checks BH(pvalue) == padj for both.--n-top per group by stat
(most active against the rest); contrast, the --n-top by absolute score.activity.tsv columns: cells source, group, score, stat, pvalue, padj, status, n_targets, unit, sorted by group (category order), then stat descending,
then source; contrast source, contrast, score, pvalue, padj, status, n_targets, sorted by score descending, then source. Every network source has a
row: scored sources have status tested; sources under --tmin follow as one
not_tested row each, sorted by source, with NA group, statistics and p-values
(never 0). Figures use only tested rows. result.json status_counts counts
sources per status. sources_dropped.tsv is source, n_targets, sorted by
source.
outdir/
├── report.md # params, summary, figures with captions
├── result.json # input, n_cells or n_genes, n_sources_scored, n_sources_dropped, status_counts, n_matched, n_in_resource, top_sources, method, seed, params, context, reference, chat_summary_lines, preferred_artifacts
├── tables/
│ ├── activity.tsv
│ └── sources_dropped.tsv
├── figures/
│ ├── activity_heatmap.pdf # (cells)
│ ├── activity_heatmap.png # (cells)
│ ├── activity_heatmap.csv # (cells)
│ ├── activity_violin.pdf # (cells)
│ ├── activity_violin.png # (cells)
│ ├── activity_violin.csv # (cells)
│ ├── activity_bar.pdf # (contrast)
│ ├── activity_bar.png # (contrast)
│ └── activity_bar.csv # (contrast)
└── reproducibility/
├── commands.sh # argv as run, and the resolved command with every argument
├── environment.txt # Python and package versions
└── checksums.sha256 # tables and figure PDFs; sha256sum -c from outdir
top=500 or 5000 from a tutorial
when exporting the network. Do not. kai uses both, and the choice changes
every score. Ask, and record the value in the network file name (tut: 500 in
6 kai notebooks, 5000 in 8).--tmin when a favourite TF lands in
sources_dropped.tsv. Do not. A source with few targets in the data gives an
unstable score; report it as dropped, and ask the user before any rerun.--input contrast.n_matched says how many targets were.padj or -log10(p) column.
Do not. Score a signed statistic (stat or log2_fc), as the user chose;
an unsigned column cannot say activated or repressed.claims.strength). A causal claim needs a perturbation.does not look log-normalised error. Do not. Ask the user where the
log-normalised matrix is. An h5ad whose X is scaled and whose .raw holds
the log values fails here: old decoupler read .raw silently, but this
script reads X only (tut: 12 of 2,845 kai notebooks pass use_raw=False).t-test_overestim_var). Do not. Ask, or run --demo
only when the user asked for one.Corpus sources, ClawBio mechanisms, tests, citations and the plot spec are in references/maintainer.md. The agent running the script does not need them.
examples/demo.h5ad (opens in a new tab)examples/demo_de.tsv (opens in a new tab)examples/demo_network.tsv (opens in a new tab)examples/make_demo.py (opens in a new tab)references/maintainer.md (opens in a new tab)scripts/palettes.py (opens in a new tab)scripts/plots.py (opens in a new tab)scripts/skillkit.py (opens in a new tab)scripts/tf_activity.py (opens in a new tab)scripts/theme.py (opens in a new tab)tests/test_tf_activity.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub mdmanurung/lucid-coder --plugin lucid-coder27 skills in this plugin
/alignInstall the lucid-coder house-style configs into this repository, one file at a time, after showing each diff and asking. Use when the user says "align this repo", "install the house style configs", "set up air/ruff/lintr", or "add the palette file"./cccLigand-receptor cell-cell communication between cell types from a log-normalised single-cell h5ad with LIANA+ rank_aggregate (CellPhoneDB, Connectome, log2FC, NATMI, SingleCellSignalR, or a subset), a bundled or exported ligand-receptor resource TSV, a fixed pass rule on magnitude and specificity ranks, a source x target count heatmap, an LR dot plot, a report and a reproducibility bundle. Optional per-sample runs. Fire on "cell-cell communication", "ligand-receptor analysis", "which cell types talk to which", "LIANA", "CellPhoneDB", "rank_aggregate", "CCC between clusters". Do NOT fire for spatial CCC (bivariate, MISTy), for factorising CCC across many samples (Tensor-Cell2cell, MOFAtalk), for DE-driven CCC between conditions, for non-human data without a translated resource, or for raw counts./compositionCell-type composition and differential abundance with crumblr: counts cells per sample and label (from a cell-level h5ad or a counts TSV), drops rare labels, runs crumblr's precision-weighted CLR and variancePartition dream (fixed and random effects, e.g. (1|donor)), and writes tables, a stacked composition bar, per-label proportion boxes, an effect forest, a report and a reproducibility bundle. Fire on "cell-type composition", "differential abundance of cell types", "do cell-type proportions change", "crumblr", "CLR of cell frequencies", "which populations expand after stimulation". Do NOT fire for neighbourhood-level DA on a KNN graph (Milo), gene expression DE (pseudobulk or cell-level), scCODA / Bayesian composition models, or a plain Wilcoxon on frequencies (group-tests).