# dereplicating "error" ... or, how to fix a typo.

**URL:** <https://forum.qiime2.org/t/dereplicating-error-or-how-to-fix-a-typo/16354>\
**Category:** User Support\
**Tags:** dereplicate\
**Created:** [August 31, 2020, 9:56pm UTC](https://forum.qiime2.org/t/dereplicating-error-or-how-to-fix-a-typo/16354 "2020-08-31T21:56:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![devonorourke](https://forum.qiime2.org/user_avatar/forum.qiime2.org/devonorourke/32/3110_2.png) [@devonorourke](https://forum.qiime2.org/u/devonorourke)\
**Post date:** [August 31, 2020, 9:56pm UTC](https://forum.qiime2.org/t/dereplicating-error-or-how-to-fix-a-typo/16354/1 "2020-08-31T21:56:03Z")

</div>

I've been working on building a COI database from NCBI references, and separately, building a COI database from BOLD references. I wanted to _combine_ the two and evaluate this merged data set. Part of that merging requires a dereplication step after combining the sequence and taxonomy records. I was getting an output wasn't quite right - the dereplicated output was created without error, but a large number of sequences contained nearly empty taxonomy strings. Something 1/3 of all my sequences (tens of thousands!) had a string that looked like this:

```auto
derep_001 Animalia;Chordata; c __; o__ ; f __; g__ ; s__

```

Weird, right? Why would so many taxa get squashed that way. I got started with a bit of 🔎 detective work by running `VSEARCH --derep_fulllength` and generated a .uc file to see if I could identify cases where BOLD and NCBI sequences were good hits, but one was chosen over the other. Here's one of those hits:

```auto
NCBI_abc	Animalia;Chordata;Actinopteri;Tetraodontiformes;Monacanthidae;Meuschenia;Meuschenia scaber
BOLD_xyz	Animalia;Chordata;Actinopterygii;Tetraodontiformes;Monacanthidae;Meuschenia;Meuschenia scaber

```

Did you spot it? Those darn fish 🐟 ...

@BenKaehler - when I run `get-ncbi-data`, I'm sure `Actinopteri` is the Class you end up pulling, but I'm wondering why, and how often, BOLD is using these alternative naming schemes across the entire Taxonomy string ( example here, BOLD's _Actinopterygii_ vs. NCBI's _Actinopteri_).

@SoilRotifer - There must be a way I can try to automate this, right? Something like making a list of all the strings from Kingdom through Family, maybe, and getting total counts of each, and then comparing how often the two names are identical... ugh. This seems like it's destined to be a manual task.

Thanks for any strategies you can think of that might help me account for instances when BOLD and NCBI are going to end up using different naming strategies.

```auto

```

---

<div class="post-metadata">

**Author:** ![SoilRotifer](https://forum.qiime2.org/user_avatar/forum.qiime2.org/soilrotifer/32/21071_2.png) [@SoilRotifer](https://forum.qiime2.org/u/SoilRotifer)\
**Post date:** [September 1, 2020, 12:01am UTC](https://forum.qiime2.org/t/dereplicating-error-or-how-to-fix-a-typo/16354/2 "2020-09-01T00:01:59Z")

</div>

Hi @devonorourke,

I've encountered this quite often. Welcome to the world of ever-changing and inconsistent taxonomies and taxonomy curation. Back in the day when I used UTAX / SINTAX (usearch), there was a step where it would warn you about "multiple parents" for lower-level taxonomies. Which would be highlighted in this case. There was another output that outlined exactly how the dereplicated sequence taxonomy was produced. In short... it was a very manual process.. as I would just remove records that were obviously wrong.

You've probably seen many arthropod and mollusc taxonomies that have the same exact sequence! Basically, researchers submit a sequence for one.. when it is really a contaminant sequence of another. This combination gave me many empty taxonomy strings.

Also, this is where other LCA taxonomy options may help. Majority-rule LCA might alleviate this problem, as it will just take the taxonomic annotation that occurs more often for that sequence... then again, that may note completely work either.

Not sure if this is possible, but if there is a way to construct a mapping of BOLD IDs to NCBI IDs, you can just replace one with the other, to use the taxonomy string of choice. For each case you'll have to decide if you want the BOLD or the NCBI string. Either, or both, could be wrong...🤷‍♂️

-Mike

---

<div class="post-metadata">

**Author:** ![devonorourke](https://forum.qiime2.org/user_avatar/forum.qiime2.org/devonorourke/32/3110_2.png) [@devonorourke](https://forum.qiime2.org/u/devonorourke)\
**Post date:** [September 1, 2020, 12:19am UTC](https://forum.qiime2.org/t/dereplicating-error-or-how-to-fix-a-typo/16354/3 "2020-09-01T00:19:09Z")

</div>

Thanks for the validation in knowing I'm not crazy, and there isn't a single and simple step to resolve this.

I'm going to amend the title at the moment as:  
"Resolving taxonomic identities in COI, or 🤷‍♂️ 🤷‍♀️ 🤯"...

On the plus side, as I've started to make manual edits, I'm learning about the wide world of animal taxonomy... so many weird and amzing critters... 🐛 🐡

Turns out that I can account for a lot of the major discrepancies between BOLD and NCBI at the Class level. After a bit of digging, it appears that it's frequently the case that a BOLD class name is a subclass in NCBI, and making that switch to the NCBI name is sufficient to resolve the two completely. Fortunately, just a handful of these Class names resolve tens of thousands of sequences:

```auto
BOLD taxa | NCBI taxa
## direction of switch
-----------------------
c __Actinopterygii --> c__ Actinopteri
c __Reptilia --> c__ Lepidosauria
c __Elasmobranchii --> c__ Chondrichthyes
c __Copepoda --> c__ Hexanauplia
c __Thecostraca --> c__ Hexanauplia

```

Of course, I'm not proposing these are the _correct_ names. Just that they should represent the same kind of thing with the same name, insofar as for my comparison of shared labels. If you spot anything here that seems like the switch should be in the reverse, feel free to let me know.

---

<div class="post-metadata">

**Author:** ![BenKaehler](https://forum.qiime2.org/user_avatar/forum.qiime2.org/benkaehler/32/1693_2.png) [@BenKaehler](https://forum.qiime2.org/u/BenKaehler)\
**Post date:** [September 2, 2020, 6:11am UTC](https://forum.qiime2.org/t/dereplicating-error-or-how-to-fix-a-typo/16354/4 "2020-09-02T06:11:00Z")

</div>

Hi @devonorourke, along the same lines, I'm not sure whether this is useful, but you could ask for

```auto
--p-ranks kingdom phylum superclass order family genus species 

```

and that would solve the problem for _Meuschenia scaber_. It would probably cause a bunch of other problems, though.

---

<div class="post-metadata">

**Author:** ![SoilRotifer](https://forum.qiime2.org/user_avatar/forum.qiime2.org/soilrotifer/32/21071_2.png) [@SoilRotifer](https://forum.qiime2.org/u/SoilRotifer)\
**Post date:** [September 2, 2020, 1:12pm UTC](https://forum.qiime2.org/t/dereplicating-error-or-how-to-fix-a-typo/16354/5 "2020-09-02T13:12:52Z")

</div>

@devonorourke You're giving me horrible flashbacks! 😱  
I was looking through some of my old parsing code from several years ago, and what I had to do, depending on the marker gene and the available taxonomy for that marker gene, I would do what @BenKaehler suggested... that is, look at the overall accounting of available ranks for the sequence data I was trying to taxonomically curate. Often this required me to use a _super-_ or _sub-_ rank. I wish I would have remembered to suggest this earlier. But it looks like you've got it!

---

<div class="post-metadata">

**Author:** ![devonorourke](https://forum.qiime2.org/user_avatar/forum.qiime2.org/devonorourke/32/3110_2.png) [@devonorourke](https://forum.qiime2.org/u/devonorourke)\
**Post date:** [September 2, 2020, 1:51pm UTC](https://forum.qiime2.org/t/dereplicating-error-or-how-to-fix-a-typo/16354/6 "2020-09-02T13:51:13Z")

</div>

Great - thanks for the idea @BenKaehler.

The problems, as you might expect, run deep, and aren't as simple as a single taxonomic level change. In fact, in the example I gave above with the fish, NCBI uses _both_ terms ("Actinopterygii" and "Actinopteri") as a Class label, so... I guess I need to just do the best I can, manually, for now.

Makes me think there will never be a simple way to programmatically merge BOLD and NCBI. In my first foray into cleaning up BOLD and NCBI records, there's not an obvious "X references are less messy", but perhaps others could articulate a reason to favor one over another.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![devonorourke](https://forum.qiime2.org/user_avatar/forum.qiime2.org/devonorourke/32/3110_2.png) [@devonorourke](https://forum.qiime2.org/u/devonorourke)\
**Post date:** [September 2, 2020, 7:47pm UTC](https://forum.qiime2.org/t/dereplicating-error-or-how-to-fix-a-typo/16354/7 "2020-09-02T19:47:36Z")

</div>

In case anyone was interested in this thread (other than RESCRIPt crew of @SoilRotifer, @Nicholas_Bokulich, @BenKaehler @thermokarst), I thought I'd share the first draft of the results among the BOLD and NCBI labels. Happy to get feedback to improve clarity.

The goal was to depict how often a label might be similar or different between NCBI or BOLD taxonomies. Notably, I'm _only_ talking about 🦇 🐛 🐟 🐌 : animal taxa for the COI marker gene.

Here's how to read the figure:

1. I broke down this analysis among labels at Phylum, Class, Order, Family, and Genus levels. Each of these levels is represented as a horizontal face in the figure (level labels indicated at right).

2. Researchers who submit sequences and taxonomic info for a given reference can (and do!) submit information to BOLD and NCBI simultaneously. To account for this, I split up my data into three sets:

- References collected from BOLD's site ("BOLD")
- References from NCBI **with a keyword** that matches those cross referenced with BOLD ("NCBIob", _aka NCBI-Only-Bold_")
- References from NCBI that **lack the keyword** that matches those cross referenced with BOLD ("NCBInb", _aka NCBI-Not-Bold_")

With three distinct sets of information, there are 7 ways they might interact. Each of these interactions are depicted as discrete labels along the x-axis. For example, the first x-axis label shows the number of taxonomic labels that are shared among all 3 sets - it's an "inner join" for all 3 groups. The second-fourth columns' are 2-way intersections. These represent those labels that are _both_ in two groups, but _not_ in the third group. I've labeled these as "exclusive" sets. The final three columns represent those taxonomic labels unique to a given set.

1. So what are the values? There are actually two sets of numbers represented in each column:

- The y axis values scale from 0 to 1, and represent the fraction of taxonomic labels in the given set being depicted.
  - For the first four columns, this is the number of shared labels, relative to the "universe" of labels - that is, the sum of all possible unique labels among the three groups (BOLD, NCBIob, NCBInb).
  - For the final three columns however, the number of shared labels is relative to the specific dataset itself. This was to avoid the weirdness of a situation where a single group may have _entirely_ unique taxonomic labels, but if it was plotted relative to the "universe" of labels, it might still only appear to have 1/3 of it's labels listed as unique.

- The integer values plotted above each bar represent the number of distinct labels in that group. For instance, the first value shown in the first column of the Phylum label is **17** (see the top-left-most column). This means that there were 17 unique Phylum names shared among all three datasets. If you move across that Phylum face to the fourth column ("_Exclusive BOLD + NCBInb_"), the value is **6**. That means that there were six unique Phylum names found in _both_ of those datasets that weren't present in the _NCBInb_ dataset. One other thing to keep in mind - if you sum these integers across a taxonomic level (i.e. horizontal facet), you'll get the "universe" of all possible taxonomic labels. Thus, there are 31 unique Phylum labels (17+6+3+5) across all of BOLD and NCBI records I gathered.

 ![COIlabelComps](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/0/0e9387f4851b2d650c3f0f5725851e57a1b5379e.png)

---

<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:** [October 4, 2020, 1:47am UTC](https://forum.qiime2.org/t/dereplicating-error-or-how-to-fix-a-typo/16354/8 "2020-10-04T01:47:37Z")

</div>

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