/lucid-coder:signature-scoringfrom lucid-coder
Gene-signature scores per cell from a log-normalised single-cell h5ad (scanpy score_genes or decoupler AUCell), the mean per sample and group in a long table ready for group-tests, a size-matched random-gene-set control per signature, box, UMAP and control figures, a report and a reproducibility bundle. Fire on "score this gene set", "signature score per cell", "score_genes", "module score", "AddModuleScore in scanpy", "AUCell score", "IFN signature per sample", "does my signature beat random genes". Do NOT fire for marker discovery (use sc-markers), for DE between conditions (use pseudobulk-de), for TF or pathway activity from a prior-knowledge network (ULM/MLM, PROGENy, CollecTRI), for UCell or NNLS reference scoring, or for raw counts that are not yet 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 signature-scoring. The script does the analysis; you collect its arguments, run it, and explain its outputs.
Run scripts/signature_scoring.py. Never re-implement the scoring, change a
value, 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. To test whether a score differs
between groups, hand tables/sample_scores.tsv to the group-tests skill.
| Input | Format | Required content | Example |
|---|---|---|---|
--adata | .h5ad | log-normalised values (normalize_total + log1p) in X; not raw counts, not scaled | sc-embed's data/embedded.h5ad; examples/demo.h5ad |
--sample-col | obs column | one sample (donor, library) per cell; each sample in one group | sample |
--group-col | obs column | 2 to 6 groups | condition; demo group |
--gene-sets | TSV, long, header | columns set and gene, one row per gene; set names use only letters, digits, _, ., - | examples/demo_gene_sets.tsv |
obsm["X_umap"] | optional | 2-D embedding; without it the UMAP figures are skipped | demo has one |
Gene symbols must match var_names exactly. Duplicate rows are dropped. The
script refuses a matrix with negative values (scaled), only integers (raw
counts), or a maximum above 20 (log1p of counts scaled to a fixed total cannot
reach it; CPM or linear data do). A categorical --group-col keeps its category order; any other column
is cast to strings and sorted. An h5ad .raw is ignored (use_raw=False).
Gene names and cell ids must be unique (skillkit.check_unique).
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 |
|---|---|---|---|
--adata | input h5ad | Which h5ad holds the log-normalised cells? | examples/demo.h5ad |
--gene-sets | set, gene TSV | Which file lists the signature genes? | examples/demo_gene_sets.tsv |
--sample-col | obs column of samples | Which obs column names the sample (the replicate)? | sample |
--group-col | obs column of groups | Which obs column holds the groups to compare? | group |
--method | score_genes or aucell | Mean-minus-control score (scanpy score_genes) or rank-based AUCell (decoupler)? | score_genes |
--ctrl-size | score_genes only: control genes drawn per bin | How many control genes per expression bin? (corpus: 1000) | 50 |
--n-bins | expression bins for score_genes controls and for the random-set control | How many expression bins? Recommended 25 (scanpy 1.12.4 score_genes default, after Tirosh et al. 2016). | 25 |
--n-up | aucell only: top-ranked genes per cell in the AUC | How many top-ranked genes per cell count for the AUC? (decoupler's hidden default is 5% of genes) | not used |
--min-genes | genes a set must have in the data | How many of a set's genes must be in the data to score it? | 5 |
--n-random | random sets per signature | How many size- and expression-matched random gene sets per signature? | 50 |
--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 |
--seed | seed | Which seed? Fixes score_genes control genes, random sets and jitter. | 0 |
--context | what the data are; opens the report and chat_summary_lines | Species, tissue or cell type, condition and dataset? | synthetic demo: 8 samples, healthy vs disease, no real tissue |
--outdir | new output directory | Which new directory gets the outputs? It must not exist. | given by the user |
The last column is demo-only, not defaults. --demo alone pins all of them;
beside --demo only --outdir may be given. --n-bins is always required.
--ctrl-size is required with score_genes and refused with aucell; --n-up
the reverse.
python scripts/signature_scoring.py \
--adata results/2026-10-27_embed/data/embedded.h5ad \
--gene-sets data/hallmark_ifn.tsv --sample-col donor --group-col condition \
--method score_genes --ctrl-size 1000 --n-bins 25 --min-genes 5 \
--n-random 100 --reference "GRCh38, GENCODE 44" --seed 0 \
--context "human PBMC, IFN-beta vs control, Kang 2018" \
--outdir results/2026-10-27_ifn-score
python scripts/signature_scoring.py --adata embedded.h5ad --gene-sets sets.tsv \
--sample-col donor --group-col condition --method aucell --n-up 500 \
--n-bins 25 --min-genes 5 --n-random 100 --reference "GRCh38, GENCODE 44" --seed 0 \
--context "human PBMC, IFN-beta vs control, Kang 2018" --outdir results/ifn-aucell
# Demo (only when the user asks for one)
python scripts/signature_scoring.py --demo --outdir demo_out
X (sc-embed's embedded.h5ad qualifies).
Layers, including counts, are not read.data/scored.h5ad: X and layers as in the input, plus obs columns
<method>_<set> with the per-cell scores. tables/cell_scores.tsv carries
unit = "cells (not replicates)": per-cell scores are descriptive.sc.tl.score_genes (scanpy 1.12.4): use_raw=False, gene_pool all genes,
random_state=--seed. dc.mt.aucell (decoupler): empty=False,
tmin=--min-genes. Random sets: numpy.random.default_rng(--seed).
ERROR: <message>, exit 2. Gene
names and cell ids must be unique.var_names; record
missing genes per set. A set with fewer than --min-genes found is not
scored and kept as a not_tested row; stop only if every set is short.
result.json reports n_matched distinct set genes found out of
n_in_resource distinct genes listed (demo: 20 of 21).score_genes: sc.tl.score_genes(ctrl_size=, n_bins=, random_state=seed, use_raw=False), one call per set. aucell: one dc.mt.aucell(net, tmin=--min-genes, n_up=, empty=False) call for all sets.X as score_genes does (rank, then
integer-divide by round(n_genes / (--n-bins - 1)); Tirosh et al. 2016).
For each set draw --n-random random gene sets of the same size, taking one
gene from the bin of each signature gene, never a set gene or a repeat
(numpy.random.default_rng(seed)). When a signature gene's bin has too few
candidates left (the top bin often holds one gene), the missing genes come
from the nearest bin; n_borrowed in random_control.tsv counts them per set.
--n-bins must leave 2 or more genes per bin. Score
them with the same engine and arguments, and summarise them the same way.
The statistic is the spread of group means of sample means (max minus min
group mean). A set beats random when its spread exceeds every random
set's; p_empirical = (1 + n random >= observed) / (n_random + 1).data/scored.h5ad (obs <method>_<set>), the tables, figures,
report, result and reproducibility bundle.cell_scores.tsv is sorted by cell; sample_scores.tsv by feature, then
subject; genes_found.tsv and random_control.tsv by set.
random_control.tsv has one row per listed set with a status column:
tested, or not_tested (fewer than --min-genes genes in the data, NA
statistics, no figures); result.json counts them in status_counts. sample_scores.tsv
uses group-tests' input names: feature is the set, subject the sample, and
the group column keeps its obs name. Figures are named per set; the tree lists
the demo's sets sig_null and sig_up.
outdir/
├── report.md # params, summary, figures with captions
├── result.json # n_cells, n_samples, n_sets, n_matched, n_in_resource, n_found, missing_genes, beats_random, status_counts, p_empirical, method, seed, params, context, reference, chat_summary_lines, preferred_artifacts
├── data/
│ └── scored.h5ad # input plus obs <method>_<set>; not checksummed
├── tables/
│ ├── cell_scores.tsv # cell, sample col, group col, one column per set
│ ├── sample_scores.tsv # feature, subject, group col, value, n_cells
│ ├── genes_found.tsv # set, n_listed, n_found, missing
│ └── random_control.tsv # set, n_genes, n_random, n_borrowed, observed_spread, random_mean, random_max, p_empirical, beats_random, status
├── figures/
│ ├── score_by_group_sig_null.pdf
│ ├── score_by_group_sig_null.png
│ ├── score_by_group_sig_null.csv
│ ├── score_by_group_sig_up.pdf
│ ├── score_by_group_sig_up.png
│ ├── score_by_group_sig_up.csv
│ ├── score_umap_sig_null.pdf
│ ├── score_umap_sig_null.png
│ ├── score_umap_sig_null.csv
│ ├── score_umap_sig_up.pdf
│ ├── score_umap_sig_up.png
│ ├── score_umap_sig_up.csv
│ ├── random_control.pdf
│ ├── random_control.png
│ └── random_control.csv
└── 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
sample_scores.tsv to
group-tests.claims.strength).missing "not expressed". Do not.
Non-detection is not absence: a gene not in var_names was filtered or named
differently, so it is "not tested".p_empirical assume
independent samples; the donor term belongs in group-tests' design.beats_random as a group test. Do not. It
says the signature separates groups more than random genes of the same size;
direction and significance between groups come from group-tests.--ctrl-size 1000 --n-bins 25 because the
corpus uses them, or let AUCell pick its 5% n_up. Do not. Ask; the corpus
values go in the grill question, not the command.--min-genes to score a not_tested set,
or drop its row. Do not. Report it and its missing genes; the user fixes the
symbols (case, aliases, Ensembl IDs) or chooses the threshold.does not look log-normalised error. Do not. Ask where the log-normalised
values are.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_gene_sets.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/signature_scoring.py (opens in a new tab)scripts/skillkit.py (opens in a new tab)scripts/theme.py (opens in a new tab)tests/test_signature_scoring.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).