Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change X axis order with fantaxtic_bar #16

Closed
pauGuas opened this issue Apr 15, 2023 · 3 comments
Closed

Change X axis order with fantaxtic_bar #16

pauGuas opened this issue Apr 15, 2023 · 3 comments

Comments

@pauGuas
Copy link

pauGuas commented Apr 15, 2023

Hi, I am trying to change the X axis order on my fantaxtic_bar plot - I'm sad to see that was deprecated, by the way! It is my favorite package for microbiome data.

`ps_norm <- transform_sample_counts(ps, function(x) x / sum(x) )
family <- tax_glom(ps, taxrank = "Family")

top15 <- get_top_taxa(family, 15, relative = TRUE, discard_other = FALSE, other_label = "Other")
top15 <- name_taxa(top15, label = "", species = F, other_label = "Other")

sample_data(top15)$Month = factor(sample_data(top15)$Month, levels = c("20-Nov","21-Apr","21-May","21-Jul", "22-Feb", "22-Mar", "22-Apr"))
sample_names(top15) <- sample_data(top15)$Month
fantaxtic_bar(top15, color_by = "Family", label_by = "Family", facet_by = NULL, grid_by = NULL)`

This didn't change the X axis order. Any suggestions? Thank you

@gmteunisse
Copy link
Owner

Hi Pau,

Thanks for using fantaxtic! fantaxtic_bar has unfortunately been deprecated. However, all its functionality and more has been reimplemented in plot_nested_bar - have a look at the new documentation on the GitHub page.

In plot_nested_bar, you can supply a character vector with the sample names (from sample_names(ps)) in the desired x-axis order to the sample_order argument.

If you prefer to use fantaxtic_bar, I believe it should be possible to change to x-axis order by setting order_alg = 'as.is', which should plot your samples along the x-axis in the order in which they are encountered in the data. I do really recommend to use the updated functionality, as I can't guarantee that fantaxtic_bar still works as intended.

Let me know if this has resolved your issue.

@pauGuas
Copy link
Author

pauGuas commented Apr 16, 2023

Thank you, I'm really enjoying this new function. My issue now is I need to specify colors for each order that is graphed so I can compare across samples. I tried to do this but it just used its own default colors:

plot_nested_bar(ps_obj = top_asv$ps_obj, top_level = "Phylum",
nested_level = "Family",
palette=c(Frankiales = "paleturquoise1",
Micrococcales = "turquoise2",
Microtrichales = "turquoise3",
Bacteroidales = "gold",
Cytophagales = "goldenrod2",
Flavobacteriales = "goldenrod3",
Burkholderiales = "mistyrose",
Enterobacterales = "pink",
Pseudomonadales = "palevioletred1",
Rhizobiales = "palevioletred3",
Sphingmonadales = "maroon1",
Rhodobacterales = "violetred4",
Xanthomonadales = "palevioletred4",
Verrucomicrobiota = "black"))

@gmteunisse
Copy link
Owner

gmteunisse commented Apr 17, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants