-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Hello David,
First of all, thank you so much for this amazing package!
I have a question about manually setting the order of bars in com_barplot. After some faceting and coding, even though I have created a list with the desired order for the bars to appear (given some geographical locations), R is still not understanding my command and is instead sorting the bars in descending order. I was wondering if you could provide any suggestions on this?
In the desired_order, I have a long list of row names I pulled from ps_sub, which has been arranged; they look like "M15E_24_4_1_16S_S43" "M15E_24_4_2_16S_S44" "M15E_24_4_3_16S_S45" "M1E_24_4_1_16S_S1" "M1E_24_4_2_16S_S2" "M1E_24_4_3_16S_S3".
For the Site_Rep from metadata, they look something like M15-1, M15-2, M15-3, M1-1, M1-2, M1-3. Instead of descending, ascending, or some random orders, I want them to be in the sequences of M15, M1, M2, M3, M4, M14, M4, M5 ... M13.
Below is the code I am using. I have also attached an image of the figure I currently have.
e_bar <- ps_sub %>%
tax_fix() %>%
comp_barplot(
tax_level = "Family",
x = "Site_Rep",
label = "Site_Rep",
sample_order = desired_order,
n_taxa = 20,
bar_width = 0.8,
palette = met_tax_palette,
bar_outline_color = NA,
merge_other = TRUE
) +
facet_grid(
cols = vars(Season),
scales = "fixed"
) +
coord_flip() +
labs(x = "Site",
y = "Relative Abundance",
title = "Dry Season Abundance, Ethanol Method") +
guides(
fill = guide_legend(ncol = 1)
)
Thank you again!
Tim
