gmteunisse / fantaxtic

Fantaxtic - Nested Bar Plots for Phyloseq Data
26 stars 3 forks source link

label_duplicate_taxa does not generate unique labels #10

Closed gmteunisse closed 1 year ago

gmteunisse commented 1 year ago

label_duplicate_taxa does not generate unique labels when asv_as_id = F. The reason seems to be that taxa with different upstream taxonomy can have the same downstream tax label, e.g. Clostridia. This can largely be resolved by setting asv_as_id = T, but requires a proper solution.

require("phyloseq")
require("fantaxtic")
require("tidyverse")

# Load data
data(GlobalPatterns)

# Generate (unique) species names using fantaxtic
ps <- name_na_taxa(GlobalPatterns)
ps <- label_duplicate_taxa(ps, asv_as_id = F)

# Count non-unique species
tax_table(ps) %>%
  data.frame(taxid = row.names(.)) %>%
  group_by(Species) %>%
  summarise(n = n()) %>%
  filter(n > 1L)
gmteunisse commented 1 year ago

I reated a quick fix so that taxon names are unique when tax_level is specified, no duplicates occur in https://github.com/gmteunisse/fantaxtic/commit/b7df1e0be62d9e445bc8a0e80aadbfa412ce559d. However, a full solution still needs to be implemented.

gmteunisse commented 1 year ago

Fixed in https://github.com/gmteunisse/fantaxtic/commit/478f36d1cdaecde7f26477d57795fdd6797f1056.