extract-seq-segments: number of reads vs accuracy of reads.

Hi Mike,

I read this from your post: "But if you are hoping to strictly stay within the bounds of your expected amplicon length, then Id simply do more iterations, at a much higher similarity, say 90% then go up.", and I'm curious if you could elaborate more on scenarios where we would want to stay within the bounds of amplicon length versus accepting longer sequence lengths?

I am following your tutorial to build a custom reference db for COI ANML primers, which target a segment of 157bp long (Jusino et al 2018) for an avian diet metabarcoding study. So far I've built two databases with three iterations, where -p-perc-identity has been set to 1) 70>80>90%, and 2) 90>94>97%. Unlike John, I am not experiencing huge differences in the sequence lengths between iterations, but the two resulting databases are different enough that I am struggling to decide which to train the naive-bayes classifier with. For 90>94>97%, I get a sequence count of 200k+ with the mean length is just about right where our target length is. In contrast, the mean length of the 70>80>90% database is about 50bp longer than target, but has 1 Million sequences.

To me, 1 million vs 200k references is quite a significant difference, and could mean more prey items get identified, but I'm not sure if I should prioritize the accuracy of the mean read length, or if I am missing any other considerations when making this decision. I am a complete newbie to DNA metabarcoding, so I would really appreciate some advice on how to decide which database to proceed with. Thank you for your time!

versus

Hi @deClare125,

Thank you for trying the extract-seq-segments pipeline and providing your outputs!

I think at the time I responded to that post about length variation, we did not implement both of the --p-min-seq-len and --p-max-seq-len options. When these options are used, there will be a noticeable drop in sequence length creep that we initially observed, and should not be as large of a problem as it used to be. :slight_smile:

Figuring out which sequence lengths are the appropriate bounds can vary depending on the amplicon segment you are after. For example, this can be problematic for highly variable length genes, as I discuss in some of our other forum tutorials. Anecdotally, I've found that using more iterations at high identity (after an initial 70-80% identity extraction) works better for high-variable length genes. But your mileage may vary.

Like you've done, I base my selection of possible gene segment lengths on the literature. Then I set the min & max values to that. Actually, I often add another 10-20% to the max length, as there is always length variation.

I personally always like to start with 70% identity for my first step, as you grab a far wider pool of reference sequences. You can see this in the first iteration of your "70>80>90" processing. You grab more references in your first iteration there, than all three iterations from your "90>94>97" processing.

This is kind of the conundrum, starting off with higher identities means you 'll need to perform more iterations, as your pool will grow more slowly, compared to lower identities. That is, at high identities you may need to run 6, 7, or 8 iterations, where as with lower identities you many only need ~3 or so. The only risk with applying too many low identity iterations is the potential to extract spurious segments. Especially, from the few larger length sequences that might be in your reference pool, e.g. chromosome fragments, etc....

Think of it this way, if I extract a sequence segment that has ~70% identity to my query (~30% divergent). Then that newly extracted segment becomes part of the new query pool. Then in my next iteration, that new query sequence might extract a fragment with a ~70% identity to it. Which means that, the newly extracted sequence from the 2nd iteration is now ~ 60% divergent from the initial query.

^^This is how the new query segment pool is intentionally grown. But you can also see how this can generate problems if too many low identity iterations occur. It appears that you observe some length variation, to a minor degree, in your "70>80>90" processing given the observed increase in 50 bp length. Which may not be a problem(?).

Historically, I've liked to start with 70% identity. For some reference data sets, I think simply performing one iteration at 70% identity followed by 90% identity worked well enough for my needs at the time. Some other gene segments I prepared required 2-3 initial iterations at 70%, because my initial segment pool was not very diverse to begin with.

I guess that is the key point here: knowing how broad, or not, your initial reference segment pool is. If the starting segment pool is already quite diverse, then you might be fine starting with ~80% identity or higher, followed by other more strict identities.

In a nut shell, my "go to" approach is to do the following (assuming I have nothing else to inform my decisions on identity or number of iteration cycles): 70 > ~85 > ~95, while using the --p-max-seq-len option.

To wrap up, given the information you provided, I'd trust your "70>80>90" processing. Especially, if you leverage the --p-max-seq-len option. Alternatively, you can combine that option with extracting segments at 80% > 90%.

Also, do not forget that you can assess the quality of your reference databases following the approach outlined here.

-I hope this helps!
-Cheers!

Hi Mike,

Thank you so much for your detailed response!

Think of it this way, if I extract a sequence segment that has ~70% identity to my query (~30% divergent). Then that newly extracted segment becomes part of the new query pool. Then in my next iteration, that new query sequence might extract a fragment with a ~70% identity to it. Which means that, the newly extracted sequence from the 2nd iteration is now ~ 60% divergent from the initial query.

This was particularly helpful and clarified a lot for me. I ended up doing another run with the --p-max-seq-len flag as you suggested and wound up with a 70>85>95 database I think I am satisfied with proceeding with. It (alongside the 70>80>90 set which I had run without the the max seq len filter) are in training now. I'll update you if I have any questions about how they performed.

Since my diet study is using two genes, I also ran this for 16S (I used NCBI data). However, despite the initial data download pulling way more reads than the COI off the get go (67k vs 14k), running 70>85>95% and even 70>80>95% did not produce very many more reads and both databases topped out at ~190k reads. I suspect I need more iterations in between (versus pivoting to a different database like midori as you've suggested here), but I was curious if you had any thoughts on improving the yield without adding too many spurious or irrelevant reads.

Thank you again for your help!

Sincerely,

Clare

No worries! :slight_smile:

For the SSU, and other genes, I sometimes see a drop as I go higher. But I think that might due to the underlying max accepts / rejects options that vsearch is using. That is, if either of those limits are exceeded, the search terminates. Thus, you can get a decrease in the items found compared to the previous step. I'll have to double check and see if we can expose those parameters. Though I thought we had left those to be exhaustive searches ...

Perhaps, in this case, 95 % might be less effective compared to 90%? But yeah, there is always going to be a plateau. Also, if you are extracting from the majority of your downloaded dereplicated data, e.g. say 60-70%, then I think you are good to go. Remember GenBank is mainly a repository, and the quality of the data is in the form of whomever uploaded it, good or bad. So, I'd not worry too much about "getting it all". As long as the taxonomic assignment make sense given your study system. :slight_smile:

I assume you are dereplicating the downloaded GenBank data prior to search extraction? Then generally following the rest of the tutorial? That is, dereplicate and cull sequences each cycle? I ask because this usually helps with limiting spurious extractions and reduce those search penalties I mentioned above. But then again, this is a whole lot of data.

Personally, it should not take much effort to use SILVA or MIDORI 2 for your SSU needs, especially as they've done all the hard work curating much of the data for you. Also, these reference databases would serve as a great sanity check compared to the GenBank data. I'd suspect that one, or both of these other reference databases might be better here, but I've never thoroughly compared them. In fact, this might make a nice comparison narrative in your eventual manuscript. :slight_smile: