# Using deblur plugin for R1 only vs. merged R1 and R2

**URL:** <https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396>\
**Category:** User Support\
**Tags:** deblur\
**Created:** [October 3, 2017, 1:45pm UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396 "2017-10-03T13:45:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matilda\_H-D](https://forum.qiime2.org/user_avatar/forum.qiime2.org/matilda_h-d/32/576_2.png) [@Matilda\_H-D](https://forum.qiime2.org/u/Matilda_H-D)\
**Post date:** [October 3, 2017, 1:45pm UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396/1 "2017-10-03T13:45:12Z")

</div>

Hi there!

Apologies for the long post, I am hoping that providing a lot of detail will make my question easier to understand ...

Our lab has been using QIIME 1 for 16S amplicon analysis for a few years and I am testing out some analyses in QIIME 2 with a view to the whole group making the transition to QIIME 2 within the next year.

We work with 16S V4 region amplicons and use paired-end reads from an Illumina MiSeq.

In our QIIME 1 pipeline, we did the following:

- converted the bcl files from the sequencer into fastq using bcl2fastq
- concatenated R1, index and R3 files
- merged reads using BBmerge
- demultiplexed samples and performed quality control in QIIME 1 using split\_libraries.py
- performed open- and closed-reference OTU picking in QIIME 1

Our group has been keen to try out Deblur as an alternative to OTU picking, so that is what I have been working on. I learned from this forum that the deblur plugin only works with single-end sequences, so I decided to test out using R1 only vs. using paired-end reads merged with BBmerge and then imported into QIIME2 as 'single-end' sequences (I used manifest fastq format to import the reads into QIIME2 in both cases).

I tested this out on a subset of 10 samples and have found that the taxonomic profiles differ when using unmerged and merged reads -- in particular, more taxa are identified when using R1 only.

Next I wanted to know which 'additional' taxa are being identified when using R1 compared to merged reads (or another way of looking at it is which taxa are lost when using the merged reads compared to R1 only). At first I tried filtering the features found in 'merged-read' samples from the table containing both 'merged-read' and 'R1-only' samples, but then I realised this probably won't work because the merged reads are longer than the R1 reads, so there won't be any sequence variants in common between the two. I think I really want to be working at the level of taxonomy here.

I think I might be able to answer this question either by:

1. trimming the merged reads to 150bp (same length as R1), then running deblur on the merged-read and unmerged-read samples together, then filtering to retain the features that are found only in R1-read samples, then assigning taxonomy to these to see what we are 'missing' by using merged reads.  
However, I am a little concerned about losing the information in the last 100bp or so of the merged read by doing this -- is there really any advantage in using the merged reads at all if I then trim them to be the same length as an unmerged read?

2. Is there some way to filter the feature table at the level of taxonomy rather than at the level of sequence variant? Or to filter the taxonomy.qza file? I have only found scripts for filtering features or samples by abundance or by a specified index or a metadata category, and I'm not sure if I could apply those here.

Thank you so much for any advice!!  
Matilda

---

<div class="post-metadata">

**Author:** ![ebolyen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/ebolyen/32/11_2.png) [@ebolyen](https://forum.qiime2.org/u/ebolyen)\
**Post date:** [October 3, 2017, 8:28pm UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396/4 "2017-10-03T20:28:42Z")

</div>

Hi @Matilda_H-D!

This is a really great question! I suspect the biggest driver of why you see less features on the merged data is that fewer sequences make it past this implicit filter of merging. In other words, if your forward and reverse reads don't align, then you probably won't end up with a sequence at all (although BBmerge may work differently, I can't really say).

**Before even getting into the differences, you might run** `qiime demux summarize` **on both data-sets to see if there are significantly less sequences available in your merged set.**

Assuming that isn't what is causing the difference you see, we can explore the options you laid out. Option 1 might tell you something if BBmerge is the sole reason and is doing something odd at the intersection of the reads, but I think option 2 is a more complete approach (as it doesn't discard your bases), so I'll focus on that.

> [@Matilda\_H-D](#):
>
> At first I tried filtering the features found in ‘merged-read’ samples from the table containing both ‘merged-read’ and ‘R1-only’ samples, but then I realised this probably won’t work because the merged reads are longer than the R1 reads, so there won’t be any sequence variants in common between the two. I think I really want to be working at the level of taxonomy here.

That's exactly right, but there is a way to remap those features to the taxonomy that they are classified as, which will give you a common language to find the difference between the tables.

This will be a little gross, because we don't have a way to use feature-tables as metadata (yet) or to filter `FeatureData[Taxonomy]` directly. But you should be able to do the following:

1. Run `qiime taxa collapse` on your both of your feature-tables (_single-end_ and _merged_), which will map the feature IDs from ASVs to taxonomy strings (this will need your `FeatureData[Taxonomy]` artifact from each dataset). You may want to experiment with the `--p-level` parameter depending on how granular you need to be in finding the difference.

2. Next we need to find out which taxonomy strings are in your _merged_ data. (This is the gross part.) What we need to do is run `qiime feature-table summarize` on your collapsed _merged_ feature-table. Then on that first page, we're going to download the CSV for `Frequency per feature detail`: 

3. Finally, we'll use `merged-taxonomy-strings.tsv` to remove any of those features from our collapsed _single-end_ feature-table (from step 1):

```bash
qiime feature-table filter-features \
   --i-table your-collapsed-single-end-table.qza \ 
   --p-exclude-ids \
   --m-metadata-file merged-taxonomy-strings.tsv \
   --o-filtered-table single-minus-merged-table.qza

```

This should have the effect of removing every taxonomy from your _single-end_ table that was seen in your _merged_ data. Leaving you with only the unique observations in the _single-end_. You can then do whatever you want with this new "difference" table. I should mention that there's probably some assignments which will exist in the merged table but not in the single-end table, so just keep in mind that you only got rid of the assignments that were shared.

Let me know how it goes!

---

<div class="post-metadata">

**Author:** ![Matilda\_H-D](https://forum.qiime2.org/user_avatar/forum.qiime2.org/matilda_h-d/32/576_2.png) [@Matilda\_H-D](https://forum.qiime2.org/u/Matilda_H-D)\
**Post date:** [October 9, 2017, 4:40pm UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396/6 "2017-10-09T16:40:11Z")

</div>

Hi @ebolyen,

Many thanks for your response!

There are definitely many fewer sequences in the merged dataset: 486,655 total sequences versus 832,662 using unmerged R1. So there are clearly a lot of sequences in the R1 that have no overlapping R2 and so fail to merge.

However, the total number of features (sOTUs) present in each table was less than I might have expected due to the discrepancy in number of sequences (33 fewer in the merged dataset).

I guess our question is whether this loss of information in the merging step is introducing a bias we should be trying to avoid in our analysis.

I followed your suggested steps and it seems to have worked well. I collapsed the tables at Level 7. There were only 13 features in the final table (i.e. uniquely found in the unmerged table), so I guess some of the 30-odd extra features found in the unmerged dataset were similar enough to have the same classification at the species level. It would be quite nice to be able to look at what is different at the sequence variant level as well, but I'm guessing you would have suggested such a method if it existed ... ? 🙂

Also, I'm not sure I follow why there might be some assignments that are in the merged table but not in the single-end table. Shouldn't everything identified in the merged table also have been present in the single-end table? Or is it likely that taxonomic assignments could have shifted based on the extra information found in a longer read (i.e. some taxa might have been incorrectly assigned based on R1 only, but with the additional information from R2 they are correctly assigned a different taxonomy)?

Is there any potential in the future for the deblur plugin to be able to handle unmerged, paired-end data?

Thanks very much again,  
Matilda

---

<div class="post-metadata">

**Author:** ![ebolyen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/ebolyen/32/11_2.png) [@ebolyen](https://forum.qiime2.org/u/ebolyen)\
**Post date:** [October 10, 2017, 12:04am UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396/8 "2017-10-10T00:04:21Z")

</div>

> [@Matilda\_H-D](#):
>
> I guess our question is whether this loss of information in the merging step is introducing a bias we should be trying to avoid in our analysis.

It doesn't sound like you've lost too much. The bias is going to depend on who's in your sample, as length can be a source of systematic bias if certain clades just happen to have a longer than average target region. Since you've already denoised both ways (this is usually the lengthy process) it should be relatively fast to run your analysis both ways and see if there are any meaningful differences in your interpretation of those results.

> [@Matilda\_H-D](#):
>
> I followed your suggested steps and it seems to have worked well. I collapsed the tables at Level 7. There were only 13 features in the final table (i.e. uniquely found in the unmerged table), so I guess some of the 30-odd extra features found in the unmerged dataset were similar enough to have the same classification at the species level.

Awesome!

> [@Matilda\_H-D](#):
>
> It would be quite nice to be able to look at what is different at the sequence variant level as well, but I’m guessing you would have suggested such a method if it existed … ?

You could cross-reference using your `FeatureData[Taxonomy]` and `qiime metadata tabulate`. But that'll be a bit painful, and you still can't really map the single-end ASVs to the paired-end ASVs in any meaningful way (other than taxonomy/OTU clustering).

> [@Matilda\_H-D](#):
>
> Shouldn’t everything identified in the merged table also have been present in the single-end table? Or is it likely that taxonomic assignments could have shifted based on the extra information found in a longer read (i.e. some taxa might have been incorrectly assigned based on R1 only, but with the additional information from R2 they are correctly assigned a different taxonomy)?

Exactly that. So it's possible your merged reads will have a more precise annotation thanks to the longer length.

> [@Matilda\_H-D](#):
>
> Is there any potential in the future for the deblur plugin to be able to handle unmerged, paired-end data?

I'm not sure. @wasade would know the answer to that though!

---

<div class="post-metadata">

**Author:** ![wasade](https://forum.qiime2.org/user_avatar/forum.qiime2.org/wasade/32/2317_2.png) [@wasade](https://forum.qiime2.org/u/wasade)\
**Post date:** [October 10, 2017, 4:32pm UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396/10 "2017-10-10T16:32:53Z")

</div>

Thanks @ebolyen for the ping. With paired data, I really like going back to the RDP classifier paper, [Wang et al 2007](https://www.ncbi.nlm.nih.gov/pubmed/17586664), which highlights the limitations of longer fragments when assigning taxonomy using naive Bayes. Ultimately, the assignments are going to be contingent on the correctness and resolution of the reference database irrespective of the assignment method.

@Matilda_H-D, as you observed as well, there is generally a loss of depth too in the pairing process. In addition, there is an implicit increased tolerance for error (both on the merge and in R2). I'm not aware of a comprehensive independent benchmark that has compared the pros and cons of merging reads; for questions of relative differences in alpha diversity, beta diversity, and probably taxonomy given the resolution of 16S, my guess is that for many questions asked in microbiome studies, pairing reads probably will not alter the conclusions drawn. It is possible that paired data may actually lead to inaccurate conclusions from reduced coverage or taxonomic misassignment due to merge or quality issues.

I do not believe it is assured that things identified in the merged table will be present in the single-end table. The merge process is unlikely to be perfect, many taxons are polyphyletic, and all references databases contain chimeras.

@Matilda_H-D, do your specific question, we do not have that planned at this time. Our present method of handling paired data is in effect how you used Deblur, where the pairing happens upstream and Deblur remains agnostic.

Best,  
Daniel

---

<div class="post-metadata">

**Author:** ![Matilda\_H-D](https://forum.qiime2.org/user_avatar/forum.qiime2.org/matilda_h-d/32/576_2.png) [@Matilda\_H-D](https://forum.qiime2.org/u/Matilda_H-D)\
**Post date:** [October 12, 2017, 4:17pm UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396/11 "2017-10-12T16:17:07Z")

</div>

Thanks very much to both @ebolyen and @wasade for your helpful responses!

At this stage I think I will proceed with testing some analyses and seeing how much merging actually changes the conclusions.

One last thing: I repeated Evan's suggested filtering workflow in reverse to see if there were any taxa that were uniquely found in the merged dataset. As you both suggested, there are indeed some things that appear only after merging, although there are only three of these features, compared to thirteen that are unique to the unmerged (at species level).

I think I understand what is going on, but just to be sure: two of the taxonomy strings that were 'unique to the merged table' were identical to two that were 'unique to the unmerged table'. So this means that, if I followed the steps correctly, although there appear to be identical 'unique' things, they are actually different at the sequence variant and at the species level, we just can't distinguish them from the taxonomic assignments although they could be distinguished by sequence? (The assignments in question are at genus and family level.)

Thanks again,  
Matilda

---

<div class="post-metadata">

**Author:** ![ebolyen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/ebolyen/32/11_2.png) [@ebolyen](https://forum.qiime2.org/u/ebolyen)\
**Post date:** [October 12, 2017, 10:26pm UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396/13 "2017-10-12T22:26:06Z")

</div>

> [@Matilda\_H-D](#):
>
> I think I understand what is going on, but just to be sure: two of the taxonomy strings that were ‘unique to the merged table’ were identical to two that were ‘unique to the unmerged table’. So this means that, if I followed the steps correctly, although there appear to be identical ‘unique’ things, they are actually different at the sequence variant and at the species level, we just can’t distinguish them from the taxonomic assignments although they could be distinguished by sequence? (The assignments in question are at genus and family level.)

By the time we start filtering the table (to see what's unique to that dataset) there isn't any ASV information left. Everything is a taxonomy string. So in principle, you shouldn't see any shared features between the two differences: `unmerged - merged` and `merged - unmerged`.

Could you share the "unique" taxonomy strings that seem to be shared? I'm guessing they are subtly different in some way that the computer is seeing (such as a trailing `;` or `s__` or something) but which is otherwise not very meaningful.

---

<div class="post-metadata">

**Author:** ![Matilda\_H-D](https://forum.qiime2.org/user_avatar/forum.qiime2.org/matilda_h-d/32/576_2.png) [@Matilda\_H-D](https://forum.qiime2.org/u/Matilda_H-D)\
**Post date:** [October 12, 2017, 11:44pm UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396/15 "2017-10-12T23:44:36Z")

</div>

> By the time we start filtering the table (to see what’s unique to that dataset) there isn’t any ASV information left. Everything is a taxonomy string. So in principle, you shouldn’t see any shared features between the two differences: unmerged - merged and merged - unmerged.

Hmm, but if the tables were collapsed at L7, isn't it possible there would be features (for want of a better word) that have the same taxonomic assignment (especially if not named down the species level) but are different enough to be classified as different species? Maybe I don't understand quite what is happening when they're collapsed. Should I actually have collapsed at a lower taxonomic level if I don't have species-level assignments for all the taxa?

> Could you share the “unique” taxonomy strings that seem to be shared? I’m guessing they are subtly different in some way that the computer is seeing (such as a trailing ; or s\_\_ or something) but which is otherwise not very meaningful.

Sure!

```auto
k __Bacteria;p__ Actinobacteria;c __Actinobacteria;o__ Actinomycetales;f __Corynebacteriaceae;g__ Corynebacterium;s__

```

vs.

```auto
k __Bacteria;p__ Actinobacteria;c __Actinobacteria;o__ Actinomycetales;f __Corynebacteriaceae;g__ Corynebacterium;s__

```

and

```auto
k __Bacteria;p__ Firmicutes;c __Clostridia;o__ Clostridiales;f __Veillonellaceae;__ ;__

```

vs.

```auto
k __Bacteria;p__ Firmicutes;c __Clostridia;o__ Clostridiales;f __Veillonellaceae;g__ ;s__

```

So having just done that, I can see that the second pair (Veillonellaceae) are actually not exactly the same because one has the 'g' and 's' and the other doesn't (would you mind explaining why this would happen?), but the first pair still look the same to me.

I'm pretty sure I used the pretrained Greengenes 13.8 99% feature classifier to assign taxonomies -- sorry I'm not at the office at the moment so can't check for sure.

Thanks!

---

<div class="post-metadata">

**Author:** ![ebolyen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/ebolyen/32/11_2.png) [@ebolyen](https://forum.qiime2.org/u/ebolyen)\
**Post date:** [October 13, 2017, 11:58pm UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396/17 "2017-10-13T23:58:59Z")

</div>

> [@Matilda\_H-D](#):
>
> Hmm, but if the tables were collapsed at L7, isn’t it possible there would be features (for want of a better word) that have the same taxonomic assignment (especially if not named down the species level) but are different enough to be classified as different species?

Your intuition is correct, it's just that collapsing basically sums up all of the observations at a given taxonomic level's assignment. So before you collapse the table, you have that information between your table and the `FeatureData[Taxonomy]`, but once you collapse, the individual sequences get smushed together into the same taxonomy string.

* * *

As an example:

FeatureTable[Frequency]

```auto
    f1 f2 f3
s1 1 1 1
s2 0 9 1

```

FeatureData[Taxonomy]

```auto
f1 k __X;p__ Y;c__Z
f2 k __X;p__ Y;c__Z
f3 k __A;p__ B;c__C

```

After collapsing:

```auto
    k __X;p__ Y;c __Z k__ A;p __B;c__ C
s1 2 1
s2 9 1

```

* * *

> [@Matilda\_H-D](#):
>
> So having just done that, I can see that the second pair (Veillonellaceae) are actually not exactly the same because one has the ‘g’ and ‘s’ and the other doesn’t (would you mind explaining why this would happen?), but the first pair still look the same to me.

The one without the `g` / `s` was only assigned to `k __Bacteria;p__ Firmicutes;c __Clostridia;o__ Clostridiales;f __Veillonellaceae` but that isn't 7 levels deep, so it `qiime taxa collapse` padded it out with `__ `. The one that ended with `g` / `s` was assigned to an OTU that didn't have a genus/species specific annotation in Greengenes.

As for the first set, I honestly have no explanation as to why and how that happened. Would you be able to DM me the two collapsed and filtered tables? I can double check a couple things in the provenance to make sure something didn't go wrong.  
(Just as a sanity-check, there's definitely _some_ shared features that are removed from both tables right? The filtering hasn't failed to remove things?)

---

<div class="post-metadata">

**Author:** ![ebolyen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/ebolyen/32/11_2.png) [@ebolyen](https://forum.qiime2.org/u/ebolyen)\
**Post date:** [October 16, 2017, 5:13pm UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396/19 "2017-10-16T17:13:35Z")

</div>

Just following up here!

@Matilda_H-D discovered the mistake in my instructions that was causing `...;g __Corynebacterium;s__ ` to show up in both tables after filtering.

The first line of a metadata file is always treated as a header line. The above string was the first line in the `.csv` that was pulled off of the summarize visualizations. This meant that even though it was assigned in both datasets, the `feature-data filter-features` command never actually got to see the ID to remove it.

---

<div class="post-metadata">

**Author:** ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)\
**Post date:** [November 16, 2017, 11:13pm UTC](https://forum.qiime2.org/t/using-deblur-plugin-for-r1-only-vs-merged-r1-and-r2/1396/20 "2017-11-16T23:13:36Z")

</div>

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
