Step 4: Denoising with DADA2 - shenjean/diversity GitHub Wiki

I. Remove primer sequences

If not using 16S rRNA V4/EMP protocols where PCR primers were also used as sequencing primers, primer sequences will be present in the sequences. The safest way is to remove primer sequences from the demultiplexed files before downstream analysis.

--p-error-rate specifies the maximum allowable error rate. Default is 0.1.

qiime cutadapt trim-paired \
  --i-demultiplexed-sequences pe.qza \
  --p-front-f CCAGCASCYGCGGTAATTCC \
  --p-front-r ACTTTCGTTCTTGATYR \
  --o-trimmed-sequences trimmed.qza \
  --verbose

II. Visualize the read qualities:

qiime demux summarize --i-data trimmed.qza --o-visualization trimmed.demux.qzv
  • To visualize the summaries, download the qzv files and upload/drop them to qiime2view. Click on the "Interactive Quality Plot" tab on the resulting qzv file in QIIME 2 view. Example qzv file here
  • Hover your mouse over each read position on the interactive plot to get the quality score summary (parametric seven-number summary) in real-time. From the visualization and the summaries, you can identify start and end positions where quality scores begin to increase or drop. These will guide the trimming parameters for DADA2.
  • Options available for trimming paired-end reads using DADA2 include: --p-trim-left-f, --p-trim-left-r, --p-trunc-len-f, --p-trunc-len-r. Visit this QIIME2 wiki page for more info

III. Run DADA2

In the command line, run the following command:

qiime dada2 denoise-paired --i-demultiplexed-seqs trimmed.qza --p-n-threads 8 \
--p-trim-left-f 0 --p-trim-left-r 0 --p-trunc-len-r 232 --p-trunc-len-f 0 \
--o-table pe.dada2.qza --o-representative-sequences pe.repseqs.qza \
--o-denoising-stats pe.dada2-stats.qza --o-base-transition-stats pe.base-transition-stats.qza

Once done, two new qza files will be generated. xx.repseqs.qza contains sequences of representative sequences identified by DADA2 and xx.dada2.qza is a feature table containing counts of each representative sequence in each sample. You can generate interactive graphic summaries of your qza files:

qiime feature-table tabulate-seqs --i-data pe.repseqs.qza --o-visualization pe.repseqs.qzv
qiime feature-table summarize --i-table pe.dada2.qza --o-feature-frequencies pe.feature-frequencies.qza --o-sample-frequencies pe.sample-frequencies.qza --o-summary pe.dada2.summary.qzv

From the feature-table summary, you can get the number of features (or Amplicon Sequence Variants - ASVs) per sample by clicking on the Interactive Sample Detail tab. It is especially important to visualize the feature table (pe.dada2.qzv) to get an overview of the number of ASVs found in each sample. This information shows you which samples have sufficient sequences for downstream analysis, and also the number of ASVs to use for subsampling, where you select the sampling depth for downstream alpha and beta diversity analyses.

IV. Exporting data from qza files

qiime tools export --input-path pe.dada2.qza --output-path pe_dada2_export
biom convert -i pe_dada2_export/feature-table.biom -o pe_dada2_export/otu_table.txt --to-tsv

If you want to download your ASV sequences in FASTA format, you can similarly use the export command. The command below will create a new folder repseqs_export and save the fasta file in the new folder.

qiime tools export --input-path pe.repseqs.qzv --output-path repseqs_export

V. Filtering data from feature table (Optional)

Frequency-based filtering

Depending on your dataset, you may want to filter out low-frequency features using total-frequency based filtering:

qiime feature-table filter-features --i-table pe.dada2.qza --p-min-frequency 10 --o-filtered-table feature-frequency-filtered-table.qza

Contigency-based-filtering

You may also want to filter out features that only show up in <x number of samples with contingency-based filtering:

qiime feature-table filter-features --i-table feature-frequency-filtered-table.qza --p-min-samples 2 --o-filtered-table sample-contingency-filtered-table.qza

Identifier-based filtering

Use --p-exclude-ids options to exclude samples/features in metadata file instead of retaining them

Filter features containing feature-ids listed in the featureIDs.tofilter file

qiime feature-table filter-features --i-table DADA2.qza --m-metadata-file featureIDs.tofilter --o-filtered-table DADA2.filter2.qza --p-exclude-ids

Filter samples containing sample-ids listed in the sampleIDs.tofilter file

qiime feature-table filter-samples --i-table DADA2.filter2.qza --m-metadata-file ../sampleIDs.tofilter --o-filtered-table DADA2.filter3.qza --p-exclude-ids

Metadata-based filtering

Or you can filter by metadata column values:

qiime feature-table filter-samples \
  --i-table bacteriatable.qza \
  --m-metadata-file metadata.txt \
  --p-where "[Species]='Halodule wrightii' AND [Tissue]='Leaf'" \
  --o-filtered-table metadata-filtered-table.qza