๐งฎ Interactive DADA2 Truncation & Overlap Calculator
The #1 most common error in 16S paired-end pipelines is losing 70% to 100% of sequencing reads during DADA2 merging. This occurs when users truncate reads too aggressively at the 3' end, leaving less than the required 12-20 bp overlap between forward and reverse reads.
When reads cannot merge, DADA2 silently discards them, resulting in empty or near-empty feature tables!
- Target Amplicon Length: Total biological base pairs between primers (e.g. 253 bp for V4 515F-806R, ~460 bp for V3-V4).
- Forward / Reverse Read Length: The sequencing run cycle length (e.g. 250 bp on MiSeq 2x250).
- Truncation Formula:
Effective Overlap = (trunc-len-f - trim-left-f) + (trunc-len-r - trim-left-r) - amplicon_len
- Safety Rule: Ensure Effective Overlap is ≥ 20 bp. If < 12 bp, DADA2 cannot merge reads.
- Step 1: Inspect your
demux-summary.qzvquality score boxplots to find where median quality drops below Q30. - Step 2: Test your candidate truncation values in this calculator to confirm positive overlap ≥ 20 bp.
- Step 3: Input those exact values into Section 5 (
qiime dada2 denoise-paired) via--p-trunc-len-fand--p-trunc-len-r.
๐ Rarefaction Depth Advisor
Microbial diversity metrics (richness, Shannon, UniFrac) are highly sensitive to sequencing library size. A sample sequenced to 50,000 reads will artificially appear to contain far more rare species than one with 3,000 reads simply due to sequencing effort.
Rarefaction standardizes all samples by subsampling reads without replacement to an even depth (--p-sampling-depth). Any samples with fewer reads than this cutoff are completely dropped from analysis.
- Too Low Depth: Retains 100% of samples, but fails to capture rare community members, reducing taxonomic and phylogenetic resolution.
- Too High Depth: Maximizes diversity resolution, but discards valuable biological samples that had lower library yield.
- Recommended Target: Pick a depth where alpha rarefaction curves (
alpha-rarefaction.qzv) have plateaued, while losing ≤ 10% of samples.
- Step 1: Run
qiime feature-table summarizeand inspecttable.qzvat view.qiime2.org to get sample depth percentiles. - Step 2: Enter your minimum and median depths here to evaluate the trade-off.
- Step 3: Pass this recommended value to Section 10:
qiime diversity core-metrics-phylogenetic --p-sampling-depth <value>.
qiime feature-table summarize) to get a recommended sampling depth for diversity analysis.๐ฆ Interactive FASTQ Manifest Generator
High-throughput sequencing datasets consist of dozens or hundreds of raw .fastq.gz files. QIIME 2 does not ingest loose folders of files via ambiguous wildcards. Instead, it enforces reproducibility by requiring an authoritative Manifest TSV file that explicitly links each sample identifier to its exact file paths on disk.
Why Hand-Crafting Fails: Manually editing manifest files in spreadsheet tools (like Excel) is the single most common cause of early pipeline crashes. Excel frequently converts tabs into spaces, injects invisible Windows carriage-return characters (\r\n), or truncates sample IDs. This tool outputs a strictly compliant, Unix-encoded (LF) tab-separated manifest.
- Layout Type: Switches between Paired-End (generates 3 columns:
sample-id,forward-absolute-filepath,reverse-absolute-filepathunder formatPairedEndFastqManifestPhred33V2) and Single-End (generates 2 columns forSingleEndFastqManifestPhred33V2). - Base Directory Absolute Path: The exact folder on your server or machine where your FASTQs live (e.g.
$PWD/raw_fastqor/home/user/project/fastqs). QIIME 2 strictly demands absolute paths so that analysis scripts remain reproducible from any working directory. - Filename Extension: File extension pattern (e.g.
.fastq.gzor.fq.gz). The generator automatically builds forward (_R1) and reverse (_R2) file names. - Sample IDs Textarea: Paste your sample IDs here (one per line, comma-separated, or space-separated). The generator instantly extracts and formats them.
- Generate Manifest: Compiles and displays the formatted tab-delimited text in the live preview box.
- Load Example: Injects a standard reference 3-sample mock dataset so you can immediately see the expected structure.
- โฌ Download manifest.tsv: Exports a clean, UTF-8 tab-separated file with Unix line endings ready for terminal input.
- Manifest Output Preview: Real-time display showing the exact tab-separated text that will be fed into QIIME 2.
- Step 1 (Generate & Save): Use this generator to export
manifest.tsvdirectly into your study workspace. - Step 2 (Import Command): In terminal, pass the manifest to
qiime tools import:qiime tools import \ --type 'SampleData[PairedEndSequencesWithQuality]' \ --input-path manifest.tsv \ --output-path demux-paired.qza \ --input-format PairedEndFastqManifestPhred33V2
- Step 3 (Artifact Generation): QIIME 2 reads the manifest, verifies file existence and Phred score integrity, bundles all reads into a single compressed
demux-paired.qzaartifact, and initializes the immutable cryptographic provenance graph.
PairedEndFastqManifestPhred33V2 or SingleEndFastqManifestPhred33V2) in seconds.If your FASTQ files are stored on a remote HPC cluster, cloud instance, or Linux workstation, you don't even need to type them into a web form! Navigate to your FASTQ folder in terminal and execute this 1-line bash script:
# Run inside your FASTQ directory:
echo -e "sample-id\tforward-absolute-filepath\treverse-absolute-filepath" > manifest.tsv
for f in *_R1*.fastq.gz; do
s="${f%%_R1*}"
r="${f/_R1/_R2}"
echo -e "${s}\t${PWD}/${f}\t${PWD}/${r}" >> manifest.tsv
done
echo "Manifest generated with $(wc -l < manifest.tsv) lines!"
This loop automatically reads your actual filenames on disk, captures your current working directory ($PWD), pairs forward and reverse reads, and writes a valid manifest.tsv instantaneously.
๐งพ Sample Metadata Builder (#q2:types Compliant)
Sequencing data without metadata is biologically meaningless. Metadata provides the biological and experimental context for every single sample (e.g., treatment vs control, body site, host phenotype, timepoint, pH, temperature).
Where Metadata is Used: Every statistical and visual tool in QIIME 2 relies on metadata:
coloring Emperor 3D PCoA ordination plots, calculating group differences with PERMANOVA (beta-group-significance), comparing alpha diversity (alpha-group-significance), and identifying differentially abundant microbes with ANCOM-BC.
The Critical #q2:types Directive: When this second header row is omitted, QIIME 2 guesses column types automatically. This often fails: a numeric timepoint column (0, 1, 2) gets parsed as a continuous regression slope rather than discrete categorical test groups, or missing values (NA) cause numeric measurements to be downgraded to strings. This builder automatically inserts #q2:types with correct categorical and numeric declarations.
- Sample ID (Mandatory): The unique identifier for each sample. Must match the exact sample-ids in your FASTQ manifest. Cannot contain whitespace or forbidden characters.
- Treatment Group (categorical): Your primary biological experimental condition (e.g.
Control,DrugA,WildType). Used for ANCOM-BC comparisons and PERMANOVA. - Body Site (categorical): Anatomical location or ecological habitat (e.g.
gut,soil,saliva). Crucial for multi-factor stratification. - Subject / Host ID (categorical): Individual host or patient tag (e.g.
SubjectA,Mouse_01). Essential for repeated-measures and longitudinal volatility tracking. - Timepoint (numeric / categorical): Sampling interval (e.g.
0,7,14). Handled as continuous time in volatility plots or discrete factor in PERMANOVA. - pH / Continuous Value (numeric): Quantitative continuous measurements used for environmental gradient analysis and Adonis linear modeling.
- Batch / Sequencing Run: Technical confounder covariate used to block batch effects and sequencing run bias.
- ๏ผ Add Sample: Validates input fields and adds the sample row into the live memory table.
- Load Example Dataset: Injects a complete 4-sample longitudinal trial dataset with controls and treatments.
- โฌ Download sample-metadata.tsv: Exports a 100% QIIME 2-compliant tab-separated file with the
#q2:typesdirective included. - Clear All: Clears all table records to start building a new study from scratch.
- Step 1 (Validate & Tabulate): Run
qiime metadata tabulate --m-input-file sample-metadata.tsv --o-visualization metadata.qzvto verify your columns visually at view.qiime2.org. - Step 2 (Core Diversity Integration): Supplied via
--m-metadata-file sample-metadata.tsvinqiime diversity core-metrics-phylogeneticto color Emperor 3D PCoA scatter plots. - Step 3 (Hypothesis Testing): Passed to PERMANOVA:
qiime diversity beta-group-significance \ --i-distance-matrix core-metrics-results/unweighted_unifrac_distance_matrix.qza \ --m-metadata-file sample-metadata.tsv \ --m-metadata-column treatment \ --o-visualization treatment-significance.qzv
- Step 4 (Differential Abundance): Evaluated in ANCOM-BC via
qiime composition ancombc --p-formula 'treatment + timepoint'.
#q2:types directives (categorical vs numeric).0. QIIME 2 Core Architecture & Semantic Types
# Inspect any artifact with peek: qiime tools peek table.qza # View any .qzv locally: qiime tools view table.qzv # Extract full underlying data (BIOM/FASTA) from artifact: qiime tools extract \ --input-path table.qza \ --output-path extracted-table/
.qza and .qzv is a zip file containing biological data, metadata, semantic type definitions, and a complete provenance graph.# Common Semantic Types: SampleData[PairedEndSequencesWithQuality] # Paired FASTQs FeatureTable[Frequency] # ASV/OTU Count Table FeatureData[Sequence] # Representative ASV Sequences FeatureData[Taxonomy] # Taxonomic Assignments Phylogeny[Rooted] # Rooted Phylogenetic Tree DistanceMatrix # Beta Diversity Matrix PCoAResults # Ordination for 3D Emperor
1. Environment Setup (Conda / Mamba)
# Download & install Miniconda wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda3 source $HOME/miniconda3/bin/activate conda init bash # Install Mamba for lightning fast environment installs conda install -n base -c conda-forge mamba -y
# Create environment from official YAML wget https://data.qiime2.org/distro/amplicon/qiime2-amplicon-2024.10-py310-linux-conda.yml mamba env create -n qiime2-amplicon --file qiime2-amplicon-2024.10-py310-linux-conda.yml # Activate environment conda activate qiime2-amplicon # Verify installed plugins & versions qiime info
qiime info to confirm all plugins (dada2, diversity, feature-classifier, cutadapt, etc.) are available.2. Data Ingestion & Demultiplexing
QIIME 2 cannot work directly on loose FASTQ files. Raw sequencing reads must be imported into an immutable QIIME 2 Artifact (.qza) that seals the data with its semantic type, quality encoding (Phred33/64), and a cryptographic provenance tracker.
- --type: Declares what kind of biological data is inside (e.g.
SampleData[PairedEndSequencesWithQuality]). Prevents downstream plugins from receiving incorrect data types. - --input-path: Points to your
manifest.tsvmapping file or raw folder. - --input-format: Specifies the format parser (e.g.
PairedEndFastqManifestPhred33V2for modern Illumina). - --output-path: Destination
.qzaartifact file containing your compressed reads.
- Generate
manifest.tsvmapping sample IDs to FASTQs. - Run
qiime tools import. - Verify output by running
qiime demux summarizeto inspect quality curves.
qiime tools import \ --type 'SampleData[PairedEndSequencesWithQuality]' \ --input-path manifest.tsv \ --output-path demux-paired.qza \ --input-format PairedEndFastqManifestPhred33V2
qiime tools import \ --type 'SampleData[SequencesWithQuality]' \ --input-path manifest-single.tsv \ --output-path demux-single.qza \ --input-format SingleEndFastqManifestPhred33V2
qiime tools import \ --type 'SampleData[SequencesWithQuality]' \ --input-path manifest.tsv \ --output-path demux.qza \ --input-format SingleEndFastqManifestPhred33V2
qiime tools import \ --type 'SampleData[PairedEndSequencesWithQuality]' \ --input-path manifest.tsv \ --output-path demux-paired.qza \ --input-format PairedEndFastqManifestPhred33V2
SampleData[SequencesWithQuality] for single-end versus SampleData[PairedEndSequencesWithQuality] for paired-end, matching the manifest format specification.qiime demux emp-paired \ --i-seqs emp-paired-end-sequences.qza \ --m-barcodes-file sample-metadata.tsv \ --m-barcodes-column barcode-sequence \ --o-per-sample-sequences demux-paired.qza \ --o-error-correction-details demux-details.qza
3. Primer & Adapter Removal (q2-cutadapt)
PCR primers are synthetic non-biological oligonucleotides. If you leave primers in your reads, DADA2 will mistake primer synthesis errors, degenerate IUPAC wobble bases, and PCR drift for genuine biological mutations, creating thousands of artificial ASVs!
- --p-front-f / --p-front-r: Forward and reverse primer sequences. Use
^(e.g.^GTGYCAGC...) to anchor the primer strictly to the 5' beginning of the read. - --p-error-rate: Maximum allowable mismatch rate (0.1 = 1 mismatch per 10 bases).
- --p-minimum-length: Drops artifactual reads that become too short after trimming.
- Input demultiplexed reads (
demux-paired.qza). - Cutadapt scans the 5' ends and clips matching primer sequences.
- Outputs clean
trimmed-demux-paired.qzaready for DADA2 error modeling.
qiime cutadapt trim-paired \ --i-demultiplexed-sequences demux-paired.qza \ --p-front-f GTGYCAGCMGCCGCGGTAA \ --p-front-r GGACTACNVGGGTWTCTAAT \ --p-error-rate 0.1 \ --p-minimum-length 100 \ --o-trimmed-sequences trimmed-demux-paired.qza \ --verbose
--p-front-f) and reverse (--p-front-r) primers. Use ^ (e.g. ^GTGYCAGC...) to anchor the primer strictly to the 5' start.Why trim primers? PCR primers are artificial synthesized oligos. If kept, biological variance algorithms (DADA2) will treat primer synthesis errors or IUPAC degenerate wobbles as novel biological ASVs.
Anchoring (^): Prepending ^ forces matching only at the exact 5' end of the read, preventing internal false-positive trimming.
Common Primer Reference Table:
| Target Region | Forward Primer (5'โ3') | Reverse Primer (5'โ3') | Amplicon Size |
|---|---|---|---|
| 16S V4 (EMP standard) | 515F: GTGYCAGCMGCCGCGGTAA | 806R: GGACTACNVGGGTWTCTAAT | ~253 bp |
| 16S V3-V4 | 341F: CCTACGGGNGGCWGCAG | 805R: GACTACHVGGGTATCTAATCC | ~460 bp |
| Full-Length 16S (PacBio) | 27F: AGRGTTYGATYMTGGCTCAG | 1492R: RGYTACCTTGTTACGACTT | ~1465 bp |
| Fungal ITS1 / ITS2 | ITS1F: CTTGGTCATTTAGAGGAAGTAA | ITS4: TCCTCCGCTTATTGATATGC | Variable (~300-600 bp) |
4. Read Quality Inspection (demux summarize)
qiime demux summarize \ --i-data trimmed-demux-paired.qza \ --o-visualization demux-summary.qzv # View visualization in browser qiime tools view demux-summary.qzv
demux-summary.qzv at view.qiime2.org to inspect Interactive Quality Plots. Look for the position where median quality drops below Q25-Q30.5. DADA2 Denoising (Exact ASV Resolution)
Traditional OTU clustering lumped sequences into 97% similarity buckets, masking true biological strain variation. DADA2 constructs an empirical error model of Illumina sequencing chemistry to resolve exact, single-nucleotide differences, outputting true Amplicon Sequence Variants (ASVs).
- --p-trunc-len-f / -r: Truncates reads at the 3' position where quality drops. Must preserve ≥ 20 bp overlap for merging!
- --p-trim-left-f / -r: Trims low-quality bases from the 5' beginning. Set to 0 if Cutadapt already removed primers.
- --p-max-ee-f / -r: Discards reads with higher expected errors than cutoff (default 2.0).
- --p-n-threads: Number of parallel CPU threads to accelerate compute time.
- Filters low-quality reads and learns run-specific error models.
- Denoises forward and reverse reads independently.
- Merges paired reads with minimum 12-20 bp overlap.
- Identifies and removes bimeras/chimeras, outputting
table.qza(counts),rep-seqs.qza(FASTA), anddenoising-stats.qza.
qiime dada2 denoise-paired \ --i-demultiplexed-seqs trimmed-demux-paired.qza \ --p-trim-left-f 0 \ --p-trim-left-r 0 \ --p-trunc-len-f 240 \ --p-trunc-len-r 200 \ --p-n-threads 8 \ --o-table table.qza \ --o-representative-sequences rep-seqs.qza \ --o-denoising-stats denoising-stats.qza
table.qza), unique sequences (rep-seqs.qza), and denoising metrics (denoising-stats.qza).DADA2 Parameter Guidelines:
--p-trunc-len-f/--p-trunc-len-r: Truncates reads at the 3' end where quality drops. Must preserve sufficient overlap! Use our DADA2 Calculator to verify:(trunc-f + trunc-r) - amplicon_len ≥ 20 bp.--p-trim-left-f/--p-trim-left-r: Trims low-quality bases from the 5' beginning. Set to 0 if Cutadapt has already removed primers.--p-max-ee-f/--p-max-ee-r: Maximum expected errors allowed (default: 2.0). Reads exceeding this are discarded before error modeling.--p-chimera-method consensus: Chimeras are judged sample-by-sample and consensus is taken across samples (recommended default).--p-n-threads 0or8: Set to 0 to utilize all available CPU cores for significant speedups.
qiime dada2 denoise-paired \ --i-demultiplexed-seqs demux-paired.qza \ --p-trim-left-f 0 \ --p-trim-left-r 0 \ --p-trunc-len-f 240 \ --p-trunc-len-r 200 \ --p-n-threads 8 \ --o-table table.qza \ --o-representative-sequences rep-seqs.qza \ --o-denoising-stats stats.qza
qiime dada2 denoise-single \ --i-demultiplexed-seqs demux-single.qza \ --p-trim-left 0 \ --p-trunc-len 240 \ --p-n-threads 8 \ --o-table table.qza \ --o-representative-sequences rep-seqs.qza \ --o-denoising-stats stats.qza
denoise-paired takes separate forward and reverse parameters (-f and -r) and requires overlap merging, whereas denoise-single takes singular --p-trim-left and --p-trunc-len parameters without merging.qiime metadata tabulate \ --m-input-file denoising-stats.qza \ --o-visualization denoising-stats.qzv qiime tools view denoising-stats.qzv
# Single-end: qiime dada2 denoise-single \ --i-demultiplexed-seqs demux-single.qza \ --p-trim-left 0 \ --p-trunc-len 240 \ --p-n-threads 8 \ --o-table table.qza \ --o-representative-sequences rep-seqs.qza \ --o-denoising-stats denoising-stats.qza # PacBio CCS (Full-length ~1500bp 16S): qiime dada2 denoise-ccs \ --i-demultiplexed-seqs demux-ccs.qza \ --p-front-f AGRGTTYGATYMTGGCTCAG \ --p-front-r RGYTACCTTGTTACGACTT \ --p-min-len 1000 \ --p-max-len 1600 \ --o-table table.qza \ --o-representative-sequences rep-seqs.qza \ --o-denoising-stats denoising-stats.qza
6. Alternative QC: Deblur & VSEARCH (OTU Clustering)
qiime quality-filter q-score \ --i-demux demux-single.qza \ --o-filtered-sequences demux-filtered.qza \ --o-filter-stats demux-filter-stats.qza qiime deblur denoise-16S \ --i-demultiplexed-seqs demux-filtered.qza \ --p-trim-length 150 \ --p-sample-stats \ --o-representative-sequences deblur-rep-seqs.qza \ --o-table deblur-table.qza \ --o-stats deblur-stats.qza
--p-trim-length). Uses static error profiles.# 1. Dereplicate sequences qiime vsearch dereplicate-sequences \ --i-sequences demux-single.qza \ --o-dereplicated-table derep-table.qza \ --o-dereplicated-sequences derep-seqs.qza # 2. Cluster de novo at 97% identity qiime vsearch cluster-features-de-novo \ --i-table derep-table.qza \ --i-sequences derep-seqs.qza \ --p-perc-identity 0.97 \ --o-clustered-table table-97.qza \ --o-clustered-sequences rep-seqs-97.qza
๐ Decision Guide: DADA2 vs Deblur vs VSEARCH
Microbiome amplicon sequencing produces millions of raw reads corrupted by PCR errors, Illumina base substitution errors, and chimeras. Choosing between DADA2 (ASVs), Deblur (ASVs), and VSEARCH (97% OTUs) determines resolution, cross-study comparability, and computational cost.
- DADA2: Infers exact amplicon sequence variants (ASVs) via a sample-specific error learning model. Joins forward and reverse reads with built-in quality-aware overlap consensus and removes bimeras. Single-nucleotide resolution.
- Deblur: Uses a static global Illumina error profile. Extremely fast on massive datasets (e.g. 50,000+ samples) but requires all reads to be trimmed to an identical length and operates exclusively on single-end (or pre-joined) reads.
- VSEARCH 97% OTUs: Collapses sequences differing by โค3% into operational taxonomic units (OTUs). Blurs microdiversity, hides distinct bacterial strains, but remains useful for meta-analyses integrating legacy 454/pyrosequencing datasets.
- ITSxpress + DADA2: Required for fungal ITS because ITS variable lengths prevent quality-based truncation. Trims conserved flanking genes (18S/5.8S/28S) before non-truncated DADA2.
- For Illumina standard 16S/18S paired-end data โ Always use DADA2 denoise-paired.
- For fungal ITS โ Run ITSxpress then DADA2 with
--p-trunc-len-f 0 --p-trunc-len-r 0. - For PacBio HiFi / Nanopore โ Use DADA2 denoise-ccs.
- For legacy meta-analysis โ Use VSEARCH 97% OTUs.
7. Feature Table & Representative Sequences
The feature table (table.qza) is an $M \times N$ matrix of observation counts ($M$ samples by $N$ biological ASVs). Along with representative sequences (rep-seqs.qza), it is the direct input for taxonomy, phylogeny, alpha/beta diversity, and differential abundance.
- feature-table summarize: Generates
table.qzv, showing sequencing depth percentiles, sample counts, and feature frequencies. - tabulate-seqs: Generates
rep-seqs.qzvwith direct 1-click NCBI BLAST links for every ASV. - filter-samples: Removes low-depth samples or selects subsets using SQL metadata queries (
--p-where). - filter-features: Removes singletons or rare noise features.
- Inspect
table.qzvto verify minimum, median, and maximum read depths. - Filter out samples with inadequate reads using
filter-samples. - Pass the curated table forward to phylogeny and diversity pipelines.
# Summarize feature table (depths, sample counts, feature frequencies) qiime feature-table summarize \ --i-table table.qza \ --o-visualization table.qzv \ --m-sample-metadata-file sample-metadata.tsv # Tabulate representative sequences (interactive BLAST NCBI search) qiime feature-table tabulate-seqs \ --i-data rep-seqs.qza \ --o-visualization rep-seqs.qzv
table.qzv reveals the minimum and median sample depths needed to choose the rarefaction threshold for diversity analysis.# 1. Filter low depth samples (< 2000 reads) qiime feature-table filter-samples \ --i-table table.qza \ --p-min-frequency 2000 \ --o-filtered-table table-filtered-depth.qza # 2. Filter samples by metadata condition (e.g. body-site = 'gut') qiime feature-table filter-samples \ --i-table table.qza \ --m-metadata-file sample-metadata.tsv \ --p-where "[body-site]='gut'" \ --o-filtered-table table-gut.qza # 3. Filter out singletons / rare ASVs qiime feature-table filter-features \ --i-table table.qza \ --p-min-samples 2 \ --p-min-frequency 10 \ --o-filtered-table table-filtered-features.qza
--p-where such as "[treatment]='Drug' AND [timepoint] > 0".8. Phylogenetic Reconstruction (MAFFT & FastTree / SEPP)
qiime phylogeny align-to-tree-mafft-fasttree \ --i-sequences rep-seqs.qza \ --p-n-threads 8 \ --o-alignment aligned-rep-seqs.qza \ --o-masked-alignment masked-aligned-rep-seqs.qza \ --o-tree unrooted-tree.qza \ --o-rooted-tree rooted-tree.qza
qiime fragment-insertion sepp \ --i-representative-sequences rep-seqs.qza \ --i-reference-database sepp-refs-gg-13-8.qza \ --p-threads 8 \ --o-tree insertion-tree.qza \ --o-placements insertion-placements.qza
9. Taxonomic Classification (SILVA / Greengenes2 / UNITE)
ASVs are raw nucleotide sequences (e.g. TACGGAGGAT...). Taxonomic classification uses machine-learning classifiers to assign biological identity to each ASV: Kingdom, Phylum, Class, Order, Family, Genus, and Species.
- SILVA 138: Curated reference database for bacteria and archaea.
- Greengenes2: Phylogeny-integrated database supporting consistent whole-genome and amplicon resolution.
- UNITE: Curated reference database for fungal ITS marker genes.
- classify-sklearn: Multinomial Naive Bayes classifier trained on 7-mer nucleotide frequencies with bootstrap confidence estimation.
- Run
qiime feature-classifier classify-sklearnmatching your amplicon primer region. - Build interactive barplots via
qiime taxa barplot. - Filter out non-target sequences (e.g. mitochondrial or chloroplast DNA).
# 1. Classify sequences qiime feature-classifier classify-sklearn \ --i-classifier silva-138-99-515-806-nb-classifier.qza \ --i-reads rep-seqs.qza \ --p-n-jobs 8 \ --o-classification taxonomy.qza # 2. Tabulate taxonomic assignments and confidence scores qiime metadata tabulate \ --m-input-file taxonomy.qza \ --o-visualization taxonomy.qzv
qiime taxa barplot \ --i-table table.qza \ --i-taxonomy taxonomy.qza \ --m-metadata-file sample-metadata.tsv \ --o-visualization taxa-bar-plots.qzv qiime tools view taxa-bar-plots.qzv
# Remove mitochondrial and chloroplast DNA from feature table qiime taxa filter-table \ --i-table table.qza \ --i-taxonomy taxonomy.qza \ --p-exclude mitochondria,chloroplast \ --o-filtered-table table-no-contam.qza # Remove corresponding sequences from rep-seqs qiime taxa filter-seqs \ --i-sequences rep-seqs.qza \ --i-taxonomy taxonomy.qza \ --p-exclude mitochondria,chloroplast \ --o-filtered-sequences rep-seqs-no-contam.qza
qiime taxa collapse \ --i-table table-no-contam.qza \ --i-taxonomy taxonomy.qza \ --p-level 6 \ --o-collapsed-table table-L6-genus.qza
9b. Training a Custom Naive Bayes Classifier
# 1. Download SILVA 138 reference sequences and taxonomy wget https://data.qiime2.org/2024.10/common/silva-138-99-seqs.qza wget https://data.qiime2.org/2024.10/common/silva-138-99-tax.qza # 2. Extract reads matching your primer pair qiime feature-classifier extract-reads \ --i-sequences silva-138-99-seqs.qza \ --p-f-primer GTGYCAGCMGCCGCGGTAA \ --p-r-primer GGACTACNVGGGTWTCTAAT \ --p-min-length 100 \ --p-max-length 400 \ --o-reads silva-138-99-515-806-seqs.qza
Why extract? The classifier performs best when trained on the exact amplicon region your primers target. Training on full-length 16S sequences leads to ~10-15% lower classification accuracy.
--p-min-length / --p-max-length: Filters out unreasonably short or long extracted amplicons that indicate primer mismatches in the reference database.
Common primer pairs:
- 515F / 806R (V4): GTGYCAGCMGCCGCGGTAA / GGACTACNVGGGTWTCTAAT
- 341F / 805R (V3-V4): CCTACGGGNGGCWGCAG / GACTACHVGGGTATCTAATCC
- 27F / 1492R (Full-length 16S): AGRGTTYGATYMTGGCTCAG / RGYTACCTTGTTACGACTT
qiime feature-classifier fit-classifier-naive-bayes \ --i-reference-reads silva-138-99-515-806-seqs.qza \ --i-reference-taxonomy silva-138-99-tax.qza \ --o-classifier silva-138-99-515-806-nb-classifier.qza
Training requires 15-45 minutes and 8-32 GB RAM depending on the reference database size. The trained classifier only needs to be built once per primer pair.
Databases:
- SILVA 138 โ Bacteria, Archaea, Eukarya (most comprehensive)
- Greengenes2 โ Bacteria, Archaea (phylogeny-based, integrates WoL2)
- UNITE โ Fungi ITS taxonomy (use for ITS1/ITS2 data)
๐ Decision Guide: Which Reference Database & Classifier?
Classifying microbial representative sequences assigns biological identity (Phylum through Species) to anonymous ASVs. The accuracy of taxonomic profiles depends critically on matching your biological target to the appropriate curated reference repository and classifier algorithm.
- SILVA 138.1: The gold standard for environmental, aquatic, agricultural, and human microbiomes. Comprehensive coverage across Bacteria, Archaea, and Eukaryotes with standardized 7-rank taxonomy.
- Greengenes2 (2022.10): Built on the Web of Life (WoL) genomic tree. Harmonizes 16S amplicons directly with shotgun metagenomic whole genomes; best for phylogenetic integration.
- UNITE (v8/v9): The definitive international database for fungal ITS (ITS1, ITS2, and Full ITS) based on dynamic similarity threshold species hypotheses (SHs).
- PR2 (Protist Ribosomal Reference): Specialized curated database for protistan and microeukaryotic 18S sequences.
- BOLD / Midori: Curated cytochrome c oxidase I (COI) databases for metazoan/animal metabarcoding and environmental DNA (eDNA).
- Naive Bayes (classify-sklearn): High-speed k-mer frequency classifier. When trained on primer-extracted subregions (e.g. 515F-806R), achieves superior classification accuracy and fewer over-confident false assignments.
- Consensus VSEARCH / BLAST+: Local sequence alignment. Essential for atypical environments, novel phyla, or when training custom classifiers is computationally infeasible.
10. Alpha Diversity & Rarefaction
Alpha diversity summarizes the ecological complexity within individual samples. It evaluates both richness (how many distinct species exist) and evenness (how equitably individuals are distributed among species).
- Observed Features: Qualitative richness count of unique ASVs.
- Shannon Index: Quantitative measure accounting for richness and abundance evenness.
- Faith's PD: Phylogenetic richness measuring total branch length across the phylogenetic tree.
- Pielou's Evenness: Quantifies uniformity of abundance across taxa.
- Run
qiime diversity alpha-rarefactionto verify curves plateau. - Execute
qiime diversity core-metrics-phylogeneticat the chosen sampling depth. - Test statistical group differences using
qiime diversity alpha-group-significance(Kruskal-Wallis).
qiime diversity alpha-rarefaction \ --i-table table.qza \ --i-phylogeny rooted-tree.qza \ --p-max-depth 4000 \ --m-metadata-file sample-metadata.tsv \ --o-visualization alpha-rarefaction.qzv
qiime diversity core-metrics-phylogenetic \ --i-phylogeny rooted-tree.qza \ --i-table table.qza \ --p-sampling-depth 10000 \ --m-metadata-file sample-metadata.tsv \ --output-dir core-metrics-results
--p-sampling-depth? Use our interactive Rarefaction Depth Advisor tool above!Alpha Diversity (Within-sample):
- Faith's PD: Phylogenetic diversity (requires tree).
- Observed Features: Richness (count of ASVs).
- Shannon: Richness and evenness.
- Evenness: Pielou's Evenness.
Beta Diversity (Between-sample):
- Unweighted UniFrac: Presence/absence, phylogenetic.
- Weighted UniFrac: Abundance-weighted, phylogenetic.
- Jaccard: Presence/absence, non-phylogenetic.
- Bray-Curtis: Abundance-weighted, non-phylogenetic.
Plus Emperor 3D plots (PCoA) for each beta metric.
11. Beta Diversity & Emperor 3D
# Emperor plots are automatically generated by core-metrics # View them at view.qiime2.org qiime tools view core-metrics-results/unweighted_unifrac_emperor.qzv
12. Statistical Hypothesis Testing
Looking at clusters on an Emperor PCoA plot is exploratory; hypothesis testing statistically proves whether distances between metadata groups (e.g. Treatment vs Control, Healthy vs Disease) are significantly larger than within-group variation.
- PERMANOVA (beta-group-significance): Non-parametric multivariate ANOVA testing whether community centroids differ in distance space.
- PERMDISP: Tests whether within-group variance (dispersion) is equal across groups. Run alongside PERMANOVA to confirm significance is not a variance artifact!
- Adonis: Multi-factor regression partitioning variance across multiple confounding covariates simultaneously.
- Pass a distance matrix (e.g.
unweighted_unifrac_distance_matrix.qza) to PERMANOVA. - Specify your experimental metadata column (
--m-metadata-column treatment). - Inspect pairwise pseudo-F statistics and Benjamini-Hochberg FDR q-values in
.qzv.
qiime diversity beta-group-significance \ --i-distance-matrix core-metrics-results/unweighted_unifrac_distance_matrix.qza \ --m-metadata-file sample-metadata.tsv \ --m-metadata-column treatment \ --o-visualization unweighted-unifrac-treatment-significance.qzv \ --p-pairwise
PERMANOVA: Tests if the centroids (means) of groups are different. It is sensitive to differences in dispersion.
PERMDISP: Tests if the dispersion (variance) within groups is different. Always run this alongside PERMANOVA to ensure a significant PERMANOVA isn't just due to unequal variances.
ANOSIM: Compares ranked distances. Useful when distance values are not on a linear scale, but generally less powerful than PERMANOVA.
๐ Decision Guide: Which Beta Diversity Metric?
- Unweighted UniFrac (Qualitative + Phylogenetic): Measures phylogenetic branch lengths unique to either sample. Extremely sensitive to community membership shifts and rare ancestral lineages.
- Weighted UniFrac (Quantitative + Phylogenetic): Weights phylogenetic branch lengths by the relative abundances of taxa. Emphasizes dominant lineages and is robust against PCR noise.
- Bray-Curtis Dissimilarity (Quantitative Non-Phylogenetic): Computes differences in read counts ($BC_{jk} = 1 - \frac{2C_{jk}}{S_j + S_k}$). Ideal for non-alignable markers (ITS, COI) or when abundance shifts dominate.
- Jaccard Distance (Qualitative Non-Phylogenetic): Measures fraction of non-shared species ($1 - \frac{A \cap B}{A \cup B}$). Useful for presence/absence comparison without assuming phylogenetic lineage trees.
- Aitchison / Robust Aitchison (DEICODE): Compositional distance based on centered log-ratio (CLR) transformation. Highly recommended for sparse datasets without rarefaction!
- For 16S/18S with a rooted tree โ Test both Unweighted & Weighted UniFrac to contrast membership vs abundance effects.
- For fungal ITS โ Rely on Bray-Curtis and Jaccard.
- Always execute
qiime diversity beta-group-significance(PERMANOVA) to test statistical significance ($p < 0.05$).
13. Differential Abundance (ANCOM-BC / ANCOM-BC2)
Microbiome sequencing yields compositional relative abundances rather than absolute counts. Traditional parametric tests (t-tests, ANOVA) yield false positive rates exceeding 70% because bloom of one dominant taxon mathematically forces relative percentages of all other taxa down!
ANCOM-BC corrects for sampling fraction bias using a log-linear model to infer true biological fold changes, standard errors, and FDR-corrected q-values.
- --p-formula: Linear model formula (e.g.
treatmentorgenotype + timepoint) allowing adjustment for confounders. - --p-reference-levels: Sets the baseline reference group (e.g.
treatment::Control). - --p-prv-cut: Prevalence filter dropping ultra-rare noise taxa.
- da-barplot: Creates interactive effect-size waterfall barplots with confidence intervals.
- Collapse table to desired rank (e.g. Genus) or use ASV-level table.
- Run
qiime composition ancombcwith experimental formula. - Generate interactive differential abundance visualization with
da-barplot.
qiime composition ancombc \ --i-table table-no-contam.qza \ --m-metadata-file sample-metadata.tsv \ --p-formula 'treatment' \ --o-differentials ancombc-differentials.qza qiime composition da-barplot \ --i-data ancombc-differentials.qza \ --p-significance-threshold 0.05 \ --o-visualization ancombc-barplot.qzv
qiime composition ancombc \ --i-table table-no-contam.qza \ --m-metadata-file sample-metadata.tsv \ --p-formula 'group + timepoint' \ --p-reference-levels group::Control \ --p-prv-cut 0.10 \ --p-lib-cut 1000 \ --o-differentials ancombc2-differentials.qza qiime composition da-barplot \ --i-data ancombc2-differentials.qza \ --p-significance-threshold 0.05 \ --p-level-delimiter ';' \ --o-visualization ancombc2-barplot.qzv
14. ITS / 18S Fungal & Eukaryotic Microbiome Analysis
Unlike 16S rRNA genes which have relatively uniform length (~253 bp in V4), fungal Internal Transcribed Spacer (ITS) regions vary biologically from 200 to 600+ bp.
Critical Pipeline Changes:
1. ITSxpress is required to trim flanking conserved ribosomal genes (18S, 5.8S, 28S).
2. DADA2 Truncation must be 0 (--p-trunc-len 0)! Truncating at a fixed base position will discard all longer fungal amplicons.
3. UNITE Database must be used for taxonomy assignment.
- --p-region: Target amplicon region (
ITS1orITS2). - --p-taxa: Target kingdom (
Ffor Fungi,Afor All). - UNITE dynamic: Dynamic clustering thresholds provide species-level discrimination.
qiime itsxpress trim-pair-output-unmerged \ --i-per-sample-sequences demux-paired.qza \ --p-region ITS2 \ --p-taxa F \ --o-trimmed trimmed-its2.qza
Why extract ITS? Unlike 16S, ITS regions vary dramatically in length (200-600+ bp). DADA2 and Deblur require uniform-length inputs, so ITSxpress must extract the variable region first.
--p-region: Choose ITS1 or ITS2 based on your primer set (ITS1f/ITS2 โ ITS1; fITS7/ITS4 โ ITS2).
--p-taxa: F=Fungi, A=All (includes plants, protists).
# For ITS: set --p-trunc-len to 0 (no truncation) because ITS length varies qiime dada2 denoise-paired \ --i-demultiplexed-seqs trimmed-its2.qza \ --p-trunc-len-f 0 \ --p-trunc-len-r 0 \ --p-n-threads 8 \ --o-table table-its.qza \ --o-representative-sequences rep-seqs-its.qza \ --o-denoising-stats stats-its.qza
--p-trunc-len-f 0 and --p-trunc-len-r 0 for ITS data because ITS amplicon length varies. Quality-based truncation is handled internally by DADA2.# Download pre-trained UNITE classifier from QIIME 2 data resources # Then classify: qiime feature-classifier classify-sklearn \ --i-classifier unite-ver9-dynamic-all-25.07.2023-Q2-2024.10.qza \ --i-reads rep-seqs-its.qza \ --o-classification taxonomy-its.qza qiime taxa barplot \ --i-table table-its.qza \ --i-taxonomy taxonomy-its.qza \ --m-metadata-file sample-metadata.tsv \ --o-visualization taxa-barplot-its.qzv
# Import and process 18S data (same pipeline as 16S) # Use SILVA 138 18S classifier: qiime feature-classifier classify-sklearn \ --i-classifier silva-138-99-18S-nb-classifier.qza \ --i-reads rep-seqs.qza \ --o-classification taxonomy-18s.qza # Note: For phylogeny-aware diversity on 18S, # use de novo tree (MAFFT+FastTree) since SEPP # reference trees are 16S-specific
15. Longitudinal & Machine Learning
qiime longitudinal volatility \ --m-metadata-file sample-metadata.tsv \ --m-metadata-file shannon.qza \ --p-state-column time \ --p-individual-id-column subject \ --p-default-metric shannon \ --o-visualization volatility.qzv
16. Shotgun Metagenomics & PICRUSt2
qiime picrust2 full-pipeline \ --i-table table.qza \ --i-seq rep-seqs.qza \ --output-dir picrust2_out \ --p-threads 8 \ --p-hsp-method pic \ --p-max-nsti 2
17. Data Export & R/Python API
qiime tools export \ --input-path table.qza \ --output-path exported-feature-table biom convert \ -i exported-feature-table/feature-table.biom \ -o feature-table.tsv \ --to-tsv
import qiime2
from qiime2 import Artifact, Metadata
from qiime2.plugins import demux, dada2, feature_table
from qiime2.plugins import phylogeny, diversity, feature_classifier
import pandas as pd
# 1. Import data
demux_art = Artifact.import_data(
'SampleData[PairedEndSequencesWithQuality]',
'manifest.tsv',
view_type='PairedEndFastqManifestPhred33V2'
)
# 2. Denoise with DADA2
table, rep_seqs, stats = dada2.methods.denoise_paired(
demultiplexed_seqs=demux_art,
trunc_len_f=240,
trunc_len_r=200,
n_threads=8
)
# 3. Build tree
alignment, masked, unrooted, rooted = phylogeny.pipelines.align_to_tree_mafft_fasttree(
sequences=rep_seqs,
n_threads=8
)
# 4. Core diversity
meta = Metadata.load('sample-metadata.tsv')
results = diversity.pipelines.core_metrics_phylogenetic(
phylogeny=rooted,
table=table,
sampling_depth=10000,
metadata=meta
)
# 5. Access results as DataFrames
shannon_df = results.shannon_vector.view(pd.Series)
print(shannon_df.describe())
18. Troubleshooting Encyclopedia
| Error / Issue | Likely Cause | Solution |
|---|---|---|
| Plugin error: MemoryError | Insufficient RAM, especially during DADA2 or feature classification. | Increase RAM allocation, use fewer threads, or use a smaller classifier database. |
| No metadata column found | Typo in the column name or metadata file is not formatted correctly (e.g. not tab-separated). | Check metadata with Keemei, ensure names match exactly. |
| All samples dropped in core-metrics | --p-sampling-depth is set higher than the number of reads in your samples. | Check feature-table summarize and lower the sampling depth. |
| Missing artifact error | A required input file is missing, mistyped, or not yet created. | Check file paths and filenames. |
๐ External Resources & Key Publications
Reference Databases
- QIIME 2 Data Resources (Pre-trained Classifiers) โ
- SILVA rRNA Database โ
- Greengenes2 โ
- UNITE Fungal ITS Database โ
Community & Support
Key Publications
- Bolyen et al. (2019) โ Reproducible, interactive, scalable and extensible microbiome data science using QIIME 2. Nature Biotechnology. doi:10.1038/s41587-019-0209-9
- Callahan et al. (2016) โ DADA2: High-resolution sample inference from Illumina amplicon data. Nature Methods. doi:10.1038/nmeth.3869
- Bokulich et al. (2018) โ Optimizing taxonomic classification of marker-gene amplicon sequences with QIIME 2's q2-feature-classifier plugin. Microbiome.
- Lin & Peddada (2020) โ Analysis of compositions of microbiomes with bias correction (ANCOM-BC). Nature Communications.
20. End-to-End Cheatsheet
#!/bin/bash # 1. Import qiime tools import --type 'SampleData[PairedEndSequencesWithQuality]' --input-path manifest.tsv --output-path demux.qza --input-format PairedEndFastqManifestPhred33V2 # 2. Denoise qiime dada2 denoise-paired --i-demultiplexed-seqs demux.qza --p-trunc-len-f 240 --p-trunc-len-r 200 --o-table table.qza --o-representative-sequences rep-seqs.qza --o-denoising-stats stats-dada2.qza # 3. Phylogeny qiime phylogeny align-to-tree-mafft-fasttree --i-sequences rep-seqs.qza --o-alignment aligned-rep-seqs.qza --o-masked-alignment masked-aligned-rep-seqs.qza --o-tree unrooted-tree.qza --o-rooted-tree rooted-tree.qza # 4. Taxonomy qiime feature-classifier classify-sklearn --i-classifier silva-138-99-nb-classifier.qza --i-reads rep-seqs.qza --o-classification taxonomy.qza # 5. Diversity qiime diversity core-metrics-phylogenetic --i-phylogeny rooted-tree.qza --i-table table.qza --p-sampling-depth 10000 --m-metadata-file sample-metadata.tsv --output-dir core-metrics-results