Getting the most Abundant Taxa - meyermicrobiolab/Meyer_Lab_Resources GitHub Wiki

If you have pretty consistent community content across all samples, this works well to look at the most abundant taxa.

Starting with a phyloseq object to convert to relative abundance:

    ps10ra<-transform_sample_counts(ps, function(OTU) OTU/sum(OTU))

Now sort by abundance and pick the 50 most abundant OTUs; obviously this number can be changed to 20 or 100 or whatever you want

    ps50<-prune_taxa(names(sort(taxa_sums(ps10ra),TRUE)[1:50]), ps10ra)

Plot the most abundant OTUs, it will leave gaps to show how much is not contained in the 50 most abundant otus

fifty=plot_bar(ps50, fill="Genus")
fifty+geom_bar(aes(fill=Genus), stat="identity",position="stack")+
  theme(strip.text=element_text(face="bold"))+ 
  theme(axis.text.x = element_text( angle = 90))+
  theme(legend.position = "bottom")
⚠️ **GitHub.com Fallback** ⚠️