/lucid-coder:compositionfrom lucid-coder
Cell-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).
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 composition. The script does the analysis; you collect its arguments, run it, and explain its outputs.
Run scripts/composition.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.
Do NOT fire when:
Environment: pixi feature bioc-de (pixi install -e bioc-de, from templates/pixi.toml).
Give exactly one input mode.
| Input | Format | Required content | Example |
|---|---|---|---|
--adata | .h5ad | cell-level obs with unique cell ids, --sample-col, --label-col, --donor-col, every --formula term and --group-col; X is not read | examples/demo.h5ad |
--counts | .tsv | first column sample ID, one column per label, non-negative integer cell counts | sample B Mono ... |
--meta | .tsv | first column the same unique sample IDs as --counts, --donor-col, every --formula term and --group-col | sample donor condition |
Formula terms, --donor-col and --group-col must be constant within a sample. A numeric
column enters as a continuous covariate; code a factor as strings. Only additive
formulas (~ a + b) with random intercepts (1|x) are accepted. The reference
level of a factor is its first value in alphabetical order, as in R, so the
coefficient is <column><level> (e.g. conditionstim).
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 | Grill question | Demo-only value |
|---|---|---|
--adata + --sample-col + --label-col | Which h5ad holds the cells, which obs column names the sample (one library), which the cell-type label? | examples/demo.h5ad, sample, cell_type |
--counts + --meta | Or: which TSV holds samples x labels counts, which TSV the sample metadata? | not used |
--context | Species, tissue or cell type, condition and dataset? | synthetic demo: 8 donors, ctrl vs stim, 7 PBMC-like labels, no real tissue |
--donor-col | Which sample column names the donor (person or animal)? A donor with several samples needs a donor term in --formula. | donor |
--formula | Which model? Does a donor give more than one sample (then (1|donor)), and which covariates enter? | ~ condition + (1|donor) |
--coef | Which coefficient is the effect of interest (model.matrix name)? | conditionstim |
--group-col | Which sample column orders and colours the figures? | condition |
--tau | Which Dirichlet-multinomial overdispersion for crumblr? (crumblr's own default is 1; the weights barely depend on it.) | 1 |
--min-count | How many cells, summed over all samples, must a label have to be tested? | 50 |
--padj-max | Which BH-adjusted p cutoff marks a label significant? | 0.05 |
--seed | Which seed? (Recorded; crumblr and dream draw no random numbers; it seeds the box jitter of unpaired designs.) | 0 |
--outdir | Which new directory gets the outputs? It must not exist. | composition_demo |
The last column is demo-only, not defaults. --demo alone pins all of them;
only --outdir may be given beside it.
ERROR: <message>, exit 2.
Cell ids (--adata) and sample ids (--counts, --meta) must be unique
(skillkit.check_unique).pd.crosstab), or read --counts;
build one metadata row per sample from obs or --meta. Then check the design:
the fixed-effect terms of --formula must give a full-rank design
(skillkit.check_design_rank; batch confounded with condition stops the run),
and a donor with several samples must appear in --formula, fixed or
(1|donor) (skillkit.check_replication). n_donors and n_samples go to
result.json.--min-count cells over all samples; they are
listed in result.json (dropped_labels) and the report, with the cells they
remove per --group-col level (dropped_cells_by_level). No sample is
dropped. Proportions and CLR use the kept labels only.scripts/crumblr.R: crumblr(counts, tau = --tau) (samples as
rows), dream(cobj, --formula, meta), eBayes, then
topTable(coef = --coef, number = Inf, confint = TRUE). A --coef not in the
fit fails with the list of coefficients.padj < --padj-max, BH across the labels tested.Calls follow the crumblr-compositional reference skill (the reference skill
named for composition in docs/pipeline-skills.md)
(~/.claude/skills/crumblr-compositional/references/getting-started.md:15-28,66-76;
integration-pseudobulk.md for the counts orientation). se is logFC / t;
ci_low/ci_high are limma's CI.L/CI.R, the 95% interval on the moderated t.
Later engines, not built.
--tree): buildClusterTreeFromPB(pb) (dreamlet) needs a
pseudobulk expression object that neither input mode carries, so
treeTest(fit, cobj, hcl, coef=) (tree-testing.md:9-21) waits for an
expression-aware input.Tables are wide with one row per sample, sorted by sample. da_results.tsv is
sorted by padj, then label, and keeps every input label: status is tested, or
not_tested with NA statistics for a label under --min-count. Figures use the
tested labels only. Box figures are named proportion_<label> with
non-word characters replaced by _; the tree below lists the demo's six.
outdir/
├── report.md # params, summary, figures with captions
├── result.json # n_samples, n_donors, dropped_cells_by_level, n_labels_tested, dropped_labels, status_counts, n_significant, significant (label: up/down), paired_by, engine, params, seed, context, chat_summary_lines (first: "Context: ..."), preferred_artifacts
├── tables/
│ ├── counts.tsv # sample x kept labels, cells
│ ├── proportions.tsv # counts / sample total over kept labels
│ ├── clr.tsv # crumblr's CLR values (cobj$E, pseudocount 0.5)
│ └── da_results.tsv # label, logFC, se, t, ci_low, ci_high, pvalue, padj, significant, status
├── figures/
│ ├── composition.pdf
│ ├── composition.png
│ ├── composition.csv
│ ├── proportion_B.pdf
│ ├── proportion_B.png
│ ├── proportion_B.csv
│ ├── proportion_CD4_T.pdf
│ ├── proportion_CD4_T.png
│ ├── proportion_CD4_T.csv
│ ├── proportion_CD8_T.pdf
│ ├── proportion_CD8_T.png
│ ├── proportion_CD8_T.csv
│ ├── proportion_DC.pdf
│ ├── proportion_DC.png
│ ├── proportion_DC.csv
│ ├── proportion_Mono.pdf
│ ├── proportion_Mono.png
│ ├── proportion_Mono.csv
│ ├── proportion_NK.pdf
│ ├── proportion_NK.png
│ ├── proportion_NK.csv
│ ├── effect_forest.pdf
│ ├── effect_forest.png
│ └── effect_forest.csv
└── reproducibility/
├── commands.sh # argv as run, and the resolved command with every argument
├── environment.txt # Python packages; R, crumblr, variancePartition, limma, lme4
└── checksums.sha256 # tables and figure PDFs; sha256sum -c from outdir
Fixed plot spec. No titles and no stars; captions with padj sit in
report.md.
composition: plots.plot_composition, one stacked bar per sample, samples
ordered by --group-col then sample, labels coloured by categorical_palette (colour-blind safe, up to 23).proportion_<label>: plots.plot_box of each sample's share per
--group-col level (Tol blue, red, ...), y title " (fraction of
sample's cells)". Under 10 samples per level (the demo has 8) it draws points
and the group median, no box, and the caption says so. When a random-effect term of
--formula has exactly one sample per group level (paired donors), points sit
on the box centre and a line joins each donor (paired_by in result.json);
otherwise points jitter by ±0.2 with --seed.effect_forest: matplotlib in the house theme, logFC with its 95% CI per
label, sorted by logFC; red when significant, dashed line at 0.scripts/plots.py, theme.py, palettes.py and skillkit.py are byte copies
of templates/; a test fails when they drift.
--coef; a mechanism needs a perturbation
or other data (house-style claims.strength).--donor-col
appears in --formula; ask whether it enters as (1|donor) or fixed.--min-count to keep a rare label it cares
about. Do not. The cutoff is the user's answer; report the dropped labels and
ask.(1|donor) when the fit warns of a singular
random effect or gives few hits. Do not. Repeated samples per donor are not
independent; ask the user.--coef from the condition values. Do not.
Ask, or run once and read the coefficient list from the --coef error.--counts. Do not. crumblr's precision weights need raw cell counts; the
script refuses non-integers.--sample-col or --label-col (or the first --meta
column) stops the run with missing_ids, naming the column and the count;
casting it would make a fake sample or label called "nan". Ask the user to fix
the rows.--demo only when the user asked
for a demo.Not arguments: the script sets these, and reproducibility/environment.txt
records the package versions. A change is a maintainer edit, not a user choice.
crumblr(counts, tau = --tau) with every other argument at its
package default, then variancePartition dream (REML, Satterthwaite df) and
limma eBayes; topTable(confint = TRUE) gives the CI and BH padj.--formula are R's alphabetical levels
(stringsAsFactors); the script does not set them, so --coef names the
coefficient against the alphabetically first level.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/make_demo.py (opens in a new tab)references/maintainer.md (opens in a new tab)scripts/composition.py (opens in a new tab)scripts/crumblr.R (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/theme.py (opens in a new tab)tests/test_composition.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./enrichmentGene-set enrichment on one or more DE tables (contrasts or cell types): preranked fgsea in R, or over-representation (one-sided Fisher / hypergeometric) of the significant genes against a stated universe, BH within each contrast, with an NES dot plot, an NES heatmap, running enrichment-score curves, a report and a reproducibility bundle. Fire on "GSEA on the DE results", "fgsea Hallmark per cell type", "pathway enrichment of the DE genes", "over-representation analysis", "ORA with a background", "which pathways are up in stim", "NES dotplot". Do NOT fire for scoring a gene set per cell or sample (signature scoring), for TF or pathway activity inference (decoupler ULM/MLM, PROGENy), for enrichment that needs the dreamlet fit object (zenith), or when there is no DE table yet (run pseudobulk-de first)./figure-styleHouse figure style for scientific plots in R (ggplot2, ComplexHeatmap) and Python (plotnine, plotnine-extra): use it for ANY figure drawn from experimental, omics or single-cell data, including plot types not listed here (box, violin, slopegraph, forest, volcano, heatmap, dot plot, UMAP, PCA, composition bars, QC, survival curves, enrichment, spatial maps). Takes precedence over generic charting or dashboard skills for these figures. Do NOT fire for web dashboards, slide graphics or UI charts./gene-programsGene-program discovery by consensus NMF (cNMF-style) on raw single-cell counts: HVG selection, repeated seeded sklearn NMF, a local-density filter and k-means consensus of the replicate components, per-cell program usage, gene scores, top genes, mean usage, fraction of active cells and one-vs-rest AUC per group, a stability table, four fixed figures, a report and a reproducibility bundle. Fire on "gene programs", "cNMF", "consensus NMF", "gene expression programs", "GEP usage", "NMF programs per cell type", "which programs mark each cluster", "structure plot of program usage". Do NOT fire for scoring a known gene set (score_genes, UCell), for projecting onto a fixed reference (starCAT, NMFproj), for choosing k by a sweep, for marker genes per cluster (use sc-markers), or for log-normalised input./group-testsGroup-comparison and association tests on sample-level values (cell-type frequencies or CLR values, signature scores, Olink NPX): one Wilcoxon rank-sum, paired Wilcoxon signed-rank, Spearman or Pearson test per feature, BH or Bonferroni across features, an effect size for every test, a table, box or scatter figures for the top features, a report and a reproducibility bundle. Fire on "Wilcoxon per cell type", "compare frequencies between groups", "paired test pre vs post per donor", "Olink NPX healthy vs disease", "correlate scores with age", "Spearman per feature with FDR". Do NOT fire for gene-level differential expression from counts (pseudobulk DE), cell-level tests (marker genes, rank_genes_groups), compositional models (scCODA, crumblr, propeller), regression with covariates, or combining p-values across cohorts.