ggplot2
-graphic, including
additional annotation in the form of shading, shape,
and/or labels of sample variables.
plot_ordination(physeq, ordination, type = "samples", axes = 1:2, color = NULL, shape = NULL, label = NULL, title = NULL, justDF = FALSE)
phyloseq-class
.
The data about which you want to plot and annotate the
ordination.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."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.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.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
.
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
.
NULL
. Character
string. The name of the variable to map to text labels on
the plot. Similar to color
option, but for
plotting text.NULL
. Character
string. The main title for the graphic.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.ggplot
plot object, graphically
summarizing the ordination result for the specified axes.
Also see the general wrapping function:
# 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")
Run the code above in your browser using DataLab