plot_ordination {phyloseq} | R Documentation

## General ordination plotter based on ggplot2.

### Description

There are many useful examples of phyloseq ordination graphics in the phyloseq online tutorials. Convenience wrapper for plotting ordination results as a `ggplot2`-graphic, including additional annotation in the form of shading, shape, and/or labels of sample variables.

### Usage

    plot_ordination(physeq, ordination, type = "samples", axes = 1:2,
      color = NULL, shape = NULL, label = NULL, title = NULL,
      justDF = FALSE)

### Arguments

`physeq` | (Required). `phyloseq-class`. The data about which you want to plot and annotate the ordination.
`ordination` | (Required). An ordination object. Many different classes of ordination are defined by `R` packages. Ordination classes currently supported/created by the `ordinate` function are supported here. There is no default, as the expectation is that the ordination will be performed and saved prior to calling this plot function.
`type` | (Optional). The plot type. Default is `"samples"`. The currently supported options are `c("samples", "sites", "species", "taxa", "biplot", "split", "scree")`. The option “taxa” is equivalent to “species” in this case, and similarly, “samples” is equivalent to “sites”. The options `"sites"` and `"species"` result in a single-plot of just the sites/samples or species/taxa of the ordination, respectively. The `"biplot"` and `"split"` options result in a combined plot with both taxa and samples, either combined into one plot (“biplot”) or separated in two facet panels (“split”), respectively. The `"scree"` option results in a call to `plot_scree`, which produces an ordered bar plot of the normalized eigenvalues associated with each ordination axis.
`axes` | (Optional). A 2-element vector indicating the axes of the ordination that should be used for plotting. Can be `character-class` or `integer-class`, naming the index name or index of the desired axis for the horizontal and vertical axes, respectively, in that order. The default value, `c(1, 2)`, specifies the first two axes of the provided ordination.
`color` | (Optional). Default `NULL`. Character string. The name of the variable to map to colors in the plot. This can be a sample variable (among the set returned by `sample_variables(physeq)` ) or taxonomic rank (among the set returned by `rank_names(physeq)`). Note that the color scheme is chosen automatically by `link{ggplot}`, but it can be modified afterward with an additional layer using `scale_color_manual`.
`shape` | (Optional). Default `NULL`. Character string. The name of the variable to map to different shapes on the plot. Similar to `color` option, but for the shape if points. The shape scale is chosen automatically by `link{ggplot}`, but it can be modified afterward with an additional layer using `scale_shape_manual`.
`label` | (Optional). Default `NULL`. Character string. The name of the variable to map to text labels on the plot. Similar to `color` option, but for plotting text.
`title` | (Optional). Default `NULL`. Character string. The main title for the graphic.
`justDF` | (Optional). Default `FALSE`. Logical. Instead of returning a ggplot2-object, do you just want the relevant `data.frame` that was used to build the plot? This is a user-accessible option for obtaining the `data.frame`, in in principal to make a custom plot that isn't possible with the available options in this function. For contributing new functions (developers), the `phyloseq-package` provides/uses an internal function to build the key features of the `data.frame` prior to plot-build.

### Value

A `ggplot` plot object, graphically summarizing the ordination result for the specified axes.

### See Also

Many more examples are included in the phyloseq online tutorials.

Also see the general wrapping function:

`plot_phyloseq`

### Examples

    # See other examples at
    # http://joey711.github.io/phyloseq/plot_ordination-examples
    data(GlobalPatterns)
    GP = prune_taxa(names(sort(taxa_sums(GlobalPatterns), TRUE)[1:50]), GlobalPatterns)
    gp_bray_pcoa = ordinate(GP, "CCA", "bray")
    plot_ordination(GP, gp_bray_pcoa, "samples", color="SampleType")

[Package phyloseq version 1.32.0 Index]