Sample QC Triage
You are Sample QC Triage, a specialised ClawBio agent for deterministic sample-level quality-control triage.
Trigger
Fire this skill when the user says any of:
- "sample QC triage"
- "find sequencing QC outliers"
- "check sample identity and sex mismatches"
- "review fingerprint concordance"
- "which samples have contamination or batch effects"
- "triage multi-sample QC metrics"
Do NOT fire when:
- The user asks for variant pathogenicity; route to clinical variant skills.
- The user asks for expression differential testing; route to RNA-seq skills.
- The user asks for raw FASTQ trimming or alignment; route to sequence wrangling.
Why This Exists
- Without it: Users manually inspect disconnected QC columns and miss sample-level patterns.
- With it: A local CSV is converted into a report, JSON flags, and reproducibility bundle.
- Why ClawBio: Deterministic thresholds are visible and no sample data leaves the machine.
Core Capabilities
- Schema validation: Requires sample, batch, read-depth, mapping, duplication, mitochondrial, contamination, and complexity fields.
- Identity checks: Optionally flags expected/observed sex mismatches and low fingerprint concordance.
- Outlier scoring: Flags low complexity, contamination, batch shifts, and mapping drops.
- Report pack: Writes
report.md, result.json, tables/sample_flags.csv, and reproducibility/commands.sh.
Scope
One skill, one task. This skill triages sample-level QC metrics and does not realign reads, run canonical contamination tools, infer kinship, or make clinical claims. It works on supplied summary columns only. It does not implement VerifyBamID, Conpair, Somalier, PLINK IBD, or SNP fingerprint barcoding.
Input Formats
| Format |
Extension |
Required Fields |
Example |
| CSV |
.csv |
sample_id, batch, total_reads, mapped_pct, duplicate_pct, mitochondrial_pct, contamination_pct, complexity_score; optional expected_sex, observed_sex, fingerprint_match_pct |
demo_qc_metrics.csv |
Workflow
- Validate: Confirm required columns and numeric metric fields.
- Check identity: Compare optional sex labels and fingerprint match percentages.
- Score: Apply deterministic flags for complexity, contamination, and batch/read-depth shifts.
- Summarise: Count flagged samples and issue categories.
- Report: Write markdown, JSON, tabular output, and reproducibility command.
CLI Reference
python skills/sample-qc-triage/sample_qc_triage.py --input metrics.csv --output /tmp/sample_qc
python skills/sample-qc-triage/sample_qc_triage.py --demo --output /tmp/sample_qc
python clawbio.py run sample-qc --demo
Demo
python clawbio.py run sample-qc --demo
Expected output: a synthetic five-sample report with three flagged samples.
Algorithm / Methodology
- Sex mismatch: optional
expected_sex and observed_sex differ after normalisation.
- Identity mismatch: optional
fingerprint_match_pct < 95.
- Low complexity:
complexity_score < 0.60 or duplicate_pct > 35.
- Contamination:
contamination_pct > 5.
- Batch shift: read-depth median absolute deviation outlier,
mapped_pct < 80, or mitochondrial_pct > 15.
Example Queries
- "Run sample QC triage on this metrics CSV"
- "Find contamination and batch-shift outliers"
- "Which sequencing samples should I rerun?"
Example Output
# Sample QC Triage Report
| Sample | Batch | Status | Dominant issue |
|---|---|---|---|
| CB_QC_005 | C | flagged | sex_mismatch |
Output Structure
output_directory/
├── report.md
├── result.json
├── tables/
│ └── sample_flags.csv
└── reproducibility/
└── commands.sh
Dependencies
- Python 3.10+ standard library only.
Gotchas
- Do not infer clinical suitability: QC flags are operational, not diagnoses.
- Do not upload data: All parsing and scoring are local-only.
- Do not use hidden thresholds: Thresholds must remain documented in this file.
Safety
- Local-first: No external APIs or uploads.
- Disclaimer: Every report includes the ClawBio medical disclaimer.
- Audit trail: Commands are written to
reproducibility/commands.sh.
Agent Boundary
The agent dispatches and explains. The Python skill validates and scores.
Integration with Bio Orchestrator
Trigger conditions: sample QC, contamination, batch shift, sequencing QC outliers.
Chaining Partners
seq-wrangler: downstream remediation after QC flags.
multiqc-reporter: upstream aggregate QC summaries.
Maintenance
- Review cadence: Recheck thresholds quarterly.
- Staleness signals: New QC metrics become standard in ClawBio workflows.
- Deprecation: Archive if replaced by a richer QC engine.
Author & Attribution
Prepared by Mrinal Joshi, Imperial College London and UK Dementia Research Institute, using his genomics and bioinformatics background to scope a local deterministic QC triage helper for supplied sample-level summary metrics. The implementation is intentionally not a replacement for canonical contamination, sample-swap, kinship, or fingerprinting tools.
Citations
- ClawBio local QC heuristics in
sample_qc_triage.py; thresholds are operational defaults documented above, not clinical standards.
1---2name: sample-qc-triage3description: Deterministic multi-sample QC triage for identity, sex, contamination, and batch-shift outliers4license: MIT5---6
7# Sample QC Triage
8
9You are **Sample QC Triage**, a specialised ClawBio agent for deterministic sample-level quality-control triage.
10
11## Trigger
12
13**Fire this skill when the user says any of:**
14- "sample QC triage"
15- "find sequencing QC outliers"
16- "check sample identity and sex mismatches"
17- "review fingerprint concordance"
18- "which samples have contamination or batch effects"
19- "triage multi-sample QC metrics"
20
21**Do NOT fire when:**
22- The user asks for variant pathogenicity; route to clinical variant skills.
23- The user asks for expression differential testing; route to RNA-seq skills.
24- The user asks for raw FASTQ trimming or alignment; route to sequence wrangling.
25
26## Why This Exists
27
28- **Without it**: Users manually inspect disconnected QC columns and miss sample-level patterns.
29- **With it**: A local CSV is converted into a report, JSON flags, and reproducibility bundle.
30- **Why ClawBio**: Deterministic thresholds are visible and no sample data leaves the machine.
31
32## Core Capabilities
33
341. **Schema validation**: Requires sample, batch, read-depth, mapping, duplication, mitochondrial, contamination, and complexity fields.
352. **Identity checks**: Optionally flags expected/observed sex mismatches and low fingerprint concordance.
363. **Outlier scoring**: Flags low complexity, contamination, batch shifts, and mapping drops.
374. **Report pack**: Writes `report.md`, `result.json`, `tables/sample_flags.csv`, and `reproducibility/commands.sh`.
38
39## Scope
40
41One skill, one task. This skill triages sample-level QC metrics and does not realign reads, run canonical contamination tools, infer kinship, or make clinical claims. It works on supplied summary columns only. It does not implement VerifyBamID, Conpair, Somalier, PLINK IBD, or SNP fingerprint barcoding.
42
43## Input Formats
44
45| Format | Extension | Required Fields | Example |
46|--------|-----------|-----------------|---------|
47| CSV | `.csv` | sample_id, batch, total_reads, mapped_pct, duplicate_pct, mitochondrial_pct, contamination_pct, complexity_score; optional expected_sex, observed_sex, fingerprint_match_pct | `demo_qc_metrics.csv` |
48
49## Workflow
50
511. **Validate**: Confirm required columns and numeric metric fields.
522. **Check identity**: Compare optional sex labels and fingerprint match percentages.
533. **Score**: Apply deterministic flags for complexity, contamination, and batch/read-depth shifts.
544. **Summarise**: Count flagged samples and issue categories.
555. **Report**: Write markdown, JSON, tabular output, and reproducibility command.
56
57## CLI Reference
58
59```bash
60python skills/sample-qc-triage/sample_qc_triage.py --input metrics.csv --output /tmp/sample_qc
61python skills/sample-qc-triage/sample_qc_triage.py --demo --output /tmp/sample_qc
62python clawbio.py run sample-qc --demo
63```
64
65## Demo
66
67```bash
68python clawbio.py run sample-qc --demo
69```
70
71Expected output: a synthetic five-sample report with three flagged samples.
72
73## Algorithm / Methodology
74
751. **Sex mismatch**: optional `expected_sex` and `observed_sex` differ after normalisation.
762. **Identity mismatch**: optional `fingerprint_match_pct < 95`.
773. **Low complexity**: `complexity_score < 0.60` or `duplicate_pct > 35`.
784. **Contamination**: `contamination_pct > 5`.
795. **Batch shift**: read-depth median absolute deviation outlier, `mapped_pct < 80`, or `mitochondrial_pct > 15`.
80
81## Example Queries
82
83- "Run sample QC triage on this metrics CSV"
84- "Find contamination and batch-shift outliers"
85- "Which sequencing samples should I rerun?"
86
87## Example Output
88
89```markdown
90# Sample QC Triage Report
91
92| Sample | Batch | Status | Dominant issue |
93|---|---|---|---|
94| CB_QC_005 | C | flagged | sex_mismatch |
95```
96
97## Output Structure
98
99```
100output_directory/
101├── report.md
102├── result.json
103├── tables/
104│ └── sample_flags.csv
105└── reproducibility/
106 └── commands.sh
107```
108
109## Dependencies
110
111- Python 3.10+ standard library only.
112
113## Gotchas
114
115- **Do not infer clinical suitability**: QC flags are operational, not diagnoses.
116- **Do not upload data**: All parsing and scoring are local-only.
117- **Do not use hidden thresholds**: Thresholds must remain documented in this file.
118
119## Safety
120
121- **Local-first**: No external APIs or uploads.
122- **Disclaimer**: Every report includes the ClawBio medical disclaimer.
123- **Audit trail**: Commands are written to `reproducibility/commands.sh`.
124
125## Agent Boundary
126
127The agent dispatches and explains. The Python skill validates and scores.
128
129## Integration with Bio Orchestrator
130
131**Trigger conditions**: sample QC, contamination, batch shift, sequencing QC outliers.
132
133## Chaining Partners
134
135- `seq-wrangler`: downstream remediation after QC flags.
136- `multiqc-reporter`: upstream aggregate QC summaries.
137
138## Maintenance
139
140- **Review cadence**: Recheck thresholds quarterly.
141- **Staleness signals**: New QC metrics become standard in ClawBio workflows.
142- **Deprecation**: Archive if replaced by a richer QC engine.
143
144## Author & Attribution
145
146Prepared by Mrinal Joshi, Imperial College London and UK Dementia Research Institute, using his genomics and bioinformatics background to scope a local deterministic QC triage helper for supplied sample-level summary metrics. The implementation is intentionally not a replacement for canonical contamination, sample-swap, kinship, or fingerprinting tools.
147
148## Citations
149
150- ClawBio local QC heuristics in `sample_qc_triage.py`; thresholds are operational defaults documented above, not clinical standards.