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.
(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.
y
(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.
fill
(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.
title
(Optional). Default NULL. Character string.
The main title for the graphic.
facet_grid
(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.
Value
A ggplot2 graphic object – rendered in the graphical device
as the default print/show method.
data("GlobalPatterns")
gp.ch = subset_taxa(GlobalPatterns, Phylum == "Chlamydiae")
plot_bar(gp.ch)
plot_bar(gp.ch, fill="Genus")
plot_bar(gp.ch, x="SampleType", fill="Genus")
plot_bar(gp.ch, "SampleType", fill="Genus", facet_grid=~Family)
# See additional examples in the plot_bar online tutorial. Link above.
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(phyloseq)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/phyloseq/plot_bar.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot_bar
> ### Title: A flexible, informative barplot phyloseq data
> ### Aliases: plot_bar
>
> ### ** Examples
>
> data("GlobalPatterns")
> gp.ch = subset_taxa(GlobalPatterns, Phylum == "Chlamydiae")
> plot_bar(gp.ch)
> plot_bar(gp.ch, fill="Genus")
> plot_bar(gp.ch, x="SampleType", fill="Genus")
> plot_bar(gp.ch, "SampleType", fill="Genus", facet_grid=~Family)
> # See additional examples in the plot_bar online tutorial. Link above.
>
>
>
>
>
> dev.off()
null device
1
>