Metagenomics Fundamentals

Lesson 6 of 13 · 11 min

Taxonomic Profiling of Amplicons in QIIME 2

By now you have a FeatureData[Sequence] artifact of ASVs and a FeatureTable[Frequency] from denoising, but every feature is still an anonymous DNA string. A .qza artifact is just a zip archive holding data plus a full provenance record of how it was made. Taxonomic classification maps each ASV to a lineage using a Naive Bayes classifier trained on a curated reference such as SILVA or Greengenes2.

Import reference artifacts

bash
qiime tools import \
  --type 'FeatureData[Sequence]' \
  --input-path silva-138-99-seqs.fna \
  --output-path ref-seqs.qza

qiime tools import \
  --type 'FeatureData[Taxonomy]' \
  --input-format HeaderlessTSVTaxonomyFormat \
  --input-path silva-138-99-tax.tsv \
  --output-path ref-tax.qza

Tip: QIIME 2's data resources page hosts pre-trained Naive Bayes classifiers for SILVA 138 and Greengenes2, both full-length and pre-trimmed to the common 515F/806R V4 region. If one matches your reference and primer region, download it and skip straight to classify-sklearn. Train your own (shown below) when your primers are non-standard, or when you need a reference version or region that isn't offered pre-trained.

Trim reference to primers

bash
qiime feature-classifier extract-reads \
  --i-sequences ref-seqs.qza \
  --p-f-primer GTGYCAGCMGCCGCGGTAA \
  --p-r-primer GGACTACNVGGGTWTCTAAT \
  --p-min-length 100 \
  --p-max-length 400 \
  --o-reads ref-seqs-v4.qza

qiime feature-classifier fit-classifier-naive-bayes \
  --i-reference-reads ref-seqs-v4.qza \
  --i-reference-taxonomy ref-tax.qza \
  --o-classifier classifier-v4.qza

Classify the ASVs

bash
qiime feature-classifier classify-sklearn \
  --i-classifier classifier-v4.qza \
  --i-reads rep-seqs.qza \
  --p-confidence 0.7 \
  --o-classification taxonomy.qza

qiime tools export \
  --input-path taxonomy.qza \
  --output-path taxonomy-export
head -n 4 taxonomy-export/taxonomy.tsv
Feature ID	Taxon	Confidence
0b3a5c1e9f7d2a4c6b8e0f1a3c5d7e9f	d__Bacteria; p__Bacteroidota; c__Bacteroidia; o__Bacteroidales; f__Bacteroidaceae; g__Bacteroides	0.9999
1f2c8b4d6a0e3c5f7b9d1a3e5c7f9b2d	d__Bacteria; p__Firmicutes; c__Clostridia; o__Oscillospirales; f__Ruminococcaceae; g__Faecalibacterium; s__Faecalibacterium_prausnitzii	0.8123
9ad70c2e4b6f8a1c3e5d7f9b0a2c4e6d	d__Bacteria; p__Proteobacteria; c__Gammaproteobacteria; o__Enterobacterales; f__Enterobacteriaceae	0.9987
bash
qiime taxa barplot \
  --i-table table.qza \
  --i-taxonomy taxonomy.qza \
  --m-metadata-file sample-metadata.tsv \
  --o-visualization taxa-bar-plots.qzv

The --p-confidence value is a Naive Bayes posterior cutoff: classify-sklearn keeps the deepest rank that clears it and truncates the lineage there, which is why the third ASV above stops at family with no g__ label. Lowering it toward 0.5 pushes more calls down to genus or species but inflates false assignments. A single hypervariable region like V4 rarely carries enough signal to resolve species, so treat s__ labels as hypotheses and trust genus-level and higher calls.

Try it yourself: Re-run classify-sklearn on the same rep-seqs.qza twice, once with --p-confidence 0.7 and once with --p-confidence 0.5. Build a taxa barplot from each result and count how many ASVs gain a g__ or s__ label at the lower cutoff, then decide which of those assignments you would actually report.