joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
567 stars 187 forks source link

Error "taxa_names<-: You are attempting to assign duplicated taxa_names" when substituting OTUs to Genus #1671

Closed francescaangiol closed 1 year ago

francescaangiol commented 1 year ago

Hello!!

I am trying to clean my taxonomic table and I am encountering an error that I cannot seem to get passed by. I have already aggregated to genus level the OTUs successfully and all I need is just to substitute the names of such OTUs to the genus. When I run the command this message pops: Error in taxa_names<-(*tmp*, value = new("taxonomyTable", .Data = c("MarineGroupII", : taxa_names<-: You are attempting to assign duplicated taxa_names

I have already checked with duplicated() but seems like I don't have any duplicates.

I have searched in many forum questions but nothing is really helpful. I also tried checking on my table if there are issues with the higher ranks but I have almost 7000 OUTs and doing it one by one is too long.

I'd really appreciate any suggestions or help

gmteunisse commented 1 year ago

There probably are genera in your tax_table that have identical names, despite having a different upstream taxonomy. I would suggest to simply leave the agglomerated ASV names as the taxa_names - I don't think there are many analyses for which the taxa_names matter. However, if you do have an application that requires it, you will need to somehow label duplicated genera to make them unique. I have implemented such a function in the fantaxtic package: the label_duplicate_taxa function will identify any duplicated annotations at a specified taxonomic rank (e.g. Genus), and add a tag to ensure unique annotations.

francescaangiol commented 1 year ago

Thank you, in deed I left the names as they were and it was okay.