phy_betaPlot: Easy and Nice MDS Plots

View source: R/phy_betaPlot.R

phy_betaPlotR Documentation

Easy and Nice MDS Plots

Description

The function wraps the phyloseq functions "distance", "ordinate", and "plot_ordination", also adding some fancier represantations, called "spiders", "hulls" and "ellipses".

Usage

phy_betaPlot(
  physeq,
  dist = "bray",
  method = "PCoA",
  axes = 1:2,
  color,
  shape = NULL,
  visual_grouping = NULL,
  palette = "standard",
  ncores = 1,
  label_centroids = TRUE
)

Arguments

physeq

A phyloseq object, **CAREFUL**: the function doesn't transform internally, so if you choose to calculate the distance matrix internally with "ordinate", make sure you transform the counts prior to function call (usually relative abundance is accepted)

dist

Distance object or character vector saying the distance metric to apply

method

One of the methods allowed by "ordinate" in the phyloseq object

axes

The axes to be plotted, default are the first 2, which should discriminate samples better

color

The variable to color the samples by. Only metadata variables are supported, to color taxa, use betaPlotTaxa

shape

Should you want to further differentiate your points. the default is that shapes are chosen based on the color variable

visual_grouping

This is the cool parameter of this function. the allowed ones are "spiders", "hulls" and "ellipses"

palette

Similarly to ggpubr's "palette" parameters, the function allows for a palette name, (default is "standard", the ggplot2 default palette). All palettes in the ggsci package are allowed too

ncores

A integer number saying how many cores you want to use for the calculations. So far, it will only speed up the calculation of the distance matrix

label_centroids

A logical: do you want labels to be applied on top of each category centroid?

Value

a ggplot2 object

Examples

data("enterotype")

phy_betaPlot(physeq = enterotype,
dist = "bray",
method = "PCoA",
axes = 1:2,
color = "SeqTech",
visual_grouping = "spiders",
palette = "jco")

g-antonello/gautils2 documentation built on Nov. 28, 2022, 9:39 a.m.