/lucid-coder:trajectoryfrom lucid-coder
Trajectory and pseudotime from an embedded single-cell h5ad: PAGA group connectivity and diffusion pseudotime (scanpy DPT) from a fixed root cell, with tables, four fixed figures, a report and a reproducibility bundle. Fire on "pseudotime", "trajectory", "PAGA", "diffusion pseudotime", "DPT", "order cells along differentiation", "gene trends along pseudotime". Do NOT fire for RNA velocity (scVelo, CellRank), Slingshot or Monocle3 runs, clustering or embedding (sc-embed), or differential abundance.
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 trajectory. The script does the analysis; you collect its arguments, run it, and explain its outputs.
Run scripts/trajectory.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 |
|---|---|---|---|
--adata | .h5ad | log-normalised values in X (sc-embed output, not raw counts) | data/embedded.h5ad, examples/demo.h5ad |
| neighbour graph | uns["neighbors"], obsp["connectivities"] | from sc.pp.neighbors | sc-embed |
| embedding | obsm["X_umap"] | 2-D UMAP | sc-embed |
--groups | obs column | cluster or annotation labels, at least 2 | leiden, stage |
The root cell does not depend on the cell order in obs: it is a named cell
(--root-cell) or comes from a rule on the diffusion map (--root-rule, step 5).
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 | Which embedded h5ad holds the cells? | examples/demo.h5ad |
--groups | Which obs column holds the groups for PAGA? | stage |
--root-cell (or --root-rule) | Which cell (an obs_names entry) is the root? Give exactly one of --root-cell and --root-rule; never both, never neither. | cell0005 |
--root-rule (or --root-cell) | Pick the root by rule instead: diffusion-extreme takes the cell of --root-group furthest out on diffusion component 1 (step 5). Needs --root-group. | not used |
--root-group | With --root-rule only: which group holds the start of the trajectory? Refused with --root-cell. | not used |
--n-dcs | How many diffusion components (diffmap n_comps and DPT n_dcs)? | 10 |
--paga-threshold | Which PAGA connectivity must a group pair reach to count as an edge? | 0.1 |
--genes | Which genes get a trend plot? A comma list, or a file with one gene per line. | G00,G01,G02 |
--reference | Which genome build and annotation release name the genes (for example GRCh38, GENCODE 44)? Recorded in result.json, never guessed. | synthetic demo, no genome build |
--context | Species, tissue or cell type, condition and dataset? Printed first in the report and the chat summary. | synthetic demo: 600 cells, 4 stages along one simulated path, no real tissue |
--seed | Which seed (diffusion map random_state, box-plot jitter)? | 0 |
--outdir | Which new directory gets the outputs? It must not exist. | trajectory_demo |
The last column is demo-only, not defaults. --demo alone pins all of them.
With --demo, only --outdir may also be given; any other analysis argument is
an error.
python scripts/trajectory.py \
--adata data/embedded.h5ad --groups leiden \
--root-rule diffusion-extreme --root-group 3 \
--n-dcs 10 --paga-threshold 0.1 --genes genes.txt \
--reference "GRCh38, GENCODE 44" \
--context "human bone marrow CD34+, healthy donors, Setty 2019" --seed 0 --outdir results/2026-10-27_trajectory
# Demo (only when the user asks for one)
python scripts/trajectory.py --demo --outdir demo_out
X holds log-normalised values (sc-embed's embedded.h5ad), used only
for the gene trends; the neighbour graph and X_umap come from sc-embed.
layers["counts"] is not read.data/trajectory.h5ad: the input with X and layers unchanged, plus
obs["dpt_pseudotime"], uns["paga"], uns["iroot"] and obsm["X_diffmap"].Not asked, recorded here. sc.tl.paga (scanpy 1.12.4): model="v1.2" default.
sc.tl.diffmap: package defaults apart from n_comps and random_state.
sc.tl.dpt(n_branchings=0). Gene trends: 20 equal-width pseudotime bins with a
t-based 95% CI (plot only).
--groups in obs, a neighbour
graph (uns["neighbors"], obsp["connectivities"]), obsm["X_umap"],
every --genes entry in var_names, and --n-dcs below the cell count.
Gene names and cell ids must be unique (skillkit.check_unique).
Bad input gives ERROR: <message>, exit 2.--root-group (with --root-rule) must be one of them, and --root-cell
must be an obs_names entry.sc.tl.paga(adata, groups=--groups) on the stored neighbour graph.sc.tl.diffmap(n_comps=--n-dcs, random_state=--seed).--root-cell sets it directly. --root-rule diffusion-extreme uses DC1 = obsm["X_diffmap"][:, 1] (column 0 is the
trivial constant component). DC1's sign is arbitrary, so the side comes from
the data: if the median DC1 of --root-group is at or above the median DC1 of
all cells, the side is +1, else -1. The root is the --root-group cell
with the largest side * DC1; an exact tie goes to the smallest obs_names
entry. Flipping the eigenvector sign picks the same cell, and reordering
obs does not change it. The root is stored in uns["iroot"].sc.tl.dpt(n_dcs=--n-dcs) from that root, no branching. Cells not
reachable from the root get inf: they stay inf in the table, are counted
in the summary and per group (dropped_per_group), and are left out of the
box plot and gene trends.>= --paga-threshold.--genes entry, the mean of X in 20 equal-width
bins from 0 to the largest finite pseudotime, with a t-based 95% confidence
interval of each bin mean (n - 1 df; a bin with one cell has no interval).pseudotime.tsv is sorted by cell; paga_connectivities.tsv holds every group
pair once (upper triangle), in group order.
outdir/
├── report.md # params, summary, figures with captions
├── result.json # n_cells, n_groups, root_cell, root_group, root_rule, n_unreachable, dropped_per_group, n_edges_above_threshold, edges_above_threshold, median_pseudotime, genes, params, seed, context, reference, chat_summary_lines, preferred_artifacts
├── data/
│ └── trajectory.h5ad # input plus obs dpt_pseudotime, uns paga and iroot, obsm X_diffmap
├── tables/
│ ├── pseudotime.tsv # cell, <groups>, dpt_pseudotime, is_root
│ └── paga_connectivities.tsv # group_a, group_b, connectivity, above_threshold
├── figures/
│ ├── paga_graph.pdf
│ ├── paga_graph.png
│ ├── paga_graph.csv
│ ├── umap_pseudotime.pdf
│ ├── umap_pseudotime.png
│ ├── umap_pseudotime.csv
│ ├── pseudotime_by_group.pdf
│ ├── pseudotime_by_group.png
│ ├── pseudotime_by_group.csv
│ ├── gene_trends.pdf
│ ├── gene_trends.png
│ └── gene_trends.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
data/trajectory.h5ad is not checksummed: h5ad bytes are not stable.
--engine flag. Until then, say this skill runs scanpy PAGA and DPT only.n_branchings > 0) is off; DPT returns one ordering.--root-cell, or for --root-rule with a root
group; DC1's sign is arbitrary, which is why the rule sets the side from the
group's median. Report root_cell and root_rule.--paga-threshold until the graph looks
connected. Do not. The threshold is the user's answer; report the edges found.sc.tl.dpt or sc.pl.paga in-session to
tweak a figure. Do not. The tables are the result; a second run has no
provenance.claims.strength).inf pseudotime cells silently or fill them.
Do not. They are counted in n_unreachable; tell the user.--reference from the gene names. Do not.
The build and release are the user's answer.X. Do not. Trends are means of
X, which must hold log-normalised values (sc-embed output).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/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)scripts/trajectory.py (opens in a new tab)tests/test_trajectory.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)./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.