Standard single-cell RNA-seq analysis pipeline — QC, normalization, dimensionality reduction, clustering, differential expression, and visualization.
Scanpy is the standard Python toolkit for scRNA-seq analysis built on AnnData. This skill provides two CLI scripts plus comprehensive reference docs covering the full workflow: load data → QC → normalize → select features → PCA → neighborhood graph → UMAP/t-SNE → cluster (Leiden) → find marker genes → annotate cell types → save.
cd scanpy
python3 -m venv .venv && source .venv/bin/activate && pip install scanpy -qNone. Pure local library.
python3 scripts/qc_analysis.py input_data.h5ad --mt-threshold 5 --min-genes 200Produces qc_filtered.h5ad with filtered cells and genes, plus QC diagnostic plots (unless --skip-plots).
usage: qc_analysis.py [-h] [--output OUTPUT] [--mt-threshold MT_THRESHOLD]
[--min-genes MIN_GENES] [--min-cells MIN_CELLS]
[--skip-plots]
input
positional arguments:
input Input file (h5ad, 10X mtx, csv, etc.)
optional arguments:
--output OUTPUT Output file name (default: qc_filtered.h5ad)
--mt-threshold Max mitochondrial percentage (default: 5)
--min-genes Min genes per cell (default: 200)
--min-cells Min cells per gene (default: 3)
--skip-plots Skip generating QC plots
| Script | Purpose |
|---|---|
qc_analysis.py |
Quality control: calculates metrics, generates diagnostic plots, filters low-quality cells/genes |
demo.py |
Placeholder for basic workflow demonstration (returns scanpy version info) |
| Flag | Description | Default |
|---|---|---|
input |
Input file: .h5ad, 10X .mtx, .csv, etc. |
required |
--output |
Output filtered file path | qc_filtered.h5ad |
--mt-threshold |
Max mitochondrial gene % | 5 |
--min-genes |
Min genes per cell | 200 |
--min-cells |
Min cells per gene | 3 |
--skip-plots |
Skip generating QC plots | false |
scanpy(includes anndata, numpy, scipy, matplotlib, pandas, seaborn as transitive deps)
demo.py --format json: ✅ Returns clean JSON (scanpy imported successfully)qc_analysis.py --help: ✅ All 5 flags documented with defaults- Agno agent (Claude Haiku 4.5 via OpenRouter): ✅ Agent loaded instructions, ran
qc_analysis.py --help, described the 9-step standard workflow (load → QC → normalize → features → PCA → UMAP → cluster → markers → annotate), both scripts' roles, and QC parameters
Standard scRNA-seq workflow: load data (10X/h5ad/CSV) → QC (filter low-quality cells by gene count, total counts, mitochondrial %) → normalize (10K counts/cell, log-transform) → feature selection (~2K HVGs) → PCA → neighborhood graph → UMAP/t-SNE → Leiden clustering → marker gene identification → cell type annotation → save. The qc_analysis.py script automates the QC step with configurable thresholds (mt-threshold 5%, min-genes 200, min-cells 3) and diagnostic plots.
references/standard_workflow.md— complete Scanpy workflow code walkthroughreferences/api_reference.md— key function signatures and parametersreferences/plotting_guide.md— visualization recipes
- Fixed
skill_nameundefined bug indemo.py(replaced with"scanpy") - Removed stray
__pycache__/ qc_analysis.pyunchanged (200 lines, already functional)