ChiLiubio / microeco

An R package for data analysis in microbial community ecology
GNU General Public License v3.0
181 stars 55 forks source link

plot_bar yields different scale for relative abundance when using high_level #304

Closed lixiaopi1985 closed 5 months ago

lixiaopi1985 commented 5 months ago

Hi,

Thank you for this great package!

When I tried to plot the abundance in bars, I got the wrong scale of the relative abundance. See the picture below:

guild.abund.epi = trans_abund$new(meco.epi, taxrank = "Guild", ntaxa = 10, groupmean = "Season", high_level = "Trophic_mode")
season.plot.epi = guild.abund.epi$plot_bar()

image

Tried to plot with ggnested, the scale also changed but still wrong:

season.plot.epi = guild.abund.epi$plot_bar(ggnested = T)

image

Do you know how could I fix this?

And, if there is a way to reorder the legend label so that "others" can be placed in the last for the first plot?

Thank you

ChiLiubio commented 5 months ago

Hi. I guess the abundance data (taxa_abund list) in your meco.epi is not so-called standard relative abund. It probably has been the relative abundance * 100. If so, please add the parameter use_percentage = FASLE in your trans_abund$new and adjust the y axis title text. For more examples, please follow the metagenome data part of tutorial (https://chiliubio.github.io/microeco_tutorial/other-dataset.html#metagenomic-data), in which the abundance is RPK, not the relative abund. In the amplicon data, we generally use relative abundance ranging from 0 to 1. So the default function in trans_abund will first multiply the abund by 100 to be the percentage.

For the "others" in the legend lable, do you mean only moving the label to the bottom and do not change any plot contents? If so, the legend order will be opposite with the order in the plot?

For the second plot, ggnested method is currently only designed and tested for the amplicon data with standard taxonomic lineages. I have not tested this methd for the guild data. I will add it in the to-do list. Thanks.