plot_bar {phyloseq} | R Documentation

## A flexible, informative barplot phyloseq data

### Description

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.

### Usage

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

### Arguments

`physeq` | (Required). An `otu_table-class` or `phyloseq-class`.
`x` | (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 `ggplot`2 graphics. The default is: `NULL`, resulting in no faceting.

### Value

A `ggplot`2 graphic object – rendered in the graphical device as the default `print`/`show` method.

### See Also

phyloseq online tutorials.

`psmelt`

`ggplot`

`qplot`

### 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.

[Package phyloseq version 1.34.0 Index]