/lucid-coder:velocityfrom lucid-coder
RNA velocity and fate probabilities from a single-cell h5ad with spliced and unspliced layers: scVelo velocity (stochastic or dynamical), velocity pseudotime, and CellRank 2 VelocityKernel + GPCCA fate probabilities towards named or inferred terminal states, with tables, four fixed figures, a report and a reproducibility bundle. Fire on "RNA velocity", "scVelo", "CellRank", "velocity stream", "velocity pseudotime", "fate probabilities", "terminal states", "phase portraits", "spliced unspliced". Do NOT fire for diffusion pseudotime or PAGA without velocity (trajectory), data with no spliced/unspliced layers, clustering or embedding (sc-embed), or CellRank kernels other than velocity (pseudotime, CytoTRACE, real time).
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 velocity. The script does the analysis; you collect its arguments, run it, and explain its outputs.
Run scripts/velocity.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.
Fire this skill when the user says any of:
Do NOT fire when:
spliced/unspliced layers (run velocyto, STARsolo
--soloFeatures Velocyto or alevin-fry first; that is not this skill);Environment: pixi feature velocity (pixi install -e velocity, from templates/pixi.toml).
| Input | Format | Required content | Example |
|---|---|---|---|
--adata | .h5ad | one object, cells x genes | data/velocity_input.h5ad, examples/demo.h5ad |
layers["spliced"], layers["unspliced"] | non-negative integer counts; unspliced not all zero | from velocyto, STARsolo or alevin-fry, same genes as X | merged with scv.utils.merge |
obsm["X_umap"] | 2-D UMAP | plotting only | sc-embed |
--groupby | obs column | cluster or annotation labels, at least 2 | leiden, stage |
--gene-id-col | var column | Ensembl gene ids, one per symbol; var_names are symbols | gene_ids |
X may hold raw counts or log-normalised values. When uns["log1p"] is
present (sc-embed output), X is left as it is: no normalize_per_cell on X,
no second log1p; scVelo still scales the spliced and unspliced layers inside
scv.pp.moments. Otherwise X is normalised and logged here. A layer with
negative or non-integer values, or an all-zero unspliced, stops the run.
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 h5ad holds the spliced and unspliced layers? | examples/demo.h5ad |
--gene-id-col | Which var column holds the Ensembl gene ids (none if the source has none)? | gene_ids |
--mode | Stochastic (steady-state, fast) or dynamical (full kinetics, slow) velocity? | stochastic |
--min-shared-counts | How many counts must a gene have in spliced and unspliced together to stay? | 10 |
--n-top-genes | How many highly variable genes go into velocity? | 30 |
--hvg-flavor | Which HVG flavor: seurat or cell_ranger? Recommended seurat (scanpy 1.12.4 highly_variable_genes default). | seurat |
--use-rep | Which obsm representation builds the neighbour graph and moments? Recommended X_pca (scVelo 0.3.4 default); sc-embed's X_pca_harmony is allowed. An existing rep is used as it is, PCA is not recomputed; only a missing X_pca is computed. | X_pca |
--n-pcs | How many columns of that representation (PCs) for the neighbour graph? | 10 |
--n-neighbors | How many neighbours for the graph and the moments? | 30 |
--kernel-model | Which CellRank VelocityKernel model: deterministic, stochastic or monte_carlo? Recommended deterministic (CellRank 2.3.3 default). | deterministic |
--groupby | Which obs column holds the groups? | stage |
--terminal-states | Which groups are end points (comma list), or auto to let GPCCA infer them? | s4 |
--n-states | Only with auto: how many GPCCA macrostates? | not used |
--stability-threshold | Only with auto: which coarse-grained self-transition marks a macrostate terminal? Recommended 0.96 (CellRank 2.3.3 predict_terminal_states default). Refused with named groups. | not used |
--context | Species, tissue or cell type, condition and dataset? | synthetic demo: scVelo simulation, 500 cells, 4 stages, no real tissue |
--reference | Which genome build and annotation release named the genes (for example GRCh38, GENCODE 44)? | synthetic demo, no genome build |
--seed | Which seed (PCA, neighbours)? | 0 |
--outdir | Which new directory gets the outputs? It must not exist. | velocity_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.
--mode, the integer ranges, the
--terminal-states/--n-states pairing, the file, both layers,
obsm["X_umap"], --groupby in obs and every named terminal group in it.
Gene names and cell ids must be unique (skillkit.check_unique).
skillkit.check_gene_ids stops on a duplicated gene id; --gene-id-col none
writes gene_id as NA, never a guessed id.
Bad input gives ERROR: <message>, exit 2.scv.pp.filter_genes(min_shared_counts=), then
scv.pp.normalize_per_cell and sc.pp.log1p (both skipped when
uns["log1p"] exists, so sc-embed output is not scaled or logged twice), and
sc.pp.highly_variable_genes(n_top_genes=, flavor=--hvg-flavor, subset=True). This is the
CellRank tutorial order; scvelo 0.3.4's filter_and_normalize no longer
takes n_top_genes. --n-top-genes above the genes left, or --n-pcs at or
above min(cells, --n-top-genes) when X_pca is computed, or above the
width of an existing --use-rep, stops the run.--use-rep is not in obsm and is X_pca,
sc.pp.pca(n_comps=--n-pcs, random_state=--seed) on the HVG subset; any
other missing rep stops the run. Then
sc.pp.neighbors(use_rep=--use-rep, n_pcs=, n_neighbors=, random_state=--seed), then scv.pp.moments(n_pcs=None, n_neighbors=None) on that graph.
Any neighbour graph in the input is replaced; the input X_umap is used only
for plotting.--mode dynamical first runs
scv.tl.recover_dynamics(n_jobs=1) (slow: about 1 min per 500 cells x 30
genes here); then scv.tl.velocity(mode=).scv.tl.velocity_graph(n_jobs=1),
scv.tl.velocity_pseudotime() (scVelo picks root and end cells from the
velocity graph), scv.tl.velocity_embedding(basis="umap").cr.kernels.VelocityKernel with
compute_transition_matrix(model=--kernel-model), then GPCCA.
set_terminal_states(states={group: all its cells}), so
every cell of each named group is absorbing.auto: compute_macrostates(n_states=--n-states, cluster_key=--groupby),
then predict_terminal_states(method="stability", stability_threshold=--stability-threshold). Macrostates are named after their majority
group (s1_2 when one group holds several).compute_fate_probabilities(solver="gmres", use_petsc=False), one thread, tolerance 1e-6. The mean per group gives
fate_by_group.tsv.velocity_r2
(stochastic) or fit_likelihood (dynamical), ties by gene name.layers["spliced"] and layers["unspliced"] hold raw integer counts.
X holds raw counts, or log-normalised values flagged uns["log1p"]
(sc-embed). obsm[--use-rep] is read when present.data/velocity.h5ad: the HVG subset; X is log-normalised, Ms, Mu
and velocity are added as layers, spliced and unspliced are scaled per
cell by scVelo. Not a counts matrix: do not hand it to a skill that needs raw
counts.Not asked, recorded here, all at package defaults unless a value is given.
scVelo 0.3.4: scv.tl.velocity (min_r2=0.01), velocity_graph,
velocity_embedding(basis="umap"), recover_dynamics (dynamical only),
moments(mode="connectivities"); scv.pp.filter_genes. CellRank 2.3.3:
GPCCA, compute_fate_probabilities(solver="gmres", use_petsc=False). Phase
portraits show the 4 genes with the best fit score (plot only).
Required checks that do not apply: no design is fitted (no rank check), no
resource is joined (no n_matched), and no cell is dropped. Step 3 filters genes
over all cells, not per group, so result.json reports n_genes_input beside
n_genes.
velocity_pseudotime.tsv and fate_probabilities.tsv are sorted by cell;
velocity_genes.tsv by gene_symbol; fate_by_group.tsv by group, then terminal state.
outdir/
├── report.md # params, summary, figures with captions
├── result.json # context, n_cells, n_genes, n_genes_input, status_counts, gene_id_col, mode, terminal_states, top_genes, median_velocity_pseudotime, params, seed, reference, chat_summary_lines, preferred_artifacts
├── data/
│ └── velocity.h5ad # HVG subset with Ms/Mu/velocity layers, velocity_graph, velocity_pseudotime, obsm lineages_fwd (plain array; names in uns lineages_fwd_names)
├── tables/
│ ├── velocity_genes.tsv # gene_id, gene_symbol, scVelo velocity_* (stochastic) or fit_* and velocity_genes (dynamical) columns, status
│ ├── velocity_pseudotime.tsv # cell, <groupby>, velocity_pseudotime
│ ├── fate_probabilities.tsv # cell, <groupby>, one column per terminal state
│ └── fate_by_group.tsv # <groupby>, terminal_state, mean_fate_probability, n_cells
├── figures/
│ ├── velocity_stream.pdf
│ ├── velocity_stream.png
│ ├── velocity_stream.csv
│ ├── umap_velocity_pseudotime.pdf
│ ├── umap_velocity_pseudotime.png
│ ├── umap_velocity_pseudotime.csv
│ ├── fate_by_group.pdf
│ ├── fate_by_group.png
│ ├── fate_by_group.csv
│ ├── phase_portraits.pdf
│ ├── phase_portraits.png
│ └── phase_portraits.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/velocity.h5ad is not checksummed: h5ad bytes are not stable.
velocity_genes.tsv has one row per input gene. status is tested for the
genes the model fit (the HVG subset), not_detected for genes with zero
spliced and unspliced counts, and not_tested for genes removed by
--min-shared-counts or the HVG cut; untested rows have NA statistics.
result.json status_counts counts each status.
auto with the user's
--n-states. Report which rule ran.auto terminal states as-is. Do not. GPCCA
can mark a stable early state as terminal (the demo's s1_2). Show the user
the states next to the velocity pseudotime and ask before relying on them.--min-shared-counts or raise --n-pcs
until the run passes. Do not. Relay the ERROR: line and ask.--mode dynamical "for accuracy" on a
big object. Do not without asking: it is many times slower. It is the user's
choice.pip install -U scvelo numpy pandas when scvelo
crashes. Do not. Run with the pinned versions in the uv line below.velocity_r2 as the
chance a cell becomes that state. Do not. Both are model scores, not
calibrated probabilities of an outcome.velocity_r2 and fit_likelihood score how well the splicing model fits
a gene; say "scored" or "predicted", never "drives" or "regulates"
(house-style claims.strength).--min-shared-counts or outside the
HVG subset was not tested.--reference from the gene names. Do not.
The genome build and annotation release are a grill question.scv.pl.* in-session to tweak a figure.
Do not. The tables are the result; a second run has no provenance.python scripts/velocity.py \
--adata data/velocity_input.h5ad --mode stochastic \
--min-shared-counts 20 --n-top-genes 2000 --hvg-flavor seurat \
--use-rep X_pca_harmony --n-pcs 30 --n-neighbors 30 --kernel-model deterministic \
--groupby leiden --terminal-states Alpha,Beta --gene-id-col gene_ids \
--context "mouse pancreas, E15.5 endocrinogenesis, Bastidas-Ponce 2019" \
--reference "GRCm39, GENCODE M33" \
--seed 0 --outdir results/2026-10-27_velocity
# Inferred terminal states
python scripts/velocity.py ... --terminal-states auto --n-states 6 --stability-threshold 0.96 ...
# Demo (only when the user asks for one)
python scripts/velocity.py --demo --outdir demo_out
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/velocity.py (opens in a new tab)tests/test_velocity.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).