/scrnaseq-custom:scrnaseq-analysis-customfrom scRNA-seq custom workflow
Opinionated scverse (Python) workflow for scRNA-seq and snRNA-seq count matrices that follows Ferran Cardoso's approach (PhD thesis; Qin & Cardoso Rodriguez et al., Cell 2023): multi-format loading and metadata curation, per-sample quantile/MAD QC with flag-then-filter, light-touch log normalisation with cell-cycle regression, PCA to 50-100 components with technical-artefact diagnostics, ONE kNN graph shared by Leiden clustering and PHATE visualisation, clustree-guided cluster merging, batch assessment with integration only when needed, cell typing with the Allen Institute MapMyCells resource whenever a matching taxonomy exists (e.g. SEA-AD MTG, Whole Human/Mouse Brain), backed by markers and CellTypist (optional scANVI mapping to a pathology-aware reference), and pseudobulk differential expression with a metadata-aware design. Use for any request to load, QC, normalise, embed, cluster, annotate or run DE on single-cell or single-nucleus RNA-seq data (e.g. Alzheimer's disease brain datasets). Stops after differential expression; cross-dataset integration and differential abundance are flagged as future steps.
Trending skills
7-day visitors to each skill page
Ships in scRNA-seq custom workflow. 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 from a count matrix to differential expression (DE). It stops there. Cross-dataset integration, differential abundance and a formal cross-dataset comparison framework are future steps; the workflow is designed so they can be bolted on (raw counts kept in a layer, one reusable kNN graph, sample-level metadata curated early).
When guidance conflicts, resolve it in this order:
SKILLS_custom.md).Python/scverse is used wherever possible. R is only mentioned where no credible Python equivalent exists (and then as an optional, clearly marked alternative).
adata.uns["pipeline"].layers["counts"] is never modified. Normalised and scaled
matrices are derived views. DE on conditions always goes back to counts (pseudobulk).adata.uns["pipeline"][<step>] (one JSON string per step; read with json.loads) and to
outdir/tables/<step>/summary.json.# environment (conda/mamba); CellBender lives in its own env, see references/01_loading.md
mamba env create -f "${CLAUDE_SKILL_DIR}/scripts/environment.yml"
# config: copy the template, edit paths/keys/thresholds
cp "${CLAUDE_SKILL_DIR}/scripts/config_template.yaml" config.yaml
# sample sheet: one row per sample (dataset x library), see assets/sample_sheet_template.csv
All scripts/, references/ and assets/ paths in this file are relative to this skill's
directory (${CLAUDE_SKILL_DIR}), not to the user's working directory. Run the step scripts
from the user's project as python "${CLAUDE_SKILL_DIR}/scripts/0X_*.py" --config config.yaml;
relative paths inside config.yaml (e.g. assets/markers_human_brain.csv) are looked up in
the working directory, then next to the config, then in the skill directory.
Conventions used by all scripts (scripts/0X_*.py --config config.yaml [--input] [--output]):
| Item | Convention |
|---|---|
| Checkpoints | outdir/checkpoints/01_loaded.h5ad … 07_annotated.h5ad |
| Figures / tables | outdir/figures/<step>/, outdir/tables/<step>/ |
| Raw counts | adata.layers["counts"] (CSR, integer-valued) |
| Log-normalised | adata.X and adata.layers["lognorm"] (1e4 target, log1p) |
| Scaled HVGs | adata.obsm["X_hvg_scaled"], genes in adata.uns["hvg_scaled_genes"] |
| Representations | obsm["X_pca"], optionally X_pca_harmony / X_scVI; X_phate, X_umap |
| Graph | obsp["connectivities"], obsp["distances"] from sc.pp.neighbors |
| Clusters | obs["leiden_r<res>"] per resolution (leiden_r1, leiden_r0.6, …), obs["cluster"] after merging |
| Labels | obs["cell_class"], obs["cell_type"], obs["cell_state"] (curated) |
| Sample metadata | obs[sample_key] plus donor, condition, sex, age, batch, study, region, assay |
Run the steps in order. Each step lists what to do, what to inspect, what to decide, and where the details live. Read the linked reference before running a step for the first time on a new dataset.
sample_id, path, format, species, assay (sc|sn), donor, condition, sex, age, pmi, region, chemistry, batch, study, counts_layer, transpose. Condition-level
variables for AD cohorts: diagnosis, Braak stage, CERAD, cognitive status, APOE.config.yaml.scripts/01_load.py) → 01_loaded.h5adrds2py/py8rds), check that X holds integer counts, harmonise gene
identifiers (symbols + Ensembl IDs kept side by side), prefix barcodes, join metadata,
concatenate.tables/01_load/summary.json (cells and genes per sample, gene overlap across
datasets, species/assay sanity).join: inner|outer for genes across datasets; whether ambient-RNA correction
(CellBender, run upstream on raw unfiltered matrices; recommended for brain snRNA-seq)
is available or needed.scripts/02_qc.py) → 02_qc.h5adsc.pp.calculate_qc_metrics with mt/ribo/hb flags), per-sample
thresholds from three complementary rules (absolute floors, per-sample upper quantiles,
per-sample MAD outliers), mitochondrial cap, gene filter, Scrublet doublet scores per
sample, optional sex check (XIST vs chrY).figures/02_qc/),
per-sample threshold table, doublet score histograms.qc.apply_rules), per-sample overrides, whether to remove
doublets now (default: flag only, revisit after clustering, as in the thesis). Defaults
differ for sc vs sn (see table in Section 5).scripts/03_normalise.py) → 03_norm.h5adcounts layer → normalize_total(target_sum=1e4) + log1p (lognorm layer, also
X); HVGs with seurat_v3 on counts, batch-aware (batch_key), excluding mt/ribo/hb
(optionally sex) genes; cell-cycle scores with the thesis gene set (S/G1 vs G2M), store
cc_diff = S_score - G2M_score and cycle_state; regress out cc_diff (+ pct_counts_mt)
on the HVG matrix; scale (clip at 10) → obsm["X_hvg_scaled"].n_top_genes (2000–4000 for brain; thesis used 6000–10000 in SCT),
regress_keys (thesis default: mito + cell-cycle difference; set [] if the user wants
cell cycle kept), target_sum (fixed 1e4 for cross-dataset consistency).scripts/04_dimred_graph.py) → 04_graph.h5adn_neighbors=20 on the first n_pcs=50 PCs, Euclidean); PHATE computed from that
graph (knn_dist="precomputed_affinity"); UMAP optional.figures/04_dimred/pca_*; PHATE coloured by sample, condition, QC metrics,
cycle state, doublet score.regress_keys/HVG exclusions) or
mark for Step 6. Choose n_pcs (thesis: 48 of 50) and n_neighbors.scripts/05_cluster.py) → 05_clustered.h5adobs["cluster"].scripts/06_integrate.py) → 06_integrated.h5ad--use-rep.scripts/07_annotate.py) → 07_annotated.h5adcell_type_mapper Python package for
local/HPC runs). Pick the taxonomy that matches species and tissue: SEA-AD / Human MTG
(10x) for human cortex and AD cohorts, Whole Human Brain (Siletti et al.) for other human
regions, Whole Mouse Brain (Yao et al., CCN20230722) for mouse. Prefer hierarchical
mapping (class → subclass → supertype/cluster). Input is layers["counts"] (raw integer
counts) written to an h5ad with cells × genes and Ensembl IDs (or the gene-symbol option
the taxonomy supports); keep only cells that passed QC. Store the per-level assignments,
bootstrapping probability and correlation in obs (e.g. mmc_class, mmc_subclass,
mmc_supertype, mmc_<level>_bootstrap_prob) and the full CSV/JSON output under
tables/07_annotate/mapmycells/. Record taxonomy, algorithm and version in
adata.uns["pipeline"]["07_annotate"].Adult_Human_MTG,
Adult_Human_PrefrontalCortex, Human_AdultAged_Hippocampus; Mouse_Whole_Brain for
mouse) using our high-resolution Leiden clusters for majority voting; optional
scANVI/scArches mapping to a pathology-aware reference (SEA-AD) when a reference model or
h5ad is provided. Build a consensus table per cluster (MapMyCells majority label and
fraction, marker evidence, CellTypist label).tables/07_annotate/cluster_consensus.csv, MapMyCells bootstrap probabilities per
level and cluster (low values flag cells/clusters outside the reference), crosstab
cluster × MapMyCells label, marker dotplot/heatmap, CellTypist confidence.cluster_labels (class → subclass/type → state) written back into
config.yaml and applied to obs["cell_type"]. Default to the MapMyCells label at the
deepest level with confident, cluster-consistent assignment; markers remain the final
arbiter when they disagree, and any override must be documented. If MapMyCells was not
used, say why in the report.scripts/08_de.py) → tableslognorm (descriptive, reported with
log2FC, pct, BH-adjusted p); (b) condition DE per cell type with pseudobulk (sum of
counts per sample × cell type via decoupler) and PyDESeq2 with a design built from the
sample sheet, e.g. ~ sex + age_z + batch + condition, Wald test + LFC shrinkage, BH FDR;
pseudobulk PCA per cell type to justify the design.Values are starting points, chosen per the thesis and brain-tissue practice. Record every
deviation. sc = whole-cell scRNA-seq, sn = single-nucleus.
| Parameter | sc default | sn default | Notes |
|---|---|---|---|
qc.min_genes | 600 | 500 | thesis: 600 unique genes (organoids) |
qc.min_counts | 1200 | 1000 | thesis: 1,200–80,000 range, set per dataset |
qc.max_pct_mt | 10 | 5 | thesis organoids: 3 %; nuclei should be near 0 |
qc.quantile_high | 0.995 | 0.995 | per-sample upper cap on counts and genes |
qc.nmads | 5 | 5 | lenient; mito handled by the absolute cap |
qc.min_cells_per_gene | 4 | 4 | thesis: 4 |
doublets.expected_rate | 0.008 per 1,000 cells | same | Scrublet per sample; flag only |
norm.target_sum | 1e4 | 1e4 | fixed for cross-dataset consistency |
norm.n_top_genes | 3000 | 3000 | 2000–4000; batch-aware seurat_v3 |
norm.regress_keys | [pct_counts_mt, cc_diff] | same | [] to keep cell cycle |
pca.n_comps | 100 | 100 | inspect; thesis used 50–100 |
graph.n_pcs | 50 | 50 | thesis: 48 |
graph.n_neighbors | 20 | 20 | thesis k.param = 20 |
cluster.resolutions | 0.1,0.2,0.4,0.6,0.8,1.0,1.5 | same | thesis 0.2–0.8; brain often needs 1.0+ |
cluster.outlier_fraction | 0.01 | 0.01 | thesis: outlier clusters < 1 % |
de.min_samples_per_group | 3 | 3 | pseudobulk needs replicates |
At the end (or when stopping early) write outdir/REPORT.md with: datasets and samples;
thresholds used per sample and cells removed; normalisation and regression choices; PCA
diagnostics verdict; graph parameters; resolution ladder and merge decisions; integration
verdict (and why); MapMyCells taxonomy/algorithm/version (or why it was not used);
annotation table with evidence; DE design, contrasts and DEG counts;
open questions. Keep it factual and short; link figures and tables.
knn_dist="precomputed_affinity"
(the zero diagonal would otherwise be auto-detected as a distance matrix).mt-/Rp[sl] prefixes and title-case gene sets.target_sum, gene filters and marker sets for
every dataset so the future comparison is not confounded by preprocessing. Map every
dataset to the same MapMyCells taxonomy and version so labels are directly comparable.lognorm or scaled values, and check gene
identifier overlap with the taxonomy before trusting results (low overlap → poor mapping).
A reference label is a nearest match, not proof: disease-associated or novel states absent
from the taxonomy are forced onto the closest type, so check bootstrap probabilities and
markers.references/00_philosophy.md – the thesis/paper approach, what is kept and what changes.references/01_loading.md … 08_differential_expression.md – per-step details, code
snippets, decision rules, caveats.references/bibliography.md – citations with DOIs.assets/cell_cycle_cardoso_thesis_mouse.tsv – the thesis cell-cycle gene set (s, g2m, g1).assets/cell_cycle_tirosh2016.csv – the Tirosh/Seurat list (updated symbols), alternative.assets/markers_human_brain.csv – canonical human brain cell-type and state markers.assets/sample_sheet_template.csv – required metadata columns.scripts/environment.yml, scripts/config_template.yaml – environment and config.scripts/scrna_lib.py – shared helpers (loading, QC rules, PHATE-from-graph, stability).scripts/01_load.py … 08_de.py – one script per step; all accept --config, --input,
--output (04 also --use-rep/--skip-pca, 08 also --mode).The scanpy-only paths (loading h5ad/csv, QC rules, sex check, normalisation, HVGs, cell-cycle
scoring, regression/scaling, PCA diagnostics, kNN graph, UMAP, Leiden ladder, stability,
markers, dendrogram, marker-set scoring, consensus table, Wilcoxon markers) were exercised on
a synthetic three-sample dataset. Paths that need optional packages (PHATE from the graph,
pyclustree, Scrublet's automatic threshold, MapMyCells/cell_type_mapper, CellTypist,
scANVI mapping, Harmony/scVI,
scib-metrics, decoupler + PyDESeq2) follow the current documentation of those packages but
were not executed; they fail soft with a logged message (DE on conditions fails hard, by
design, if decoupler/PyDESeq2 are missing). The MapMyCells wrapper in 07_annotate.py
(query export with Ensembl IDs, CLI call, CSV parsing into obs["mmc_<level>"], consensus
and auto labels) was tested against a stub CLI that writes the documented output format;
the real cell_type_mapper and the Allen reference files have not been run. Run the first
dataset step by step and read the logs.
SKILLS_custom.md (opens in a new tab)assets/cell_cycle_cardoso_thesis_mouse.tsv (opens in a new tab)assets/cell_cycle_tirosh2016.csv (opens in a new tab)assets/markers_human_brain.csv (opens in a new tab)assets/sample_sheet_template.csv (opens in a new tab)references/00_philosophy.md (opens in a new tab)references/01_loading.md (opens in a new tab)references/02_qc.md (opens in a new tab)references/03_normalisation.md (opens in a new tab)references/04_dimred_graph.md (opens in a new tab)references/05_clustering.md (opens in a new tab)references/06_integration.md (opens in a new tab)references/07_annotation.md (opens in a new tab)references/08_differential_expression.md (opens in a new tab)references/bibliography.md (opens in a new tab)scripts/01_load.py (opens in a new tab)scripts/02_qc.py (opens in a new tab)scripts/03_normalise.py (opens in a new tab)scripts/04_dimred_graph.py (opens in a new tab)scripts/05_cluster.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-custom