mims-harvard/tooluniverse/tooluniverse-single-cell
- community
Checking that the SKILL.md file is still in the repository.
Single-cell RNA-seq analysis with scanpy/anndata — h5ad data loading, scRNA-seq quality control and QC gating (n_genes_by_counts, total_counts, mitochondrial percent / pct_counts_mt, pct_counts_ribo, doublet detection with Scrublet/scDblFinder, ambient RNA / SoupX awareness, empty-droplet filtering, MAD-based thresholds), normalization, dimensionality reduction (PCA, UMAP, t-SNE), clustering (Leiden, Louvain), marker gene identification, cell-type annotation, pseudotime/trajectory analysis. Use for any scRNA-seq workflow, including deciding which cells to filter, flag, or investigate before downstream analysis.
Install
npx vskill@latest install mims-harvard/tooluniverse/tooluniverse-single-cellSKILL.md
Single-Cell Genomics and Expression Matrix Analysis
RULE ZERO — Check for pre-computed results FIRST
Before following any instruction below, scan the data folder for:
*_executed.ipynb→ read withtu run read_executed_notebook '{"data_folder":"<path>","search":"<keyword>"}'and cite its cell outputs as the authoritative answer- Pre-computed result files (CSV/TSV with names like
*results*,*deseq*,*enrich*,*stats*,*_simplified.csv) → read directly and report the requested value - Canonical analysis scripts (
analysis.R,run_*.py,find_*.R,*.Rmd) → execute as-is and read the output
Only follow this skill's re-analysis recipe below if none of the above exist. Re-running from raw data produces different numbers than the published answer and is much slower (often 5-10× turn count).
Comprehensive single-cell RNA-seq analysis and expression matrix processing using scanpy, anndata, scipy, and ToolUniverse.
LOOK UP, DON'T GUESS
When uncertain about any scientific fact, SEARCH databases first (PubMed, UniProt, ChEMBL, ClinVar, etc.) rather than reasoning from memory. A database-verified answer is always more reliable than a guess.
When to Use This Skill
Apply when users:
- Have scRNA-seq data (h5ad, 10X, CSV count matrices) and want analysis
- Need scRNA-seq quality control / QC gating: deciding cell filters by
mito % (pct_counts_mt), gene/UMI counts, doublets, ambient RNA, empty droplets
- Ask about cell type identification, clustering, or annotation
- Need differential expression analysis by cell type or condition
- Want gene-expression correlation analysis (e.g., gene length vs expression by cell type)
- Ask about PCA, UMAP, t-SNE for expression data
- Need Leiden/Louvain clustering on expression matrices
- Want statistical comparisons between cell types (t-test, ANOVA, fold change)
- Ask about marker genes, batch correction, trajectory, or cell-cell communication
NOT for (use other skills instead):
- Bulk RNA-seq DESeq2 only ->
tooluniverse-rnaseq-deseq2 - Gene enrichment only ->
tooluniverse-gene-enrichment - VCF/variant analysis ->
tooluniverse-variant-analysis - Deep-learning integration/batch correction (scVI, scANVI, totalVI, PeakVI, MultiVI, DestVI, veloVI) ->
tooluniverse-scvi-tools
Core Principles
- Data-first - Load, inspect, validate before analysis
- AnnData-centric - All data flows through anndata objects
- Cell type awareness - Per-cell-type subsetting when needed
- Statistical rigor - Normalization, multiple testing correction, effect sizes
- Question-driven - Parse what the user is actually asking
Required Packages
Install: pip install scanpy anndata leidenalg umap-learn harmonypy gseapy pandas numpy scipy scikit-learn statsmodels
Workflow Decision Tree
Data format handling:
- h5ad ->
sc.read_h5ad() - 10X ->
sc.read_10x_mtx()orsc.read_10x_h5() - CSV/TSV ->
pd.read_csv()-> Convert to AnnData (check orientation!)
Data Loading
AnnData expects: cells/samples as rows (obs), genes as columns (var)
Quality Control and QC Gating (do this BEFORE downstream analysis)
QC gating decides which cells and genes are real before normalization, clustering, or DE. Skipping or rushing it propagates silently: doublets become fake "intermediate" states, ambient RNA smears markers across clusters, and empty droplets inflate cell counts. Never report a filtered cell count without the gates applied, and never report cutoffs you did not actually run.
HONEST EXECUTION: QC runs scanpy/AnnData via Bash/Python. If scanpy is not installed, do NOT fabricate metrics — print the install plan and stop: python scripts/scrna_qc.py --install-plan (exits 0, lists what is missing, suggests pip install scanpy anndata scrublet).
Per-cell QC metrics (what to compute)
Key metrics in adata.obs: n_genes_by_counts, total_counts, pct_counts_mt, pct_counts_ribo, pct_counts_hb.
WHY each metric flags a problem (reason from biology, not magic numbers)
- High `pct_counts_mt` -> dying / stressed cell. A ruptured membrane lets
cytoplasmic mRNA leak out while mito transcripts stay trapped, enriching the captured RNA for mito. Cutoff is tissue-dependent (cardiomyocytes/hepatocytes are mito-rich at baseline — a blanket 10% would discard healthy cells).
- Low `n_genes_by_counts` / `total_counts` -> empty droplet or debris
(only ambient RNA captured; few genes, low depth).
- Very high counts/genes -> doublet (two transcriptomes ~double depth and
diversity) — but high count alone is weak; use a doublet caller (below).
- High `pct_counts_hb` -> RBC/blood contamination in solid tissue.
Choosing thresholds — distribution-aware (MAD), not hardcoded
Hardcoded cutoffs (mt<5%, n_genes<2500) are a starting point only; they break on mito-rich tissues and on shallow vs deep libraries. Prefer a MAD-based rule (robust to the very outliers you are removing): flag cells
nmadsmedian-absolute-deviations from the median. Usenmads=5on
log1p counts/genes (both tails), nmads=3 upper-only on pct_counts_mt, and pair mito with a biological ceiling so a uniformly degraded sample doesn't pass. Always visualize distributions first (violin + total_counts vs pct_counts_mt scatter — dying cells sit in the low-count/high-mito corner).
Run the helper (computes metrics + MAD gating, reports per-step removals):
Doublets, ambient RNA, empty droplets (per-cell metrics miss these)
- Doublets: Scrublet (
sc.pp.scrublet, scanpy >=1.10) or scDblFinder (R).
Run per sample before merging; flag-cluster-drop (doublets form bridge clusters). expected_doublet_rate ~0.8%/1,000 cells recovered (10x).
- Ambient RNA: cell-free "soup" mRNA in every droplet — a count-correction
step (SoupX / DecontX, R), NOT a cell filter. Per-cell QC cannot detect it; suspect it when markers look implausibly ubiquitous.
- Empty droplets: upstream of per-cell QC. CellRanger's filtered matrix
already applies an EmptyDrops-style call; with only the raw matrix, run EmptyDrops (DropletUtils, R) or a barcode-rank knee before per-cell QC.
QC Interpretation Table (metric -> concern -> action)
| QC metric | Direction | Typical concern | Suggested action | |
|---|---|---|---|---|
pct_counts_mt | high | Dying / stressed cell (membrane rupture) | Filter (MAD upper + tissue-aware ceiling; raise ceiling for mito-rich tissue) | |
n_genes_by_counts | very low | Empty droplet / debris | Filter (min_genes ~200 + low-tail MAD) | |
total_counts | very low | Shallow / failed capture | Filter (low-tail MAD; check barcode-rank knee) | |
n_genes_by_counts / total_counts | very high | Doublet (two cells in one droplet) | Flag, run Scrublet/scDblFinder, then drop — don't hard-cap on counts alone | |
predicted_doublet (Scrublet) | True | Multiplet | Filter per sample; cluster-then-drop if unsure | |
pct_counts_hb | high | RBC / blood contamination | Filter in non-blood tissue; investigate in blood | |
pct_counts_ribo | very high/low | Low-complexity / stressed, or cell-type signal | Flag / investigate (ribo is cell-type-specific; rarely a hard filter) | |
| markers ubiquitous across clusters | — | Ambient RNA contamination | Investigate — run SoupX/DecontX, do not silently proceed | |
| many cells, low median counts | — | Empty droplets not removed | Investigate — apply EmptyDrops / knee, re-filter |
Full reasoning, MAD code, Scrublet/SoupX/EmptyDrops recipes, and order of operations: references/scrna_qc.md. Inline pipeline QC: references/scanpy_workflow.md Phase 2.
Complete Pipeline (Quick Reference)
Differential Expression Decision Tree
Statistical Tests (Quick Reference)
Batch Correction (Harmony)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/tooluniverse-single-cell/SKILL.md
Popularity
- Repository stars
- 1,307
- Repository forks
- 200
- 7-day trend score
- 36
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 2 May 2026, 5 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/mims-harvard/tooluniverse/tooluniverse-single-cell)