Creates an nMDS plot from a consolidated binary matrix with grouping information. Colours and shapes of plotted points need to be specified. For example, if there are two groups, then: clrs = c("red", "blue"), sh = c(16, 16). This assigns red to the first group name, and blue to the second. Both will have a pch shape of 16 (round dot). These two vectors are then passed to the function nmds() as: colours = clrs, shapes = sh.
nmds(
x,
dist_meth = "binary",
k_val = 2,
pt_size = 1,
colours = c("dodgerblue", "black", "red", "green3", "orange", "darkblue", "gold2",
"darkgreen", "darkred", "grey", "darkgrey", "magenta", "darkorchid", "purple",
"brown", "coral3", "turquoise", "deeppink", "lawngreen", "deepskyblue", "tomato",
"yellow", "yellowgreen", "royalblue", "olivedrab", "midnightblue", "indianred1",
"darkturquoise"),
labs = FALSE,
legend_pos = "right",
include_ellipse = FALSE,
ellipse_type = "norm",
dimension1 = 1,
dimension2 = 2
)
Consolidated binary matrix with grouping information in the second column.
Distance method. Set to "binary" by default. Other options are "euclidean", "maximum", "manhattan", "canberra", or "minkowski".
Number of dimensions for the nMDS plot. Set to 2 by default.
Point size for symbols on the plot. Set to 1 by default.
Vector containing colours to be assigned to groups. This can be changed to the options available in the RColorBrewer palette set (e.g. "Set1"). See <http://applied-r.com/rcolorbrewer-palettes/> for more palette options. Alternatively, the colours can be set manually using, for example, c("red", "green", "blue"), thereby setting a colour for each group in your dataset. There are 28 default colours that will be set automatically to your groups.
Indicate whether labels should appear on the graph or not (TRUE or FALSE). Default = FALSE.
Indicate the position of the legend. Default = "right", but other options are "left", "bottom", "top", or "none"
Indicate whether ellipses should be included around groups. Default = FALSE.
Select the type of ellipses to include around groups. Options are "convex", "confidence", "t", "norm", and "euclid". See the ggpubr::ggscatter() function documentation for more details.
Indicate the first dimension to plot (1, 2, or 3) for the x axis. If k = 2, the first two dimensions will automatically be plotted. If k = 3, select between the three.
Indicate the second dimension to plot (1, 2, or 3) for the y axis
nMDS plot.
# NOT RUN {
mat = BinMatInput_ordination
group.names(mat)
clrs = c("red", "green", "black")
nmds(mat, colours = clrs, labs = TRUE, include_ellipse = TRUE)
# }
Run the code above in your browser using DataLab