/scrnaseq-best-practices:scrnaseq-analysisfrom scRNA-seq best practices
Gold-standard, statistically sound workflow for single-cell RNA-seq analysis, from loading counts through QC, normalisation, clustering, integration and annotation to pseudobulk differential expression, in Python (scanpy/scverse) or R (Seurat, Bioconductor). Use this skill whenever the user mentions scRNA-seq, snRNA-seq, 10x Genomics, Cell Ranger, AnnData, Seurat, Scanpy, SingleCellExperiment, h5ad, UMAP, Leiden clustering, cell type annotation, doublets, ambient RNA, batch correction/Harmony/scVI, marker genes, or differential expression between conditions in single-cell data, even if they only ask for one step (e.g. "find DE genes between treated and control cells" or "annotate these clusters"). Also use it to review or critique an existing single-cell analysis plan or script.
Ships in scRNA-seq best practices. 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.
This skill guides an agent through a single-cell RNA-seq analysis up to and including differential expression. It is language agnostic: every stage has Python (scanpy/scverse) and R (Seurat v5+, Bioconductor/OSCA) routes. The priorities, in order, are statistical validity, reproducibility, and clarity of evidence. Speed and prettiness come last.
The reasoning and the citations live in references/. Read the stage file before doing
that stage; it is short and it will stop you from making the standard mistakes.
references/00-design-and-reproducibility.md. Settle the question,
the unit of replication, confounding, and the environment before touching data. Copy
assets/decision_log_template.md into the project and fill it as you go.assets/report_template.md. Every number in the report traces to a
parameter in the decision log.| # | Stage | Default | Reference |
|---|---|---|---|
| 0 | Design, environment, conventions | Sample is the replicate; pinned env; explicit params | references/00-design-and-reproducibility.md |
| 1 | Loading | Per sample, Ensembl IDs, sample sheet joined, raw matrix kept | references/01-loading.md |
| 2 | Cell calling, ambient RNA, QC, doublets | Per-sample MAD thresholds (5 MADs; mito 3 MADs and > 8%), scDblFinder/Scrublet with platform rate; scores kept, predicted doublets and doublet clusters removed after inspection | references/02-qc-filtering.md |
| 3 | Normalisation, HVGs, scaling | Shifted log at median depth; 2000 HVGs per batch on counts; scale with clip 10 or no scaling; no regression by default | references/03-normalisation-features-scaling.md |
| 4 | PCA, graph, clustering, embedding | 50 PCs computed, 30 to 50 used; k 15 to 20; Leiden at several resolutions; UMAP for display only | references/04-dimred-clustering.md |
| 5 | Integration | Only if a batch effect is seen; Harmony for simple designs, scVI/scANVI for complex; score with scib-metrics; embedding never used for DE | references/05-integration.md |
| 6 | Annotation and markers | Reference tool + canonical markers + manual curation on clusters; hierarchy; Cell Ontology; marker p-values rank only | references/06-annotation.md |
| 7 | Differential expression | Pseudobulk (sum counts per sample x cell type) with edgeR QL / DESeq2 / limma-voom; >= 3 replicates; sanity checks for ambient, sex, stress genes | references/07-differential-expression.md |
Stages 2 (cell calling, ambient, doublets) and the per-batch HVG step in 3 are the ones most often skipped in ad hoc analyses; they are not optional here.
Tool versions and API changes checked on 2026-11-11: references/tool-versions.md.
| Decision | How to decide | Where |
|---|---|---|
| Cells or nuclei; platform | From the user / sample sheet | 00, 01, 02 |
| Re-call cells from the raw matrix? | Low-RNA cell types expected, no clean knee, implausible cell number | 02 |
| Ambient correction? | Haemoglobin/lineage markers everywhere, nuclei, marker-driven questions | 02 |
| Mito threshold | Tissue (Osorio and Cai 2021); nuclei near zero | 02 |
| Normalisation | Shifted log by default; Pearson residuals/SCTransform v2 when rare cells or depth effects matter | 03 |
| Regress covariates? | No by default; cell cycle only if it drives clustering and is not the biology | 03 |
| Number of PCs | 30 to 50; never from the elbow alone | 04 |
| Resolution | Markers + stability (clustree, bootstrapped Jaccard) + scSHC if needed | 04 |
| Integrate? Which method? Batch key? | Unintegrated plots and crosstabs; design complexity; scib-metrics | 05 |
| Annotation level for DE | From the biological question | 06, 07 |
| DE method and design | Replicates per group; paired or not; covariates from pseudobulk PCA | 07 |
| Fewer than 3 replicates | n = 2 minimal design, say so; n = 1 descriptive only | 07 |
All paths in this skill are relative to the skill's own folder, ${CLAUDE_SKILL_DIR} (shown
as the skill's base directory when it loads). Copy templates into the project rather than
editing them in place, and when a template needs the helper scripts' location (the R
template's SKILL_SCRIPTS), set it to ${CLAUDE_SKILL_DIR}/scripts/R resolved to an
absolute path.
scripts/python/qc_utils.py: per-sample MAD outlier flags, QC summary table, platform
doublet rate. No scanpy dependency; has a self-test (python qc_utils.py).scripts/R/qc_utils.R: the same in base R, on a metadata data frame ([email protected] or
as.data.frame(colData(sce))).scripts/python/pseudobulk_pydeseq2.py: pseudobulk with decoupler 2.x and PyDESeq2,
one cell type at a time, with replicate checks and LFC shrinkage. CLI and importable.scripts/R/pseudobulk_edger.R: pseudobulk with scuttle and edgeR 4 quasi-likelihood,
per cell type, with replicate checks, glmTreat option and ambient/sex/stress gene flags.
CLI and sourceable.scripts/python/workflow_template.py and scripts/R/workflow_template_seurat.R:
end-to-end templates for stages 1 to 7 with CHECKPOINT comments. Copy, fill the
PARAMETERS block, run stage by stage. They are templates, not pipelines: the checkpoints
need a human or an agent reading plots.assets/decision_log_template.md: the record of every threshold and choice.assets/report_template.md: the structure of the final write-up.Bioconductor (SingleCellExperiment) code for each stage is in the reference files; the
R template is Seurat-based because that is the more common entry point, and the two
interoperate through as.SingleCellExperiment and anndataR.
Python (scanpy), the spine of stages 2 to 6, parameters explicit:
sc.pp.calculate_qc_metrics(a, qc_vars=["mt","ribo","hb"], percent_top=[20], log1p=True, inplace=True)
sc.pp.scrublet(a, expected_doublet_rate=0.008 * a.n_obs / 1000) # per sample
adata = ad.concat(adatas, label="sample", index_unique="-", join="inner", merge="same")
sc.pp.highly_variable_genes(adata, flavor="seurat_v3", n_top_genes=2000, layer="counts", batch_key="sample")
sc.pp.normalize_total(adata, target_sum=None); sc.pp.log1p(adata); adata.layers["lognorm"] = adata.X.copy()
sc.tl.pca(adata, n_comps=50); sc.pp.neighbors(adata, n_neighbors=15, n_pcs=30)
sc.tl.leiden(adata, resolution=1.0, flavor="igraph", n_iterations=2, key_added="leiden_r1.0")
sc.tl.umap(adata, min_dist=0.5)
sc.tl.rank_genes_groups(adata, "leiden_r1.0", method="wilcoxon", layer="lognorm", use_raw=False)
R (Seurat v5+):
obj <- merge(objs[[1]], objs[-1], add.cell.ids = samples) # per-sample layers
obj <- NormalizeData(obj) |> FindVariableFeatures(nfeatures = 2000) |> ScaleData(scale.max = 10) |> RunPCA(npcs = 50)
obj <- IntegrateLayers(obj, method = HarmonyIntegration, orig.reduction = "pca", new.reduction = "harmony") # only if needed
obj <- FindNeighbors(obj, reduction = "harmony", dims = 1:30) |> FindClusters(algorithm = 4, resolution = 1) |> RunUMAP(reduction = "harmony", dims = 1:30)
obj <- JoinLayers(obj); mk <- FindAllMarkers(obj, test.use = "wilcox", only.pos = TRUE)
Pseudobulk DE, either language: scripts/python/pseudobulk_pydeseq2.py or
scripts/R/pseudobulk_edger.R (sum counts per sample x cell type; filter pseudobulks
with < 10 cells; filterByExpr per cell type; TMM; ~ covariates + condition;
BH per cell type; shrink LFCs for ranking).
Per-stage citations with URLs are at the end of each reference file.
assets/cell_cycle_genes_tirosh2016.csv (opens in a new tab)assets/decision_log_template.md (opens in a new tab)assets/report_template.md (opens in a new tab)references/00-design-and-reproducibility.md (opens in a new tab)references/01-loading.md (opens in a new tab)references/02-qc-filtering.md (opens in a new tab)references/03-normalisation-features-scaling.md (opens in a new tab)references/04-dimred-clustering.md (opens in a new tab)references/05-integration.md (opens in a new tab)references/06-annotation.md (opens in a new tab)references/07-differential-expression.md (opens in a new tab)references/tool-versions.md (opens in a new tab)scripts/R/pseudobulk_edger.R (opens in a new tab)scripts/R/qc_utils.R (opens in a new tab)scripts/R/workflow_template_seurat.R (opens in a new tab)scripts/python/pseudobulk_pydeseq2.py (opens in a new tab)scripts/python/qc_utils.py (opens in a new tab)scripts/python/workflow_template.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 franciscrickinstitute/cdc26-proj6-gamill-boot --plugin scrnaseq-best-practices