joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
579 stars 188 forks source link

Barplot Relative abundance top 10 taxas+ other group #1503

Open Macok04 opened 2 years ago

Macok04 commented 2 years ago

Hello, I am trying to make a graph with the relative abundances of the species found in my samples. I would like to graph the top 10 of the most abundant species, and that the rest are grouped into a group called others. However, I have not been able to do it, I am new to this, and although I have searched and tried things I have not been successful.

I am using the following code: ggplot (data = psmelt (SPlocation), mapping = aes_string (x = "species", y = "Abundance")) + geom_bar (aes (color = Species, fill = Species), stat = "identity", position = "fill ") + theme (legend.position =" bottom ") + facet_wrap (~ location)

The most I have been able to do is get the top 10 in an object, but it ends up eliminating the rest of the taxa, which I don't want.

top10s <- prune_taxa (names (sort (taxa_sums (SPlocation), TRUE)) [1:10], SPlocation)

Thank you

LeonardosMageiros commented 2 years ago

I am not an expert in this but maybe this tutorial will help you: http://joey711.github.io/phyloseq-demo/Restroom-Biogeography I am trying to do something similar as well with my data. See the section about figure 1. I believe that you want to do something similar so hopefully this will do.

Best Leonardos

mweberr commented 2 years ago

You can have a look at this post https://github.com/joey711/phyloseq/issues/1004