/lucid-coder:sc-embedfrom lucid-coder
Embed and cluster a QC'd single-cell h5ad: normalise, pick highly variable genes, PCA, optional Harmony integration by batch, kNN graph, UMAP and igraph Leiden, every step seeded. Writes data/embedded.h5ad, cluster and batch-by-cluster tables, four fixed figures, a report and a reproducibility bundle. Fire on "embed and cluster", "normalise, HVG, PCA, UMAP, Leiden", "run harmony on batch", "integrate batches and cluster", "UMAP coloured by batch and cluster", "Leiden clustering of my h5ad". Do NOT fire for QC or doublet filtering (sc-qc), scVI/scANVI integration, cell-type annotation, marker genes, or differential expression.
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-embed. The script does the analysis; you collect its arguments, run it, and explain its outputs.
Run scripts/sc_embed.py. Never re-implement the analysis, change a
parameter, 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 | QC'd cells, raw counts (non-negative integers) in X | sc-qc data/qc_filtered.h5ad, examples/demo.h5ad |
| batch column | obs column | --batch-key, no missing values; 2+ levels for Harmony | batch with b1, b2 |
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 QC'd h5ad holds the cells? | examples/demo.h5ad |
--target-sum | To what total count is each cell scaled before log1p? | 10000 |
--n-top-genes | How many highly variable genes? | 100 |
--flavor | Which HVG flavor: seurat, cell_ranger or seurat_v3? | seurat |
--batch-key | Which obs column holds the batch (sample, donor, run), or none? | batch |
--n-comps | How many principal components to compute? | 20 |
--integration | Integrate by batch with Harmony (harmony) or not (none)? | harmony |
--n-neighbors | How many neighbours in the kNN graph? | 15 |
--n-pcs | How many PCs (from the elbow) feed the graph? | 10 |
--min-dist | Which UMAP min_dist? | 0.3 |
--resolution | Which Leiden resolution? | 0.3 |
--leiden-n-iterations | How many Leiden iterations (-1 runs to convergence)? Recommended 2 (igraph flavor as used in the corpus; scanpy 1.12.4 default is -1). | 2 |
--harmony-max-iter | Maximum Harmony rounds? Ignored with --integration none. Recommended 20 (harmonypy 2.1.0 max_iter_harmony; its own default is 10). | 20 |
--scale-max-value | Clip scaled HVG values at this maximum, or none? Recommended none (scanpy 1.12.4 sc.pp.scale default). | none |
--svd-solver | Which PCA svd_solver? Recommended arpack (scanpy 1.12.4 default for sparse input, seeded). | arpack |
--seed | Which seed for PCA, Harmony, neighbours, UMAP and Leiden? | 0 |
--reference | Which genome build and annotation release named the 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: 2 batches x 3 groups, 300 genes, no real tissue |
--outdir | Which new directory gets the outputs? It must not exist. | sc_embed_demo |
The last column is demo-only, not defaults. --demo alone pins all of them.
With --demo, only --integration and --outdir may also be given; any other
analysis argument is an error.
ERROR: <message>, exit 2.
X must hold raw counts (non-negative integers); gene names and cell ids must
be unique (skillkit.check_unique). --batch-key none adds a constant obs
column none.layers["counts"].--flavor seurat_v3 ranks genes on the raw counts before step 4;
seurat and cell_ranger rank on the log-normalised data after step 4.
--n-top-genes genes, batch_key=--batch-key unless none.normalize_total(target_sum=--target-sum), then log1p.
X holds the log-normalised values for all genes.--scale-max-value unless none): --n-comps components,
svd_solver=--svd-solver, seeded.--integration harmony runs harmonypy.run_harmony on the
PCs by --batch-key (--harmony-max-iter rounds at most, seeded) into X_pca_harmony;
none keeps X_pca.--n-pcs columns of that representation,
--n-neighbors neighbours, seeded.--min-dist, seeded.flavor="igraph", n_iterations=--leiden-n-iterations, undirected, --resolution,
seeded, into obs["leiden"], levels in numeric order.BLAS and numba run on one thread (threadpoolctl, sc.settings.n_jobs = 1).
X holds raw integer counts; layers are ignored.data/embedded.h5ad: X holds log-normalised values for all genes,
layers["counts"] holds the raw counts. Downstream skills that need counts
(sc-annotate) take --counts-layer counts; skills that need log-normalised
X (ccc, sc-markers, signature-scoring, tf-activity) read X as it is.Not asked, recorded here. harmonypy 2.1.0 theta, lambda, sigma and
other options stay at the package defaults; Leiden runs directed=False;
PCA centres through sc.pp.scale(zero_center=True); sc.settings.n_jobs = 1.
cluster_sizes.tsv is sorted by cluster number; batch_by_cluster.tsv by
cluster number, then batch.
outdir/
├── report.md # params, summary, figures with captions
├── result.json # n_cells, n_genes, n_hvg, n_clusters, cluster_sizes, use_rep, integration, seed, params, reference, context, chat_summary_lines (first: "Context: ..."), preferred_artifacts
├── data/
│ └── embedded.h5ad # all genes; X log-normalised, layers["counts"], var highly_variable, obsm X_pca (+ X_pca_harmony), X_umap, obs leiden
├── tables/
│ ├── cluster_sizes.tsv # cluster, n_cells, frac
│ └── batch_by_cluster.tsv # cluster, batch, n_cells, frac_of_cluster (zeros kept)
├── figures/
│ ├── pca_variance.pdf
│ ├── pca_variance.png
│ ├── pca_variance.csv
│ ├── umap_batch.pdf
│ ├── umap_batch.png
│ ├── umap_batch.csv
│ ├── umap_cluster.pdf
│ ├── umap_cluster.png
│ ├── umap_cluster.csv
│ ├── batch_composition.pdf
│ ├── batch_composition.png
│ └── batch_composition.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
sc.tl.leiden at another
resolution) to "refine" clusters. Do not. Rerun the script with the user's
new --resolution into a new outdir, so each clustering has provenance.--n-pcs from the elbow itself. Do not.
Show pca_variance.png and ask the user; the elbow is a judgement.--seed or use the legacy leidenalg flavor
to match an old notebook. Do not. The igraph flavor with a fixed seed and
--leiden-n-iterations is what makes reruns identical.counts in X must be non-negative integers error. Do not. Ask where the raw
counts are; this skill normalises them itself.min_dist, neighbours and seed because
the layout depends on them; compare clusters in PC space or by markers.--reference from the gene names. Do not.
Ask for the build and annotation release; it is recorded, never inferred.claims.strength).Harmony (harmonypy) or no integration. scVI and scANVI (corpus rows A-an-05,
D-an-37) are out of scope: they need a GPU-sized training step and a model
directory. Add them later as --integration scvi with a seeded trainer.
CCA (D-an-04) is Seurat-only and out of scope.
python scripts/sc_embed.py \
--adata results/2026-10-27_qc/data/qc_filtered.h5ad \
--target-sum 10000 --n-top-genes 2000 --flavor seurat_v3 --batch-key sample \
--n-comps 50 --integration harmony --n-neighbors 20 --n-pcs 30 \
--min-dist 0.3 --resolution 1 --leiden-n-iterations 2 --harmony-max-iter 20 \
--scale-max-value none --svd-solver arpack --seed 0 --reference 'GRCh38, GENCODE 44' \
--context 'human PBMC, IFN-beta vs control, Kang 2018' \
--outdir results/2026-10-27_embed
# Demo (only when the user asks for one); add --integration none to compare
python scripts/sc_embed.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/sc_embed.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_embed.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
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).Other plugins' skills for the same job