Sample qc triage

From ClawBio/ClawBio · View interactive version

Sample qc triage is an AI agent skill from the GitHub repository ClawBio/ClawBio. Deterministic multi-sample QC triage for identity, sex, contamination, and batch-shift outliers

How to use this skill

Skill file

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:

Do NOT fire when:

Why This Exists

Core Capabilities

  1. Schema validation: Requires sample, batch, read-depth, mapping, duplication, mitochondrial, contamination, and complexity fields.
  2. Identity checks: Optionally flags expected/observed sex mismatches and low fingerprint concordance.
  3. Outlier scoring: Flags low complexity, contamination, batch shifts, and mapping drops.
  4. Report pack: Writes report.md, result.json, tables/sample_flags.csv, and reproducibility/{commands.sh,environment.yml,checksums.sha256}.

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

  1. Validate: Confirm required columns and numeric metric fields.
  2. Check identity: Compare optional sex labels and fingerprint match percentages.
  3. Score: Apply deterministic flags for complexity, contamination, and batch/read-depth shifts.
  4. Summarise: Count flagged samples and issue categories.
  5. 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

  1. Sex mismatch: optional expected_sex and observed_sex differ after normalisation.
  2. Identity mismatch: optional fingerprint_match_pct < 95.
  3. Low complexity: complexity_score < 0.60 or duplicate_pct > 35.
  4. Contamination: contamination_pct > 5.
  5. Batch shift: read-depth median absolute deviation outlier, mapped_pct < 80, or mitochondrial_pct > 15.

Example Queries

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
    ├── environment.yml
    └── checksums.sha256

Dependencies

Gotchas

Safety

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

Maintenance

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.