/lucid-coder:sc-annotatefrom lucid-coder
Cell-type annotation of a single-cell query h5ad by reference label transfer: CellTypist (a given model, or one trained on a labelled reference h5ad) or scanpy ingest kNN transfer, then a marker dotplot to check the labels. Writes per-cell labels with a confidence, a label-by-cluster table, four fixed figures, an annotated h5ad, a report and a reproducibility bundle. Fire on "annotate cell types", "label transfer from a reference", "run CellTypist", "train a CellTypist model on my reference", "scanpy ingest labels", "map query cells to reference labels". Do NOT fire for marker-only manual annotation without a reference or model, scANVI/scArches/Seurat reference mapping, clustering or UMAP of the query, or label hierarchy cleanup.
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 sc-annotate. The script does the analysis; you collect its arguments, run it, and explain its outputs.
Run scripts/sc_annotate.py. Never re-implement the transfer, change a
setting, 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 |
|---|---|---|---|
--query | .h5ad | raw counts (non-negative integers) in X, or in --counts-layer when X is not counts; obsm["X_umap"]; the --over-clustering obs column | examples/demo_query.h5ad |
--reference-adata | .h5ad | raw counts in X (or --reference-counts-layer); the --reference-label obs column with at least 2 labels | examples/demo_reference.h5ad |
--model | .pkl | a CellTypist model saved by model.write or downloaded beforehand | data/celltypist_model.pkl of a demo run |
--markers | .tsv | exactly the columns label and gene, one row per marker | examples/demo_markers.tsv |
Gene names must match between query and reference or model (symbols with symbols). The UMAP is the query's own; the script does not compute or project one.
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 |
|---|---|---|
--query | Which h5ad holds the cells to label? | examples/demo_query.h5ad |
--markers | Which marker genes check each label (TSV of label, gene)? | examples/demo_markers.tsv |
--over-clustering | Which obs column holds the query clusters (used for voting and the label-by-cluster table)? | cluster |
--engine | CellTypist (celltypist) or scanpy ingest kNN (ingest)? | celltypist |
--seed | Which seed? | 0 |
--reference | Which genome build and annotation release named the query genes (e.g. GRCh38, GENCODE 44)? Recorded in result.json. | synthetic demo genes, no genome build |
--context | Species, tissue or cell type, condition and dataset? | synthetic demo: 4 PBMC-like cell types, reference and half-depth query, no real tissue |
--model | celltypist only: which saved CellTypist model? Give this or --reference-adata. | absent |
--reference-adata | Which labelled reference h5ad? (celltypist: trains a model; ingest: required) | examples/demo_reference.h5ad |
--reference-label | Which reference obs column holds the labels? | cell_type |
--majority-voting | celltypist only: refine labels by majority vote within each cluster (yes/no)? | yes |
--n-pcs | ingest only: how many reference PCs? | 10 |
--n-neighbors | ingest only: how many reference neighbours vote? | 15 |
--counts-layer | Required when X of the query is not raw counts (sc-embed's embedded.h5ad has log-normalised X): which query layer holds the raw counts? Refused absent otherwise. | absent (X) |
--reference-counts-layer | Same for --reference-adata when its X is not raw counts. | absent (X) |
--outdir | Which new directory gets the outputs? It must not exist. | sc_annotate_demo |
The last column is demo-only, not defaults. --demo alone pins all of them.
With --demo, only --engine and --outdir may also be given; --demo --engine ingest uses the ingest demo values. An argument of the other engine is
an error, so a run never silently ignores one.
X, or in the layer named by --counts-layer
(query) and --reference-counts-layer (reference). After sc-embed, X is
log-normalised and layers["counts"] holds the counts: pass
--counts-layer counts. Without the option, a non-count X stops the run.data/annotated.h5ad: X and every layer exactly as in the input
(sc-embed's log-normalised X stays log-normalised, so ccc, sc-markers,
signature-scoring and tf-activity accept it), plus obs transferred_label and
transferred_confidence.Not asked, recorded here. normalize_total(target_sum=1e4) and log1p on copies
before CellTypist and ingest (the corpus rule); celltypist.train at its default
solver with n_jobs=1; celltypist.annotate in best-match mode;
sc.tl.Ingest kNN vote with map_labels(method="knn"); confidence is the model
probability or the neighbour agreement. Plot sizes (dot 4 mm, jitter 0.3) change
figures only.
ERROR: <message>, exit 2.
Gene names and cell ids must be unique in the query and the reference
(skillkit.check_unique).normalize_total(1e4), then
log1p, starting from the raw counts (X, or --counts-layer). X in the
saved h5ad is exactly the input X, whatever it held.--engine:
celltypist: load --model, or train on --reference-adata by
--reference-label (celltypist.train, CellTypist's default solver,
n_jobs=1, random_state=--seed). Then celltypist.annotate in
best-match mode, with majority voting over --over-clustering when
--majority-voting yes.ingest: keep shared genes, then PCA (--n-pcs) and a kNN graph
(--n-neighbors) on the reference, both with random_state=--seed. Then
scanpy Ingest projects the query into the reference PCA and takes the
kNN mode label. Ties go to the label first in sorted order.--markers label must be a model or reference
label, and every gene must be in the query.--over-clustering cluster.tables/labels.tsv is sorted by cell; tables/label_by_cluster.tsv by cluster
(obs category order), then label, and lists every cluster × label pair,
zeros included. n_matched of n_in_resource is the gene overlap: query genes
found among the model's features or the reference's genes (n_shared_genes
repeats n_matched).
outdir/
├── report.md # params, summary, figures with captions
├── result.json # n_cells, n_labels, n_shared_genes, n_matched, n_in_resource, label_counts, median_confidence, params, engine, seed, reference, context, chat_summary_lines (first: "Context: ..."), preferred_artifacts
├── data/
│ ├── annotated.h5ad # the query, X and layers as input, plus obs transferred_label and transferred_confidence
│ └── celltypist_model.pkl # only when celltypist trained on --reference-adata
├── tables/
│ ├── labels.tsv # cell, label, confidence
│ └── label_by_cluster.tsv # cluster, label, n_cells, frac_of_cluster
├── figures/
│ ├── umap_label.pdf
│ ├── umap_label.png
│ ├── umap_label.csv
│ ├── marker_dotplot.pdf
│ ├── marker_dotplot.png
│ ├── marker_dotplot.csv
│ ├── confidence_box.pdf
│ ├── confidence_box.png
│ ├── confidence_box.csv
│ ├── label_cluster_heatmap.pdf
│ ├── label_cluster_heatmap.png
│ └── label_cluster_heatmap.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
models.download_models,
Immune_All_Low.pkl) when none is given. Do not. Ask the user for a model
path or a reference; the script never touches the network.claims.strength), and check the marker dot plot.--reference from the gene names. Do not.
Ask for the build and annotation release; it is recorded, never inferred.
--reference-adata is the labelled h5ad, a different argument.claims.strength): validating them needs a reference donor
held out from training, which this skill does not run. Say so in the report.must hold raw counts error. Do not. Point the user to the raw counts (after sc-embed, pass
--counts-layer counts); the script normalises them itself.python scripts/sc_annotate.py \
--query data/query.h5ad --markers config/pbmc_markers.tsv \
--over-clustering leiden --engine celltypist \
--model models/ref_pbmc_L2.pkl --majority-voting yes \
--seed 0 --reference 'GRCh38, GENCODE 44' \
--context 'human PBMC, IFN-beta vs control, Kang 2018' --outdir results/2026-10-27_annotate
python scripts/sc_annotate.py \
--query data/query.h5ad --markers config/pbmc_markers.tsv \
--over-clustering leiden --engine ingest \
--reference-adata data/reference.h5ad --reference-label cell_type \
--n-pcs 30 --n-neighbors 15 --seed 0 --reference 'GRCh38, GENCODE 44' \
--context 'human PBMC, IFN-beta vs control, Kang 2018' --outdir results/2026-10-27_ingest
# Demo (only when the user asks for one)
python scripts/sc_annotate.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_markers.tsv (opens in a new tab)examples/demo_query.h5ad (opens in a new tab)examples/demo_reference.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/sc_annotate.py (opens in a new tab)scripts/skillkit.py (opens in a new tab)scripts/theme.py (opens in a new tab)tests/test_sc_annotate.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).