GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing benjjneb.github.io — DADA2 Pipeline Tutorial (1.16) DADA2 Pipeline Tutorial (1.16)Here we walk through version 1.16 of the DADA2 pipeline on a small multi-sample dataset. Our starting point is a set of Illumina-sequenced paired-end fastq files that have been split (or “demultiplexed”) by sample and from which the barcodes/adapters have already been removed. The end product is an amplicon sequence variant (ASV) table, a higher-resolution analogue of the traditional OTU table, which records the number of times each exact amplicon sequence variant was observed in each sample. We also assign taxonomy to the output sequences, and demonstrate how the data can be imported into the popular phyloseq R package for the analysis of microbiome data. Starting pointThis workflow assumes that your sequencing data meets certain criteria:
If these criteria are not true for your data (are you sure there aren’t any primers hanging around?) you need to remedy those issues before beginning this workflow. See the FAQ for recommendations for some common issues. Getting readyFirst we load the
Older versions of this workflow associated with previous release versions of the dada2 R package are also available: 1.6, 1.8. The data we will work with are the same as those used in the mothur MiSeq SOP. To follow along, download the example data and unzip. These fastq files were generated by 2x250 Illumina Miseq amplicon sequencing of the V4 region of the 16S rRNA gene from gut samples collected longitudinally from a mouse post-weaning. For now just consider them paired-end fastq files to be processed. Define the following path variable so that it points to the extracted directory on your machine:
If the package successfully loaded and your listed files match those here, you are ready to go through the DADA2 pipeline. Now we read in the names of the fastq files, and perform some string manipulation to get matched lists of the forward and reverse fastq files.
Considerations for your own
data: The string manipulations may have to be modified
if your filename format is different.
Inspect read quality profilesWe start by visualizing the quality profiles of the forward reads:
In gray-scale is a heat map of the frequency of each quality score at each base position. The mean quality score at each position is shown by the green line, and the quartiles of the quality score distribution by the orange lines. The red line shows the scaled proportion of reads that extend to at least that position (this is more useful for other sequencing technologies, as Illumina reads are typically all the same length, hence the flat red line). The forward reads are good quality. We generally advise trimming the last few nucleotides to avoid less well-controlled errors that can arise there. These quality profiles do not suggest that any additional trimming is needed. We will truncate the forward reads at position 240 (trimming the last 10 nucleotides). Now we visualize the quality profile of the reverse reads:
The reverse reads are of significantly worse quality, especially at the end, which is common in Illumina sequencing. This isn’t too worrisome, as DADA2 incorporates quality information into its error model which makes the algorithm robust to lower quality sequence, but trimming as the average qualities crash will improve the algorithm’s sensitivity to rare sequence variants. Based on these profiles, we will truncate the reverse reads at position 160 where the quality distribution crashes.
Considerations for your own
data: Your reads must still overlap after
truncation in order to merge them later! The tutorial is using
2x250 V4 sequence data, so the forward and reverse reads almost
completely overlap and our trimming can be completely guided by the
quality scores. If you are using a less-overlapping primer set, like
V1-V2 or V3-V4, your
truncLen must be large enough to
maintain 20 + biological.length.variation nucleotides of
overlap between them.
Filter and trimAssign the filenames for the filtered fastq.gz files.
We’ll use standard filtering parameters:
Considerations for your own
data: The standard filtering parameters are starting
points, not set in stone. If you want to speed up downstream
computation, consider tightening
maxEE. If too few reads
are passing the filter, consider relaxing maxEE, perhaps
especially on the reverse reads (eg. maxEE=c(2,5)), and
reducing the truncLen to remove low quality tails. Remember
though, when choosing truncLen for paired-end reads you
must maintain overlap after truncation in order to merge them later.
Considerations for your own
data: For ITS sequencing, it is usually undesirable to
truncate reads to a fixed length due to the large length variation at
that locus. That is OK, just leave out
truncLen. See the DADA2 ITS workflow for more information
Alternatives: Zymo Research has recently developed a tool called Figaro that can help you choose DADA2 truncation length parameters: https://github.com/Zymo-Research/figaro#figaro
Learn the Error RatesThe DADA2 algorithm makes use of a parametric error model
( The following runs in about 3 minutes on a 2013 Macbook Pro:
It is always worthwhile, as a sanity check if nothing else, to visualize the estimated error rates:
The error rates for each possible transition (A→C, A→G, …) are shown. Points are the observed error rates for each consensus quality score. The black line shows the estimated error rates after convergence of the machine-learning algorithm. The red line shows the error rates expected under the nominal definition of the Q-score. Here the estimated error rates (black line) are a good fit to the observed rates (points), and the error rates drop with increased quality as expected. Everything looks reasonable and we proceed with confidence.
Sample InferenceWe are now ready to apply the core sample inference algorithm to the filtered and trimmed sequence data.
Inspecting the returned
The DADA2 algorithm inferred 128 true sequence variants from the 1979
unique sequences in the first sample. There is much more to the
Considerations for your own
data: DADA2 also supports 454 and Ion Torrent data, but
we
recommend some minor parameter changes for those pyrosequencing
technologies. The adventurous can explore
?setDadaOpt for
other adjustable algorithm parameters.
Extensions: By default,
the
dada function processes each sample independently.
However, pooling information across samples can increase sensitivity to
sequence variants that may be present at very low frequencies in
multiple samples. The dada2 package offers two types of pooling.
dada(..., pool=TRUE) performs standard
pooled processing, in which all samples are pooled together for sample
inference. dada(..., pool="pseudo") performs
pseudo-pooling, in which samples
are processed independently after sharing information between samples,
approximating pooled sample inference in linear time.
Merge paired readsWe now merge the forward and reverse reads together to obtain the full denoised sequences. Merging is performed by aligning the denoised forward reads with the reverse-complement of the corresponding denoised reverse reads, and then constructing the merged “contig” sequences. By default, merged sequences are only output if the forward and reverse reads overlap by at least 12 bases, and are identical to each other in the overlap region (but these conditions can be changed via function arguments).
The
Considerations for your own
data: Most of your reads should
successfully merge. If that is not the case upstream parameters may need
to be revisited: Did you trim away the overlap between your reads?
Extensions:
Non-overlapping reads are supported, but not recommended, with
mergePairs(..., justConcatenate=TRUE).
Construct sequence tableWe can now construct an amplicon sequence variant table (ASV) table, a higher-resolution version of the OTU table produced by traditional methods.
The sequence table is a
Considerations for your own
data: Sequences that are much longer or shorter than
expected may be the result of non-specific priming. You can remove
non-target-length sequences from your sequence table (eg.
seqtab2 <- seqtab[,nchar(colnames(seqtab)) %in% 250:256]).
This is analogous to “cutting a band” in-silico to get amplicons of the
targeted length.
Remove chimerasThe core
The frequency of chimeric sequences varies substantially from dataset to dataset, and depends on on factors including experimental procedures and sample complexity. Here chimeras make up about 21% of the merged sequence variants, but when we account for the abundances of those variants we see they account for only about 4% of the merged sequence reads.
Considerations for your own
data: Most of your reads should remain
after chimera removal (it is not uncommon for a majority of
sequence variants to be removed though). If most of
your reads were removed as chimeric, upstream processing may need to be
revisited. In almost all cases this is caused by primer sequences with
ambiguous nucleotides that were not removed prior to beginning the DADA2
pipeline.
Track reads through the pipelineAs a final check of our progress, we’ll look at the number of reads that made it through each step in the pipeline:
Looks good! We kept the majority of our raw reads, and there is no over-large drop associated with any single step.
Considerations for your own
data: This is a great place to do a last sanity
check. Outside of filtering, there should no step in which a
majority of reads are lost. If a majority of reads failed to merge, you
may need to revisit the
truncLen parameter used in the
filtering step and make sure that the truncated reads span your
amplicon. If a majority of reads were removed as chimeric, you may need
to revisit the removal of primers, as the ambiguous nucleotides in
unremoved primers interfere with chimera identification.
Assign taxonomyIt is common at this point, especially in 16S/18S/ITS amplicon
sequencing, to assign taxonomy to the sequence variants. The DADA2
package provides a native implementation of the naive Bayesian
classifier method for this purpose. The We maintain formatted training fastas for the
RDP training set, GreenGenes clustered at 97% identity, and the Silva
reference database, and additional trainings fastas suitable for
protists and certain specific environments have been contributed. For
fungal taxonomy, the General Fasta release files from the UNITE ITS database can be
used as is. To follow along, download the
Extensions: The
dada2 package also implements a method to make species level assignments based on
exact matching between ASVs and sequenced reference
strains. Recent analysis suggests that exact
matching (or 100% identity) is the only appropriate way to assign
species to 16S gene fragments. Currently, species-assignment training fastas are available
for the Silva and RDP 16S databases. To follow the optional species
addition step, download the
Let’s inspect the taxonomic assignments:
Unsurprisingly, the Bacteroidetes are well represented among the most abundant taxa in these fecal samples. Few species assignments were made, both because it is often not possible to make unambiguous species assignments from subsegments of the 16S gene, and because there is surprisingly little coverage of the indigenous mouse gut microbiota in reference databases.
Considerations for your own
data: If your reads do not seem to be appropriately
assigned, for example lots of your bacterial 16S sequences are being
assigned as
Eukaryota NA NA NA NA NA, your reads may be in
the opposite orientation as the reference database. Tell dada2 to try
the reverse-complement orientation with
assignTaxonomy(..., tryRC=TRUE) and see if this fixes the
assignments. If using DECIPHER for taxonomy, try
IdTaxa (..., strand="both").
Alternatives: The
recently developed
The taxid matrix from IdTaxa is a drop-in
replacement for the taxa matrix from
assignTaxonomy, simply set taxa <- taxid to
carry on using the IdTaxa assignments. Read more about
IdTaxa and other useful tools at the DECIPHER R package website.
Evaluate accuracyOne of the samples included here was a “mock community”, in which a mixture of 20 known strains was sequenced (this mock community is supposed to be 21 strains, but P. acnes is absent from the raw data). Reference sequences corresponding to these strains were provided in the downloaded zip archive. We return to that sample and compare the sequence variants inferred by DADA2 to the expected composition of the community. Evaluating DADA2’s accuracy on the mock community:
This mock community contained 20 bacterial strains. DADA2 identified 20 ASVs all of which exactly match the reference genomes of the expected community members. The residual error rate after the DADA2 pipeline for this sample is 0%. Here ends the DADA2 portion of the tutorial. Bonus: Handoff to phyloseqThe phyloseq R package is a powerful framework for further analysis of microbiome data. We now demonstrate how to straightforwardly import the tables produced by the DADA2 pipeline into phyloseq. We’ll also add the small amount of metadata we have – the samples are named by the gender (G), mouse subject number (X) and the day post-weaning (Y) it was sampled (eg. GXDY). Import into phyloseq:
We can construct a simple sample
We now construct a phyloseq object directly from the dada2 outputs.
It is more convenient to use short names for our ASVs (e.g. ASV21)
rather than the full DNA sequence when working with some of the tables
and visualizations from phyloseq, but we want to keep the full DNA
sequences for other purposes like merging with other datasets or
indexing into reference databases like the Earth Microbiome Project.
For that reason we’ll store the DNA sequences of our ASVs in the refseq
slot of the phyloseq object, and then rename our taxa to a short string.
That way, the short new taxa names will appear in tables and plots, and
we can still recover the DNA sequences corresponding to each ASV as
needed with
We are now ready to use phyloseq! Visualize alpha-diversity:
No obvious systematic difference in alpha-diversity between early and late samples. Ordinate:
Ordination picks out a clear separation between the early and late samples. Bar plot:
Nothing glaringly obvious jumps out from the taxonomic distribution of the top 20 sequences to explain the early-late differentiation. These were minimal examples of what can be done with phyloseq, as our purpose here was just to show how the results of DADA2 can be easily imported into phyloseq and interrogated further. For examples of the many analyses possible with phyloseq, see the phyloseq web site! Maintained by Benjamin Callahan (benjamin DOT j DOT callahan AT gmail DOT com) Documentation License: CC-BY 4.0 |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |