gmteunisse / fantaxtic

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

Sorting stacked barplot based on abundance values #28

Closed nelli-vardazaryan closed 2 months ago

nelli-vardazaryan commented 4 months ago

Hey,

I am using fantaxtic to create a stacked barplot of relative abundances for each of my samples; however, I am having difficulties controlling the order of each block within each sample. I would like to have these blocks sorted by their abundances in descending or ascending order for easier viewing.

I am using the following code:

top_nested <- nested_top_taxa(ps.rel,
                              top_tax_level = "Phylum",
                              nested_tax_level = "Genus",
                              n_top_taxa = 15, 
                              n_nested_taxa = 15)

plot_nested_bar(ps_obj = top_nested$ps_obj,
                top_level = "Phylum",
                nested_level = "Genus")
Screenshot 2024-02-23 at 13 42 01

Is there a way to change this default behavior?

gmteunisse commented 4 months ago

Hello,

Thanks for using fantaxtic!

It is possible to sort by samples by abundance, please see the example in the documentation here https://github.com/gmteunisse/fantaxtic?tab=readme-ov-file#sample-order.

Sorting taxa by abundance is also possible, but it requires that you build the plot from scratch and relevel the taxa with your desired order; please see the documentation here, specifically the move_label and move_nested_label functions: https://github.com/gmteunisse/fantaxtic?tab=readme-ov-file#advanced-usage

Let me know if that is what you’re looking for.


From: Nelli Vardazaryan @.> Sent: Friday, February 23, 2024 10:44:14 PM To: gmteunisse/fantaxtic @.> Cc: Subscribed @.***> Subject: [gmteunisse/fantaxtic] Sorting stacked barplot based on abundance values (Issue #28)

Hey,

I am using fantaxtic to create a stacked barplot of relative abundances for each of my samples; however, I am having difficulties controlling the order of each block within each sample. I would like to have these blocks sorted by their abundances in descending or ascending order for easier viewing.

I am using the following code:

`top_nested <- nested_top_taxa(ps.rel, top_tax_level = "Phylum", nested_tax_level = "Genus", n_top_taxa = 15, n_nested_taxa = 15)

plot_nested_bar(ps_obj = top_nested$ps_obj, top_level = "Phylum", nested_level = "Genus")`

Screenshot.2024-02-23.at.13.42.01.png (view on web)https://github.com/gmteunisse/fantaxtic/assets/121139156/df9e210e-e07e-4b5e-8774-2b96ad59ab5a

Is there a way to change this default behavior?

— Reply to this email directly, view it on GitHubhttps://github.com/gmteunisse/fantaxtic/issues/28, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHBWS3W2KHHZCARIK6ZTDETYVBQG5AVCNFSM6AAAAABDWNHOC6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGE2TANZSGU2TQOI. You are receiving this because you are subscribed to this thread.Message ID: @.***>