/lucid-coder:sc-qcfrom lucid-coder
scRNA-seq cell QC and doublet removal from a raw-count h5ad with a sample column: computes per-cell QC metrics (genes, counts, % mito, % ribo), scores doublets with Scrublet per sample, applies fixed or per-sample MAD thresholds, drops failed cells and predicted doublets, and writes a filtered h5ad, tables, four fixed figures, a report and a reproducibility bundle. Fire on "QC my single-cell data", "filter low-quality cells", "remove doublets", "run Scrublet", "mito / gene count thresholds", "MAD-based QC per sample". Do NOT fire for ambient RNA removal (CellBender, SoupX), normalisation, clustering or annotation, gene filtering, or QC of bulk RNA-seq samples.
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-qc. The script does the analysis; you collect its arguments, run it, and explain its outputs.
Run scripts/sc_qc.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 | raw counts (non-negative integers) in X, or in --layer | examples/demo.h5ad |
cell-level obs | column | --sample-col, one value per library (Scrublet runs per value) | sample |
var_names | gene symbols | mitochondrial genes start with --mito-prefix | MT-CO1 |
Each sample needs more than 30 cells (one per Scrublet principal component).
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 unfiltered cells? | examples/demo.h5ad |
--layer (optional) | Which layer holds the raw counts? Absent means X. | absent (X) |
--sample-col | Which obs column names the sample (one 10x library)? | sample |
--mito-prefix | Which prefix marks mitochondrial genes (MT- human, mt- mouse)? (tut: MT- in 80 kai notebooks, mt- in 40, both in 7.) | MT- |
--mode | Fixed thresholds for every sample (fixed), or outliers per sample by MAD (mad)? | mad |
--min-genes (fixed) | Fewest genes detected for a kept cell? (tut: 200 in 39 of 106 kai notebooks; 100-700 in the rest.) | — |
--max-genes (fixed) | Most genes detected for a kept cell? | — |
--min-counts (fixed) | Fewest UMI counts for a kept cell? | — |
--max-pct-mito (fixed) | Highest % mitochondrial counts for a kept cell? In percent. (tut: kai cutoffs run 5-50%; 23 notebooks write it as the fraction 0.2.) | — |
--mads-counts (mad) | How many MADs from the median of log1p counts, each side? (tut: 5, 5 and 3 for counts, genes and mito in the sc-best-practices pattern, 15 kai notebooks, mostly one repo.) | 5 |
--mads-genes (mad) | How many MADs from the median of log1p genes, each side? | 5 |
--mads-mito (mad) | How many MADs above the median % mito? | 3 |
--expected-doublet-rate | Which doublet rate does the 10x loading table give for these libraries' recovered cells? (tut: kai uses 0.1, 0.02 or 0.06, never tied to the 10x loading table.) | 0.08 |
--doublet-threshold | Let Scrublet pick a cutoff per sample (auto), or one fixed score in (0, 1)? | auto |
--scrublet-n-prin-comps | How many principal components does Scrublet use? Recommended 30 (scanpy 1.12.4 sc.pp.scrublet default). | 30 |
--seed | Which seed for Scrublet? | 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: 3 samples of 5 populations, planted low-quality cells and doublets, no real tissue |
--outdir | Which new directory gets the outputs? It must not exist. | sc_qc_demo |
The four fixed-mode flags are required with --mode fixed and refused with
--mode mad; the three MAD flags the other way round. The last column is
demo-only, not defaults. --demo alone pins all of them; with --demo, only
--outdir may also be given.
ERROR: <message>, exit 2.
Gene names and cell ids must be unique (skillkit.check_unique).sc.pp.calculate_qc_metrics on the raw counts, with
mito = genes starting with --mito-prefix and ribo = genes starting
with RPS or RPL (any case). Ribo is reported, never thresholded.sc.pp.scrublet(batch_key=<sample>, expected_doublet_rate=..., random_state=--seed, n_prin_comps=--scrublet-n-prin-comps, use_approx_neighbors=False) on all cells. A cell is a predicted doublet when
its score exceeds its sample's threshold (--doublet-threshold auto lets
Scrublet pick one per sample).--mode fixed: --min-genes <= genes <= --max-genes,
counts >= --min-counts, % mito <= --max-pct-mito; the same in every sample.--mode mad: per sample, median ± n × MAD on log1p counts
(--mads-counts) and log1p genes (--mads-genes), both sides; median +
n × MAD on % mito (--mads-mito), upper side only. MAD is unscaled
(scipy.stats.median_abs_deviation, scale 1), so the limit is median ± n × MAD,
not n × 1.4826 × MAD. When a sample's MAD is 0 for a metric, the limit equals
the median; result.json zero_mad and the report name the sample, metric
and resulting limit.qc_status names the first failing rule in the order low_counts,
high_counts, low_genes, high_genes, high_mito; else pass.X, or in --layer. Other layers are carried
along, not read.data/qc_filtered.h5ad: the kept cells with X and all layers exactly
as in the input (raw counts), plus the QC obs columns. sc-normalize or sc-embed
take it next.sc.pp.scrublet (scanpy 1.12.4): use_approx_neighbors=False (exact kNN, for
reproducible runs); every other option stays at the package default.
sc.pp.calculate_qc_metrics(percent_top=None, log1p=True). Ribosomal genes
(RPS, RPL) are reported, never thresholded. Plot bins (40) and facet columns
(4) change figures only.
qc_per_cell.tsv is sorted by sample, then cell; cells_per_sample.tsv by sample.
outdir/
├── report.md # params, summary, figures with captions
├── result.json # n_cells_before, n_cells_after, n_failed_qc, n_doublets, n_failed_and_doublet, zero_mad, cells_after_per_sample, failed_qc_per_sample, doublets_per_sample, doublet_thresholds, mode, seed, params, reference, context, chat_summary_lines (first: "Context: ..."), preferred_artifacts
├── data/
│ └── qc_filtered.h5ad # kept cells; X and layers as input; obs gains the QC columns
├── tables/
│ ├── qc_per_cell.tsv # cell, sample, total_counts, n_genes_by_counts, pct_counts_mito, pct_counts_ribo, doublet_score, predicted_doublet, qc_status, fate, kept
│ └── cells_per_sample.tsv # sample, n_cells_before, n_failed_qc, n_doublets, n_failed_and_doublet, n_cells_after, min/max counts, min/max genes, max_pct_mito, doublet_threshold
├── figures/
│ ├── qc_violins.pdf
│ ├── qc_violins.png
│ ├── qc_violins.csv
│ ├── counts_vs_genes.pdf
│ ├── counts_vs_genes.png
│ ├── counts_vs_genes.csv
│ ├── doublet_scores.pdf
│ ├── doublet_scores.png
│ ├── doublet_scores.csv
│ ├── cells_per_sample.pdf
│ ├── cells_per_sample.png
│ └── cells_per_sample.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
n_failed_qc and n_doublets overlap: a doublet that also fails QC counts in
both, so they do not sum to n_cells_before - n_cells_after. The overlap is
n_failed_and_doublet; removed = n_failed_qc + n_doublets - n_failed_and_doublet. fate is exclusive: kept, failed QC, or doublet (passed QC only).
Limits in cells_per_sample.tsv are on the raw scale; max_counts is inf in
fixed mode.
Drops are reported per sample, the group QC runs in. sc-qc takes no condition
column on purpose: QC often runs before the sample sheet is joined, and samples
nest in conditions. The skill that aggregates samples next (pseudobulk-de,
composition) sums failed_qc_per_sample and doublets_per_sample per condition.
batch_key).mt_frac < 0.2 and pct_counts_mt < 20 are the same
cut. Ask, and say that --max-pct-mito takes percent (tut: 59 of 2,845 kai
notebooks set a mito cutoff).--mode mad is per sample by design.--mito-prefix or fall back to MT- for
mouse. Do not. Ask; the no gene name starts with error exists because a wrong
prefix silently gives 0% mito.--doublet-threshold by eye. Do not. Report it and ask the user.predicted_doublet cell a doublet ("83
doublets in S1"). Do not. It is a Scrublet call on a score, so write
"predicted doublets" (house-style claims.strength).--reference from the gene names. Do not.
Ask for the build and annotation release; it is recorded, never inferred.counts ... must be non-negative integers error. Do not. Point --layer at the
raw counts or ask where they are.python scripts/sc_qc.py \
--adata data/raw_cells.h5ad --layer counts --sample-col sample \
--mito-prefix MT- --mode mad --mads-counts 5 --mads-genes 5 --mads-mito 3 \
--expected-doublet-rate 0.06 --doublet-threshold auto \
--scrublet-n-prin-comps 30 --seed 0 --reference 'GRCh38, GENCODE 44' \
--context 'human PBMC, IFN-beta vs control, Kang 2018' --outdir results/2026-10-27_qc
python scripts/sc_qc.py \
--adata data/raw_cells.h5ad --sample-col sample --mito-prefix MT- \
--mode fixed --min-genes 200 --max-genes 5000 --min-counts 500 --max-pct-mito 10 \
--expected-doublet-rate 0.06 --doublet-threshold auto \
--scrublet-n-prin-comps 30 --seed 0 --reference 'GRCh38, GENCODE 44' \
--context 'human PBMC, IFN-beta vs control, Kang 2018' --outdir results/2026-10-27_qc-fixed
# Demo (only when the user asks for one)
python scripts/sc_qc.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_qc.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_qc.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).