phyloseq (version 1.16.2)

plot_bar: A flexible, informative barplot phyloseq data


There are many useful examples of phyloseq barplot graphics in the{phyloseq online tutorials}. This function wraps ggplot2 plotting, and returns a ggplot2 graphic object that can be saved or further modified with additional layers, options, etc. The main purpose of this function is to quickly and easily create informative summary graphics of the differences in taxa abundance between samples in an experiment.


plot_bar(physeq, x="Sample", y="Abundance", fill=NULL,
 title=NULL, facet_grid=NULL)


(Required). An otu_table-class or phyloseq-class.
(Optional). Optional, but recommended, especially if your data is comprised of many samples. A character string. The variable in the melted-data that should be mapped to the x-axis. See psmelt, melt, and ggplot for more details.
(Optional). A character string. The variable in the melted-data that should be mapped to the y-axis. Typically this will be "Abundance", in order to quantitatively display the abundance values for each OTU/group. However, alternative variables could be used instead, producing a very different, though possibly still informative, plot. See psmelt, melt, and ggplot for more details.
(Optional). A character string. Indicates which sample variable should be used to map to the fill color of the bars. The default is NULL, resulting in a gray fill for all bar segments.
(Optional). Default NULL. Character string. The main title for the graphic.
(Optional). A formula object. It should describe the faceting you want in exactly the same way as for facet_grid, and is ulitmately provided to ggplot2 graphics. The default is: NULL, resulting in no faceting.


  • A ggplot2 graphic object -- rendered in the graphical device as the default print/show method.

See Also{phyloseq online tutorials}.





Run this code
data("GlobalPatterns") = subset_taxa(GlobalPatterns, Phylum == "Chlamydiae")
plot_bar(, fill="Genus")
plot_bar(, x="SampleType", fill="Genus")
plot_bar(, "SampleType", fill="Genus", facet_grid=~Family)
# See additional examples in the plot_bar online tutorial. Link above.

Run the code above in your browser using DataCamp Workspace