gmteunisse / fantaxtic

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

Names must be unique issue #32

Closed janetw closed 4 months ago

janetw commented 4 months ago

Hello, I am trying out fantaxtic. I am having some issues though in that it apparently is seeing some of the sample names as being duplicate. The code I am using is as follows and the code itself works with the GlobalPatterns data.

# Get the most abundant phyla and the most abundant families within those phyla
top_nested_milk_genus <- nested_top_taxa(ps_milk_genus),
                              top_tax_level = "Phylum",
                              nested_tax_level = "Family",
                              n_top_taxa = 3, 
                              n_nested_taxa = 3)

Error output: Error in rename_with(): ! Names must be unique. ✖ These names are duplicated:

Error in rename_with(., function(x) { :

When I expand the traceback, I see that in step 3 there is a function to rename and it is using gsub() to remove the 'X'. Is there a way to not have it do this since the X is part of the sample name?

From expanding the traceback: 3. otu_table(ps_tmp) %>% data.frame(taxid = row.names(.)) %>% rename_with(function(x) { gsub("X", "", x) }) %>% pivot_longer(!taxid, names_to = "sample_id", values_to = "abundance") %>% left_join(sample_data(ps_tmp) %>% data.frame(sample_id = row.names(.)), ... 2. top_taxa(ps_obj, tax_level = top_tax_level, n_taxa = n_top_taxa, by_proportion = by_proportion, ...) 1. nested_top_taxa(ps_milk_genus, top_tax_level = "Phylum", nested_tax_level = "Family", n_top_taxa = 3, n_nested_taxa = 3)

Thanks for any help or insight you might be able to provide! Best regards, Janet

janetw commented 4 months ago

Hello again, So I decided to just to change the sample names with the 'X' in them by using gsub() to change it from 'X' to 'exit'. This seems to have solved the problem. I am still interested in knowing the rationale for automatically doing the gsub() in the function though.

Thank you for this package! The figure generated seems to be the figure we are looking for!

Best regards, Janet

gmteunisse commented 4 months ago

Thanks for bringing this to my attention. I just fixed the behaviour, so that you can keep the X in the sample names.