Skip to content

Ordering comp_barplot() by genus of interest #24

Answered by david-barnett
sbachas asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @sbachas !

This is possible, by first aggregating and transforming the taxa to compositions, then arranging the samples with ps_arrange, then plotting comp_barplot with "default" sample_order, which keeps the order as already set.

Here's an example, but beware that this might not look so good with a less abundant taxon. Hope this helps!

data("dietswap", package = "microbiome")
dietswap %>% 
   tax_agg("Phylum") %>% 
   tax_transform("compositional") %>% 
   ps_arrange(Bacteroidetes, .target = "otu_table") %>% 
   comp_barplot(tax_level = "Phylum", sample_order = "default")

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by david-barnett
Comment options

You must be logged in to vote
1 reply
@david-barnett
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants