Closed pauGuas closed 1 year ago
Hi Pau,
There are two reasons why you are not getting the colours that you're specifying:
palette
.top_level="Phylum"
, so the colouring is by phylum, not by order.Some other observations:
by_proportion=FALSE
)top_taxa(ps, n_taxa=15, tax_level='Order')
to get to the same resultnested_level=Family
, even though you are agglomerated at the order level, so there is no information at the family level.See below for a reproducible example. Also have a look at the documentation on the main page and for each function using help(top_taxa); help(nested_top_taxa); help(plot_nested_bar)
.
require('phyloseq')
#> Loading required package: phyloseq
require('fantaxtic')
#> Loading required package: fantaxtic
data("GlobalPatterns")
ps <- GlobalPatterns
top_order <- top_taxa(ps, n_taxa = 15, tax_level = 'Order')
plot_nested_bar(ps_obj = top_order$ps_obj, top_level = "Phylum",
nested_level = "Order",
palette=c(Actinobacteria = 'blue',
Bacteroidetes = 'green',
Cyanobacteria = 'red',
Firmicutes = 'turquoise',
Proteobacteria = 'purple'))
Created on 2023-04-19 by the reprex package (v2.0.1)
Glad you’re getting closer! You have to supply a character vector with the sample names in the desired order to ‘sample_order’. Check out the example in the documentation.
From: Pau Fiori @.> Sent: Tuesday, April 25, 2023 11:50:27 PM To: gmteunisse/fantaxtic @.> Cc: gmteunisse @.>; Comment @.> Subject: Re: [gmteunisse/fantaxtic] plot_nested_bar: Specify colors for each bacterial order (Issue #17)
I am so close to getting this graph how I want it! My samples have numbers as the sample_names. I made sure they are as.numeric. Still, the graph does not put them in numerical order on the X axis.
— Reply to this email directly, view it on GitHubhttps://github.com/gmteunisse/fantaxtic/issues/17#issuecomment-1522465083, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHBWS3XIUTVBWCMN6OSO7IDXDBBKHANCNFSM6AAAAAAXCZ77NE. You are receiving this because you commented.Message ID: @.***>
Hello, I need to specify colors for each of my bacterial orders so I can compare across plots. I tried using this code but the plot comes up with randomly chosen colors by the program. Could you help me troubleshoot? Thank you!
ps <- GlobalPatterns ps_norm <- transform_sample_counts(ps, function(x) x / sum(x) ) order <- tax_glom(ps_norm, taxrank = "Order") top_order <- top_taxa(order, n_taxa = 15) plot_nested_bar(ps_obj = top_order$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"))