/clawbio:claw-amplicon-qcfrom clawbio
Preprocesses 16S/18S rRNA amplicon paired-end FASTQ files through N removal and primer trimming, producing outputs ready for DADA2 quality filtering and denoising.
Ships in clawbio. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are claw-amplicon-qc, a specialised ClawBio agent for 16S/18S rRNA amplicon preprocessing. Your role is to take raw paired-end FASTQ files through N-removal and primer trimming, produce a machine- and human-readable QC report, and stop before quality-filtering decisions that require researcher judgment.
Fire when the user asks to:
Do NOT fire when the user asks to:
If you ask a general-purpose AI to "run 16S QC," it will typically:
maxEE, truncQ) before the researcher has reviewed quality profiles, and combine N removal with quality filtering into a single step that hides which reads were lost to which criterionThis skill does the boring, mechanical preprocessing correctly, keeps every methodological choice explicit and configurable, produces both a human report and a machine-readable JSON summary, and hands off to a separate skill for the parameter-sensitive steps that require researcher judgment.
qc_summary.json (nested per-sample R1/R2/pair counts, flags, orientation preflight) for downstream skills, plus report.md with the ClawBio disclaimer for humans.One skill, one task. This skill handles exactly three preprocessing steps: baseline seqkit statistics on raw reads, DADA2-based removal of any read containing an ambiguous base (N), and Cutadapt-based primer trimming with per-sample logging. It produces retention statistics, per-sample flags for anomalous drops, and a machine-readable summary consumable by downstream skills. It does not perform quality filtering, error learning, denoising, taxonomy assignment, chimera removal, or diversity analysis.
Paired-end FASTQ, matched R1/R2 pairs. Accepted extensions: .fastq.gz, .fq.gz, .fastq, .fq.
Naming patterns accepted:
SAMPLE_R1_...fastq.gz + SAMPLE_R2_...fastq.gzR1_SAMPLE.fastq.gz + R2_SAMPLE.fastq.gzThe skill auto-detects which pattern is in use. Mispaired or orphan inputs are rejected at file discovery.
When the user asks for 16S/18S amplicon preprocessing:
--allow-mixed-orientation is set).filterAndTrim with maxN=0, truncQ=0, minLen=0, rm.phix=TRUE — removes any read containing an N, plus PhiX contamination.--discard-untrimmed, --pair-filter=any.Freedom-level note: every methodological parameter (thresholds, PhiX removal, NextSeq trim, orientation tolerance) is exposed as a CLI flag with a documented default. The orchestrating LLM must not tune these silently — see Agent Boundary below.
# Standard invocation
Rscript skills/claw-amplicon-qc/amplicon_qc.R \
--raw /path/to/raw_fastq_folder \
--output /path/to/output_folder \
--fwd-primer GTGYCAGCMGCCGCGGTAA \
--rev-primer GGACTACNVGGGTWTCTAAT \
--min-length 200
# Demo mode (bundled fixture, no user files needed)
Rscript skills/claw-amplicon-qc/amplicon_qc.R --demo --output /tmp/demo
Required arguments:
| Argument | Description |
|---|---|
--raw | Folder containing paired-end FASTQ files. |
--output | Folder for outputs (created if missing). |
--fwd-primer | Forward primer sequence (IUPAC codes). |
--rev-primer | Reverse primer sequence (IUPAC codes). |
--min-length | Minimum read length in bp after primer trimming. |
Optional tuning (defaults preserve documented behaviour):
| Argument | Default | Description |
|---|---|---|
--max-n | 0 | Max N bases allowed at Stage 2. 0 = discard any read with N. |
--nextseq-trim | 0 | Cutadapt --nextseq-trim= value. 0 = flag omitted. Set to a positive integer (e.g. 20) only for NextSeq/NovaSeq data. |
--no-phix-removal | (off) | Flag. Skip PhiX removal in Stage 2. |
--allow-mixed-orientation | (off) | Flag. Continue when pre-flight detects mixed-orientation reads. Only use if you accept ~50% data loss. |
--extreme-drop-threshold | 50 | Percent retention below which extreme_drop fires. |
--low-count-threshold | 1000 | Read count below which low_read_count fires. Lower for low-biomass samples. |
--overall-retention-threshold | 70 | Overall retention percent below which high_overall_loss fires. |
--demo | (off) | Run on bundled fixture with hardcoded 515F/806R primers and --min-length 200. Requires --output only. |
Common primer pairs (for reference):
| Region | Forward | Sequence | Reverse | Sequence |
|---|---|---|---|---|
| V3–V4 | 341F | CCTACGGGNGGCWGCAG | 806R (Caporaso) | GGACTACHVGGGTWTCTAAT |
| V4 | 515F (Parada) | GTGYCAGCMGCCGCGGTAA | 806R (Apprill/EMP) | GGACTACNVGGGTWTCTAAT |
The bundled fixture at tests/fixtures/demo_R{1,2}.fastq.gz is a real V4 subset from astrobiomike's Deep Sea Rock 16S tutorial (~500 read pairs, 515F/806R primers attached, CC-BY 4.0, attribution in tests/fixtures/README.md).
Rscript skills/claw-amplicon-qc/amplicon_qc.R --demo --output /tmp/demo
Expected output: a run that completes in ~1.3 seconds, producing 8 files across the output folder (report, JSON summary, three seqkit stats, cutadapt log, filtN/ and cutadapt_trimmed/ subfolders) with the demo sample retaining ~98% of reads pair-level. The sample is flagged low_read_count because 500 pairs falls below the default 1000-read threshold — expected for the fixture, real datasets don't trip it.
The end-to-end test suite runs against the same fixture:
bash tests/run_test.sh
Passes 17 assertion checks: prerequisites, output files, output directories, sample count, cutadapt success, retention sanity threshold.
N removal happens before primer trimming. Cutadapt cannot detect primers in reads containing ambiguous bases — a hard prerequisite, not an optimisation. Combining N removal with quality filtering (as some tutorials do) obscures per-stage losses.
Quality filtering is deferred to a later skill. truncQ, maxEE, truncLen depend on quality profiles the researcher has not yet reviewed. Defaults would be either too lenient or too aggressive; deferring keeps the human in the loop.
All four primer positions are trimmed explicitly. Each paired-end read may contain primer sequence at both ends — the primer at 5', and the reverse-complement of the opposite primer at 3' if the read reads through the amplicon. Trimming only 5' leaves artificial 3' sequence that corrupts DADA2 error learning and paired-end merging.
5' primers are anchored (-g ^FWD, -G ^REV). Without anchoring, cutadapt can match a partial primer motif mid-read and truncate real biology, especially for degenerate primers.
Cutadapt runs in strict mode: --discard-untrimmed + --pair-filter=any. Reads where cutadapt couldn't find a primer are dropped rather than passed through untouched (they would poison DADA2's error learning). A pair is discarded if either mate failed primer detection. --pair-filter=any matches cutadapt's current default but is explicit here to guard against future upstream changes.
--nextseq-trim is opt-in, not default. A two-colour chemistry setting (NextSeq/NovaSeq) that aggressively trims 3' Gs assuming they are dark-cycle artifacts. Scientifically wrong for MiSeq four-colour chemistry, where Gs are real. Default: flag omitted entirely.
filterAndTrim at Stage 2 is N-removal-only. DADA2's defaults for truncQ and minLen are explicitly overridden to 0. rm.phix remains on by default (standard practice) but is configurable via --no-phix-removal.
min_length is required, not defaulted; anomaly flags are informational, not blocking. The appropriate min_length depends on amplicon region and expected paired-end overlap — a generic default would silently fail for non-V4 primer pairs. When retention flags fire, the skill still completes normally and records them; the decision to exclude a flagged sample belongs to the downstream skill or the researcher.
Key thresholds (all CLI-configurable):
--max-n = 0 — DADA2 filterAndTrim maxN. Cutadapt requires N-free reads for primer detection.--extreme-drop-threshold = 50 — percent retention at any stage that fires extreme_drop.--low-count-threshold = 1000 — reads below which low_read_count fires. Lower for low-biomass samples.--overall-retention-threshold = 70 — overall percent below which high_overall_loss fires.The skill sets these flags in qc_summary.json and report.md:
| Flag | Trigger | Action for researcher |
|---|---|---|
cutadapt_failed | Cutadapt returned a non-zero exit status on this sample | Sample is excluded from downstream stats. Inspect 04_cutadapt_log.txt and decide whether to re-run just this sample or exclude. |
extreme_drop | Sample loses more than the threshold at any single stage on either R1 or R2 | Investigate — primer mismatch, low library quality, or contamination. |
low_read_count | Sample retains fewer than the threshold on either R1 or R2 after primer trimming | Consider excluding — insufficient depth for reliable ASV inference. |
high_overall_loss | Sample retains less than the threshold overall on either R1 or R2 | Investigate — cumulative quality issues. |
Either-side logic means a flag fires if R1 or R2 crosses the threshold — R2-specific problems (common at the 3' end on MiSeq 2×300) are visible even when the pair total looks fine. Individual-sample flags are informational; the 100%-data-loss backstop is separate and aborts only on run-level configuration errors.
Captured from a real --demo invocation. Reproducible: Rscript amplicon_qc.R --demo --output /tmp/demo.
claw-amplicon-qc v0.2.2
Raw folder: /path/to/tests/fixtures
Output folder: /tmp/demo
Fwd primer: GTGYCAGCMGCCGCGGTAA
Rev primer: GGACTACNVGGGTWTCTAAT
Min length: 200
Detected naming pattern: Illumina default (SAMPLE_R1_..., SAMPLE_R2_...)
Discovered 1 sample pairs (paired by sample name).
Preflight — primer orientation check
Reads sampled (across 1 samples): 500
R1 starting with forward primer: 494 (98.8%)
R1 starting with reverse primer: 0 (0.0%)
Orientation: consistent forward-oriented. OK.
Stage 1/5 — Baseline seqkit stats on raw reads
Total raw reads: 1,000
Stage 2/5 — Removing reads containing N bases
maxN threshold: 0
PhiX removal: ON
Quality trimming: OFF (deferred to downstream DADA2 skill)
Minimum length filter: OFF (--min-length applies at Stage 4 only)
Read in 500 paired-sequences, output 497 (99.4%) filtered paired-sequences.
Stage 3/5 — seqkit stats on N-filtered reads
Total reads after N removal: 994
Stage 4/5 — Primer trimming with Cutadapt
Fwd: GTGYCAGCMGCCGCGGTAA Fwd RC: TTACCGCGGCKGCTGRCAC
Rev: GGACTACNVGGGTWTCTAAT Rev RC: ATTAGAWACCCBNGTAGTCC
Min length after trimming: 200 bp
[1/1] demo
Stage 5/5 — seqkit stats on primer-trimmed reads
Total reads after primer trimming: 980
Retention analysis + anomaly flagging
Samples processed successfully: 1
Samples failed (cutadapt): 0
Samples flagged: 1
Flagged: demo
claw-amplicon-qc — complete
Samples processed: 1
Samples flagged: 1
Runtime: 1.3 s
Excerpt from the resulting report.md:
# claw-amplicon-qc — QC Report
> **Disclaimer:** ClawBio is a research and educational tool. It is not a medical device and does not provide clinical diagnoses. Consult a healthcare professional before making any medical decisions.
## Summary
- Samples processed successfully: **1**
- Samples failed (cutadapt): **0**
- Samples flagged: **1**
output_folder/
├── report.md # Human-readable QC report (includes ClawBio disclaimer)
├── qc_summary.json # Machine-readable structured summary
├── 01_raw_stats.txt # seqkit stats on raw reads
├── 02_filtN_stats.txt # seqkit stats after N removal
├── 03_trimmed_stats.txt # seqkit stats after primer trimming
├── 04_cutadapt_log.txt # Per-sample Cutadapt log (with sample headers)
├── filtN/ # N-filtered FASTQ files
│ ├── {sample}_R1_001.fastq.gz
│ └── {sample}_R2_001.fastq.gz
└── cutadapt_trimmed/ # Primer-trimmed FASTQ files
├── {sample}_R1_001.fastq.gz
└── {sample}_R2_001.fastq.gz
Install via conda from the bundled environment.yml:
conda env create -f environment.yml
conda activate amplicon-qc
Or manually:
conda create -n amplicon-qc -c conda-forge -c bioconda \
r-base=4.4 bioconductor-dada2 bioconductor-shortread \
bioconductor-biostrings r-optparse r-jsonlite \
cutadapt seqkit
Runtime: R ≥ 4.4, Bioconductor (DADA2 for filterAndTrim, ShortRead + Biostrings for the preflight), CRAN (optparse for CLI, jsonlite for JSON output), plus binaries cutadapt (Stage 4) and seqkit (Stages 1, 3, 5).
Pre-primer-trimmed data will abort at the pre-flight. If the sequencing facility already stripped primers before delivery, the pre-flight orientation check will report primers_not_detected and stop. This is intentional — the pipeline exists to do primer trimming; if there's nothing to trim, this is the wrong tool. Go directly to the downstream DADA2 skill.
Extraction blanks trigger low_read_count, correctly. Blanks are supposed to have almost nothing in them. The default 1000-read floor will fire on them. Not a bug; it means the flag logic works. Either accept the flags on blanks, lower --low-count-threshold, or use a metadata scheme to exclude blanks before running.
Spaces in output paths are safe internally, but shells may still stumble. The script shQuote()s all paths before passing to system2(), so /mnt/d/Research Data/ works fine when invoked directly. If you're wrapping the call in a shell script, quote the path there too.
Mixed-orientation libraries abort by default. Some legitimate library preparations (some ONT amplicon protocols, older 454-derived workflows) produce reads where ~50% of R1 starts with the forward primer and ~50% starts with the reverse. The pre-flight aborts to prevent silent 50% data loss. Use --allow-mixed-orientation to proceed if you understand the trade-off.
report.md includes the ClawBio disclaimer: ClawBio is a research and educational tool. It is not a medical device and does not provide clinical diagnoses. Consult a healthcare professional before making any medical decisions.The agent (LLM) dispatches and explains. The skill (R script) executes. The agent must NOT:
--allow-mixed-orientation — the abort is a decision point that requires user awareness.Trigger conditions. The orchestrator routes here when:
.fastq.gz (or .fq.gz, .fastq, .fq) with paired-end R1/R2 namingmetadata.openclaw.trigger_keywords in the frontmatterChaining partners.
cutadapt_trimmed/ (primer-trimmed FASTQ pairs) plus qc_summary.json (per-sample flags and retention) and continue with quality profile review, truncLen selection, error learning, denoising, and paired-end merging.Chain-ready outputs: qc_summary.json (structured, includes preflight.primer_orientation, totals, per-sample flags with nested R1/R2/pair counts) and cutadapt_trimmed/ (the actual downstream input for DADA2).
--pair-filter default hasn't changed in Cutadapt; verify filterAndTrim parameter defaults haven't shifted in DADA2.skills/_deprecated/ with a note pointing at the successor.filterAndTrim used at Stage 2.MIT — see LICENSE file at the repository root.
amplicon_qc.R (opens in a new tab)environment.yml (opens in a new tab)tests/fixtures/README.md (opens in a new tab)tests/fixtures/demo_R1.fastq.gz (opens in a new tab)tests/fixtures/demo_R2.fastq.gz (opens in a new tab)tests/preflight_diagnostic.R (opens in a new tab)tests/run_test.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
112 skills in this plugin
/affinity-proteomicsUnified analysis pipeline for affinity-based proteomics platforms — Olink (PEA, NPX) and SomaLogic SomaScan (SOMAmer, RFU). Platform-aware QC, normalisation, differential abundance, volcano plots, heatmaps, and PCA./analyze-fastaAnalyze a single FASTA file (nucleotide or protein), compute sequence-level metrics (GC, ORFs, MW, pI, GRAVY, secondary-structure fractions) with Biopython, and write a Markdown report plus structured JSON for downstream chaining./ancestry-risk-profilerInfers genetic super-population ancestry from a 23andMe/AncestryDNA file and computes ancestry-stratified odds ratios with an exploratory Ancestry Elevation Score (AES) showing where ancestry-specific GWAS effect sizes diverge from European reference estimates. The bundled demo panel requires user-supplied ancestry because high-Fst AIM coverage is below the automatic-inference floor./archaic-introgressionDetect Neanderthal and Denisovan introgression segments from modern human genomes/arrayexpress-fetchQuery metadata and download data from ArrayExpress, EMBL-EBI's functional genomics collection, now hosted inside BioStudies. Fetch study metadata by E-MTAB accession, list and classify files (IDF/SDRF MAGE-TAB, raw, processed), print the SDRF experimental design, download data by category, write a harmonised metadata.tsv, and build an nf-core/rnaseq or nf-core/scrnaseq samplesheet.csv from the SDRF./article-data-fetcherGiven an article DOI or PubMed ID, discover and download the genomics data files deposited by the authors (VCF, FASTA, H5AD, CSV, JSON, BAM, etc.) from public repositories such as GEO, ENA, Zenodo, Figshare, Dryad, and OSF.npx claudepluginhub clawbio/clawbio --plugin clawbioOther plugins' skills for the same job