gmteunisse / fantaxtic

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

Change X axis order with fantaxtic_bar #16

Closed pauGuas closed 1 year ago

pauGuas commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Great! Re the colours: could you open a new issue for that and post a reproducible example (e.g. with GlobalPatterns?).


From: Pau Fiori @.> Sent: Sunday, April 16, 2023 10:27:18 PM To: gmteunisse/fantaxtic @.> Cc: gmteunisse @.>; Comment @.> Subject: Re: [gmteunisse/fantaxtic] Change X axis order with fantaxtic_bar (Issue #16)

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"))

— Reply to this email directly, view it on GitHubhttps://github.com/gmteunisse/fantaxtic/issues/16#issuecomment-1510478404, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHBWS3S3LGDSBS3U553BMMTXBRI2NANCNFSM6AAAAAAW7WWTO4. You are receiving this because you commented.Message ID: @.***>