Agent Skill
Single-cell RNA-seq QC (Anthropic)
Runs quality control on .h5ad or 10x .h5 single-cell data: computes QC metrics, filters outlier cells by median absolute deviation, and plots before and after.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkInstall
Commands are pinned to commit 0e0fcac, the version we read, wherever the install method supports it.
npx skills
npx skills add anthropics/knowledge-work-plugins@0e0fcacddcc892eb92a1b7873ff9d68159c47571 --skill single-cell-rna-qc -a claude-codeCopies the skill into .claude/skills/ in this project, pinned to the reviewed commit.
Plugin marketplace
/plugin marketplace add anthropics/knowledge-work-plugins
/plugin install bio-research@knowledge-work-pluginsRun inside Claude Code. Installs the whole bio-research plugin from its default branch, not the pinned commit, including its MCP connectors such as PubMed, bioRxiv and ChEMBL.
npx skills
npx skills add anthropics/knowledge-work-plugins@0e0fcacddcc892eb92a1b7873ff9d68159c47571 --skill single-cell-rna-qc -a codexInstalls to .agents/skills/, which Codex scans from the working directory up to the repo root.
npx skills
npx skills add anthropics/knowledge-work-plugins@0e0fcacddcc892eb92a1b7873ff9d68159c47571 --skill single-cell-rna-qc -a cursorInstalls to .agents/skills/, one of the folders Cursor reads skills from.
gh skill
gh skill install anthropics/knowledge-work-plugins bio-research/skills/single-cell-rna-qc --pin 0e0fcacddcc892eb92a1b7873ff9d68159c47571 --agent github-copilotNeeds GitHub CLI 2.90.0 or later. Use --scope user to install for every repository.
npx skills
npx skills add anthropics/knowledge-work-plugins@0e0fcacddcc892eb92a1b7873ff9d68159c47571 --skill single-cell-rna-qcPinned to the commit we reviewed. The CLI asks which agents to install for; add -g to install for your user instead of this project.
What it does
From Anthropic’s bio-research plugin. By default the agent runs one script, scripts/qc_analysis.py, on a .h5ad file or a 10x Genomics Cell Ranger .h5 file: it loads the data, calculates count depth, genes per cell and the share of mitochondrial, ribosomal and haemoglobin reads, flags outlier cells by median absolute deviation (5 MADs for counts and genes, 3 for mitochondrial share, plus a hard 8% mitochondrial cut-off), drops genes seen in fewer than 20 cells, and writes before, threshold and after plots with a filtered and an annotated copy of the data. When the user wants something non-standard, such as a different mitochondrial limit for neurons, it imports the functions in qc_core.py and qc_plotting.py instead. references/scverse_qc_guidelines.md explains each metric, why MAD beats fixed cut-offs and when to loosen or tighten them.
When to use it
The first pass on a new single-cell RNA-seq dataset, before normalisation and clustering, when you want filtering you can defend in a methods section. Its defaults are deliberately permissive so rare populations survive, every threshold is a command-line flag, and the plots make the agent’s choices visible, which is what a reviewer will ask about. The species flags (mt- for mouse, MT- for human) cover the common annotation mistake.
When to skip it
It covers QC only: no ambient RNA correction, doublet detection, normalisation or clustering, which the SKILL.md lists as next steps for other tools. For the whole analysis in one skill, use Scanpy. The script accepts only .h5ad and 10x .h5 and exits on any other extension, so Seurat .rds objects or loom files need converting first. It also expects the Python packages to be installed already, which rules out machines where you cannot add scanpy.
Try it
Run QC on data/pbmc_10k_raw_feature_bc_matrix.h5 (human PBMCs). Use the
standard MAD thresholds, show me the before and after plots, and tell me
how many cells and genes were removed at each step.
What it can touch
- Bundles scripts
- Yes
- Pre-approved tools
- None declared
- Needs
- Python 3 with anndata, scanpy, scipy, numpy and matplotlib
- Client-specific fields
- None, spec fields only
Its scripts run with your permissions, and it may have changed since the commit we read. How to check a skill.
Three Python scripts that run with your permissions. qc_analysis.py reads the input file you name and writes five files to <input>_qc_results/ (or --output-dir): three PNG plots and two .h5ad files. qc_core.py and qc_plotting.py hold the functions it imports; neither makes network calls or reads anything outside the data passed in. The scripts need the Python packages listed under requirements and do not install them. There is no allowed-tools line and no hook, so your agent asks before running each script unless you have already allowed Python.
At commit 0e0fcac the SKILL.md is 175 lines long. Alongside it:
references/(1 entry)scripts/(3 entries)LICENSE.txt
Alternatives
- Scanpy (K-Dense) for QC plus normalisation, clustering, UMAP and marker genes in one skill.
- scvi-tools, from the same plugin, for batch integration and label transfer once the data is clean.
- Jupyter notebooks if you want the QC steps kept as a notebook rather than a script run.
SKILL.md
The file exactly as published at the reviewed commit, reproduced under its Apache-2.0 licence.
---
name: single-cell-rna-qc
description: Performs quality control on single-cell RNA-seq data (.h5ad or .h5 files) using scverse best practices with MAD-based filtering and comprehensive visualizations. Use when users request QC analysis, filtering low-quality cells, assessing data quality, or following scverse/scanpy best practices for single-cell analysis.
---
# Single-Cell RNA-seq Quality Control
Automated QC workflow for single-cell RNA-seq data following scverse best practices.
## When to Use This Skill
Use when users:
- Request quality control or QC on single-cell RNA-seq data
- Want to filter low-quality cells or assess data quality
- Need QC visualizations or metrics
- Ask to follow scverse/scanpy best practices
- Request MAD-based filtering or outlier detection
**Supported input formats:**
- `.h5ad` files (AnnData format from scanpy/Python workflows)
- `.h5` files (10X Genomics Cell Ranger output)
**Default recommendation**: Use Approach 1 (complete pipeline) unless the user has specific custom requirements or explicitly requests non-standard filtering logic.
## Approach 1: Complete QC Pipeline (Recommended for Standard Workflows)
For standard QC following scverse best practices, use the convenience script `scripts/qc_analysis.py`:
```bash
python3 scripts/qc_analysis.py input.h5ad
# or for 10X Genomics .h5 files:
python3 scripts/qc_analysis.py raw_feature_bc_matrix.h5
```
The script automatically detects the file format and loads it appropriately.
**When to use this approach:**
- Standard QC workflow with adjustable thresholds (all cells filtered the same way)
- Batch processing multiple datasets
- Quick exploratory analysis
- User wants the "just works" solution
**Requirements:** anndata, scanpy, scipy, matplotlib, seaborn, numpy
**Parameters:**
Customize filtering thresholds and gene patterns using command-line parameters:
- `--output-dir` - Output directory
- `--mad-counts`, `--mad-genes`, `--mad-mt` - MAD thresholds for counts/genes/MT%
- `--mt-threshold` - Hard mitochondrial % cutoff
- `--min-cells` - Gene filtering threshold
- `--mt-pattern`, `--ribo-pattern`, `--hb-pattern` - Gene name patterns for different species
Use `--help` to see current default values.
**Outputs:**
All files are saved to `<input_basename>_qc_results/` directory by default (or to the directory specified by `--output-dir`):
- `qc_metrics_before_filtering.png` - Pre-filtering visualizations
- `qc_filtering_thresholds.png` - MAD-based threshold overlays
- `qc_metrics_after_filtering.png` - Post-filtering quality metrics
- `<input_basename>_filtered.h5ad` - Clean, filtered dataset ready for downstream analysis
- `<input_basename>_with_qc.h5ad` - Original data with QC annotations preserved
If copying outputs for user access, copy individual files (not the entire directory) so users can preview them directly.
### Workflow Steps
The script performs the following steps:
1. **Calculate QC metrics** - Count depth, gene detection, mitochondrial/ribosomal/hemoglobin content
2. **Apply MAD-based filtering** - Permissive outlier detection using MAD thresholds for counts/genes/MT%
3. **Filter genes** - Remove genes detected in few cells
4. **Generate visualizations** - Comprehensive before/after plots with threshold overlays
## Approach 2: Modular Building Blocks (For Custom Workflows)
For custom analysis workflows or non-standard requirements, use the modular utility functions from `scripts/qc_core.py` and `scripts/qc_plotting.py`:
```python
# Run from scripts/ directory, or add scripts/ to sys.path if needed
import anndata as ad
from qc_core import calculate_qc_metrics, detect_outliers_mad, filter_cells
from qc_plotting import plot_qc_distributions # Only if visualization needed
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
# ... custom analysis logic here
```
**When to use this approach:**
- Different workflow needed (skip steps, change order, apply different thresholds to subsets)
- Conditional logic (e.g., filter neurons differently than other cells)
- Partial execution (only metrics/visualization, no filtering)
- Integration with other analysis steps in a larger pipeline
- Custom filtering criteria beyond what command-line params support
**Available utility functions:**
From `qc_core.py` (core QC operations):
- `calculate_qc_metrics(adata, mt_pattern, ribo_pattern, hb_pattern, inplace=True)` - Calculate QC metrics and annotate adata
- `detect_outliers_mad(adata, metric, n_mads, verbose=True)` - MAD-based outlier detection, returns boolean mask
- `apply_hard_threshold(adata, metric, threshold, operator='>', verbose=True)` - Apply hard cutoffs, returns boolean mask
- `filter_cells(adata, mask, inplace=False)` - Apply boolean mask to filter cells
- `filter_genes(adata, min_cells=20, min_counts=None, inplace=True)` - Filter genes by detection
- `print_qc_summary(adata, label='')` - Print summary statistics
From `qc_plotting.py` (visualization):
- `plot_qc_distributions(adata, output_path, title)` - Generate comprehensive QC plots
- `plot_filtering_thresholds(adata, outlier_masks, thresholds, output_path)` - Visualize filtering thresholds
- `plot_qc_after_filtering(adata, output_path)` - Generate post-filtering plots
**Example custom workflows:**
**Example 1: Only calculate metrics and visualize, don't filter yet**
```python
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
plot_qc_distributions(adata, 'qc_before.png', title='Initial QC')
print_qc_summary(adata, label='Before filtering')
```
**Example 2: Apply only MT% filtering, keep other metrics permissive**
```python
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
# Only filter high MT% cells
high_mt = apply_hard_threshold(adata, 'pct_counts_mt', 10, operator='>')
adata_filtered = filter_cells(adata, ~high_mt)
adata_filtered.write('filtered.h5ad')
```
**Example 3: Different thresholds for different subsets**
```python
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
# Apply type-specific QC (assumes cell_type metadata exists)
neurons = adata.obs['cell_type'] == 'neuron'
other_cells = ~neurons
# Neurons tolerate higher MT%, other cells use stricter threshold
neuron_qc = apply_hard_threshold(adata[neurons], 'pct_counts_mt', 15, operator='>')
other_qc = apply_hard_threshold(adata[other_cells], 'pct_counts_mt', 8, operator='>')
```
## Best Practices
1. **Be permissive with filtering** - Default thresholds intentionally retain most cells to avoid losing rare populations
2. **Inspect visualizations** - Always review before/after plots to ensure filtering makes biological sense
3. **Consider dataset-specific factors** - Some tissues naturally have higher mitochondrial content (e.g., neurons, cardiomyocytes)
4. **Check gene annotations** - Mitochondrial gene prefixes vary by species (mt- for mouse, MT- for human)
5. **Iterate if needed** - QC parameters may need adjustment based on the specific experiment or tissue type
## Reference Materials
For detailed QC methodology, parameter rationale, and troubleshooting guidance, see `references/scverse_qc_guidelines.md`. This reference provides:
- Detailed explanations of each QC metric and why it matters
- Rationale for MAD-based thresholds and why they're better than fixed cutoffs
- Guidelines for interpreting QC visualizations (histograms, violin plots, scatter plots)
- Species-specific considerations for gene annotations
- When and how to adjust filtering parameters
- Advanced QC considerations (ambient RNA correction, doublet detection)
Load this reference when users need deeper understanding of the methodology or when troubleshooting QC issues.
## Next Steps After QC
Typical downstream analysis steps:
- Ambient RNA correction (SoupX, CellBender)
- Doublet detection (scDblFinder)
- Normalization (log-normalize, scran)
- Feature selection and dimensionality reduction
- Clustering and cell type annotationRelated skills
Scanpy single-cell analysis (K-Dense)
Runs single-cell RNA-seq analysis with Scanpy: QC, normalisation, clustering, UMAP and marker genes, through bundled scripts or step by step.
scvi-tools single-cell deep learning (Anthropic)
Picks the scvi-tools model that fits your single-cell data (scVI, scANVI, totalVI and others), prepares raw counts, trains it, then clusters and runs DE.
Jupyter notebooks (OpenAI, deprecated repo)
OpenAI's skill that creates and edits .ipynb notebooks from bundled experiment and tutorial templates using a helper script. The source repo is deprecated.
Guides and recipes that use Single-cell RNA-seq QC (Anthropic)
- Clean and analyse a messy spreadsheet with AI
Clean a messy spreadsheet with ChatGPT or Claude without losing rows: profile it, agree the rules, keep a cleaning log and reconcile totals before any chart.