david-barnett / microViz

R package for microbiome data visualization and statistics. Uses phyloseq, vegan and the tidyverse. Docker image available.
https://david-barnett.github.io/microViz/
GNU General Public License v3.0
94 stars 10 forks source link

comp_barplot() option not to scale to 1 #41

Closed fconstancias closed 2 years ago

fconstancias commented 2 years ago

Hi David,

Thanks for the awesome package. I was wondering if we could skip the scaling to barplot to 1 using comp_barplot(). The rationale behind would be to be able to plot the proportion of selected ASV/taxa and plot their actual proportions.

I could not find the options from the actual arguments.

Thanks.

david-barnett commented 2 years ago

Hi Florentin, glad you are finding microViz useful :)

I think you are looking for the comp_barplot argument tax_transform_for_plot, which you can set to "identity" instead of the default "compositional" scaling.

I haven't included an example of doing this in the documentation, so here's one below, modified from the current help page. Was this what you wanted?

library(microViz)
library(ggplot2)
data(dietswap, package = "microbiome")

 dietswap %>%
   ps_filter(timepoint == 1) %>%
   comp_barplot(tax_level = "Family", n_taxa = 8, tax_transform_for_plot = "identity") + 
   coord_flip()

image

fconstancias commented 2 years ago

That's perfect @david-barnett . Thanks