Vegan: An Introduction To Ordination: Jari Oksanen
Vegan: An Introduction To Ordination: Jari Oksanen
Jari Oksanen
processed with vegan 2.5-7 in R Under development (unstable) (2020-11-27 r79520) on
November 27, 2020
Abstract
The document describes typical, simple work pathways of vegetation
ordination. Unconstrained ordination uses as examples detrended corre-
spondence analysis and non-metric multidimensional scaling, and shows
how to interpret their results by fitting environmental vectors and factors
or smooth environmental surfaces to the graph. The basic plotting com-
mand, and more advanced plotting commands for congested plots are also
discussed, as well as adding items such as ellipses, convex hulls, and other
items for classes. The constrained ordination uses constrained (canonical)
correspondence analysis as an example. It is first shown how a model is
defined, then the document discusses model building and significance tests
of the whole analysis, single constraints and axes.
Contents
1 Ordination 2
1.1 Detrended correspondence analysis . . . . . . . . . . . . . . . . . 2
1.2 Non-metric multidimensional scaling . . . . . . . . . . . . . . . . 2
2 Ordination graphics 4
2.1 Cluttered plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Adding items to ordination plots . . . . . . . . . . . . . . . . . . 5
4 Constrained ordination 7
4.1 Significance tests . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2 Conditioned or partial ordination . . . . . . . . . . . . . . . . . . 11
Vegan is a package for community ecologists. This documents explains how the
commonly used ordination methods can be performed in vegan. The document
only is a very basic introduction. The current document only describes a small
part of all vegan functions. For most functions, the canonical references are
the vegan help pages, and some of the most important additional functions are
listed at this document.
1
1 Ordination
The vegan package contains all common ordination methods: Principal compo-
nent analysis (function rda, or prcomp in the base R), correspondence analysis
(cca), detrended correspondence analysis (decorana) and a wrapper for non-
metric multidimensional scaling (metaMDS). Functions rda and cca mainly are
designed for constrained ordination, and will be discussed later. In this chapter
I describe functions decorana and metaMDS.
The display of results is very brief: only eigenvalues and used options are listed.
Actual ordination results are not shown, but you can see them with command
summary(ord), or extract the scores with command scores. The plot function
also automatically knows how to access the scores.
2
Run 2 stress 0.1183186
... New best solution
... Procrustes: rmse 0.02027054 max resid 0.06496303
Run 3 stress 0.1192678
Run 4 stress 0.1192679
Run 5 stress 0.2192919
Run 6 stress 0.1192678
Run 7 stress 0.1183186
... Procrustes: rmse 4.798313e-07 max resid 1.503447e-06
... Similar to previous best
Run 8 stress 0.1192679
Run 9 stress 0.1183186
... New best solution
... Procrustes: rmse 5.688499e-06 max resid 1.842467e-05
... Similar to previous best
Run 10 stress 0.1183186
... Procrustes: rmse 2.091255e-06 max resid 4.85836e-06
... Similar to previous best
Run 11 stress 0.1922241
Run 12 stress 0.1183186
... New best solution
... Procrustes: rmse 1.737353e-06 max resid 4.863911e-06
... Similar to previous best
Run 13 stress 0.1183186
... Procrustes: rmse 2.319046e-05 max resid 6.636297e-05
... Similar to previous best
Run 14 stress 0.1192678
Run 15 stress 0.1809578
Run 16 stress 0.1183186
... Procrustes: rmse 3.221461e-06 max resid 1.07411e-05
... Similar to previous best
Run 17 stress 0.1812933
Run 18 stress 0.1183186
... Procrustes: rmse 2.613774e-06 max resid 6.008369e-06
... Similar to previous best
Run 19 stress 0.1192678
Run 20 stress 0.1808911
*** Solution reached
> ord
Call:
metaMDS(comm = dune)
Data: dune
Distance: bray
Dimensions: 2
Stress: 0.1183186
Stress type 1, weak ties
Two convergent solutions found after 20 tries
Scaling: centring, PC rotation, halfchange scaling
Species: expanded scores based on ‘dune’
3
+ +
1.5
+
1.0
+
+
+
0.5
NMDS2
+
+
+
+ +
+ +
+ +
0.0
+ +
+
++ +
+
+
−0.5
+ +
+
+
+
−1.0
2 Ordination graphics
Ordination is nothing but a way of drawing graphs, and it is best to inspect
ordinations only graphically (which also implies that they should not be taken
too seriously).
All ordination results of vegan can be displayed with a plot command (Fig.
1):
> plot(ord)
Default plot command uses either black circles for sites and red pluses for
species, or black and red text for sites and species, resp. The choices depend on
the number of items in the plot and ordination method. You can override the
default choice by setting type = "p" for points, or type = "t" for text. For a
better control of ordination graphics you can first draw an empty plot (type =
"n") and then add species and sites separately using points or text functions.
In this way you can combine points and text, and you can select colours and
character sizes freely (Fig. 2):
> plot(ord, type = "n")
> points(ord, display = "sites", cex = 0.8, pch=21, col="red", bg="yellow")
> text(ord, display = "spec", cex=0.7, col="blue")
All vegan ordination methods have a specific plot function. In addition,
vegan has an alternative plotting function ordiplot that also knows many non-
vegan ordination methods, such as prcomp, cmdscale and isoMDS. All vegan
plot functions return invisibly an ordiplot object, so that you can use ordiplot
support functions with the results (points, text, identify).
Function ordirgl (requires rgl package) provides dynamic three-dimensional
graphics that can be spun around or zoomed into with your mouse. Function or-
diplot3d (requires package scatterplot3d) displays simple three-dimensional
scatterplots.
4
Airaprae Empenigr
1.5
Hyporadi
1.0
Salirepe
Anthodor
Comapalu
Vicilath
0.5
NMDS2
Callcusp
Planlanc
Scorautu
Bracruta Eleopalu
Trifprat Ranuflam
Achimill Trifrepe
0.0
Rumeacet Juncarti
Sagiproc
Bellpere
Lolipere
Poaprat
Agrostol
Bromhord
−0.5
Poatriv
Alopgeni
Juncbufo
Elymrepe
Cirsarve
Chenalbu
Figure 2: A more colourful ordi-
−1.0
−1.0 −0.5 0.0 0.5 1.0 1.5 nation plot where sites are points,
NMDS1 and species are text.
• Use automatic orditorp function that uses text only if this can be done
without overwriting previous labels, but points in other cases.
• Use automatic ordipointlabel function that uses both points and text
labels, and tries to optimize the location of the text to avoid overwriting.
• Use interactive orditkplot function that draws both points and labels for
ordination scores, and allows you to drag labels to better positions. You
can export the results of the edited graph to encapsulated postscript, pdf,
png or jpeg files, or copy directly to encapsulated postscript, or return the
edited positions to R for further processing.
5
1.0
NM
0.5
NMDS2
0.0
BF
HF
−0.5
SF
hulls, ordiellipse adds ellipses enclosing all points in the group (ellipsoid
hulls) or ellipses of standard deviation, standard error or confidence areas, and
ordispider combines items to their centroid (Fig. 3):
> data(dune.env)
> attach(dune.env)
> plot(ord, disp="sites", type="n")
> ordihull(ord, Management, col=1:4, lwd=3)
> ordiellipse(ord, Management, col=1:4, kind = "ehull", lwd=3)
> ordiellipse(ord, Management, col=1:4, draw="polygon")
> ordispider(ord, Management, col=1:4, label = TRUE)
> points(ord, disp="sites", pch=21, col="red", bg="yellow", cex=1.3)
In addition, you can overlay a cluster dendrogram from hclust using ordicluster
or a minimum spanning tree from spantree with its lines function. Segmented
arrows can be added with ordiarrows, lines with ordisegments and regular
grids with ordigrid.
• ordisurf (which requires package mgcv) fits smooth surfaces for continu-
ous variables onto ordination using thinplate splines with cross-validatory
selection of smoothness.
Function envfit can be called with a formula interface, and it optionally
can assess the “significance” of the variables using permutation tests:
6
> ord.fit <- envfit(ord ~ A1 + Management, data=dune.env, perm=999)
> ord.fit
***VECTORS
***FACTORS:
Centroids:
NMDS1 NMDS2
ManagementBF -0.4534 -0.0102
ManagementHF -0.2636 -0.1282
ManagementNM 0.2958 0.5790
ManagementSF 0.1506 -0.4670
Goodness of fit:
r2 Pr(>r)
Management 0.4134 0.005 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Permutation: free
Number of permutations: 999
The result can be drawn directly or added to an ordination diagram (Fig. 4):
> plot(ord, dis="site")
> plot(ord.fit)
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
4 Constrained ordination
Vegan has three methods of constrained ordination: constrained or “canonical”
correspondence analysis (function cca), redundancy analysis (function rda) and
distance-based redundancy analysis (function capscale). All these functions
7
1.0
4.5
ManagementNM
0.5
A1
NMDS2
3.5
6.5
0.0
ManagementBF
ManagementHF
6
5.5
−0.5
ManagementSF
5
can have a conditioning term that is “partialled out”. I only demonstrate cca,
but all functions accept similar commands and can be used in the same way.
The preferred way is to use formula interface, where the left hand side
gives the community data frame and the right hand side lists the constraining
variables:
> ord <- cca(dune ~ A1 + Management, data=dune.env)
> ord
Call: cca(formula = dune ~ A1 + Management, data = dune.env)
8
17
19
2
18 11 10
ManagementBF
1
EmpenigrHyporadi Vicilath 7 1
Airaprae
Salirepe 6 5
Achimill 2
Anthodor Bromhord
Planlanc
Lolipere
ScorautuManagementHF
Poaprat
CCA2
Bellpere Trifprat
Trifrepe
ManagementNM
0
Bracruta Rumeacet
Elymrepe
Juncarti Sagiproc Poatriv
Juncbufo4 3
Ranuflam 9
Callcusp Alopgeni
Cirsarve
Agrostol
Eleopalu
ManagementSF
−1
20 8
12
Chenalbu
13
Comapalu
−2
A1
14 15
16
9
Model: cca(formula = dune ~ A1 + Management, data = dune.env)
Df ChiSquare F Pr(>F)
Model 4 0.77978 2.1896 0.001 ***
Residual 15 1.33549
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
The function actually used was anova.cca, but you do not need to give its name
in full, because R automatically chooses the correct anova variant for the result
of constrained ordination.
It is also possible to analyse terms separately:
> anova(ord, by="term", permutations=199)
Permutation test for cca under reduced model
Terms added sequentially (first to last)
Permutation: free
Number of permutations: 199
10
CCA1 1 0.31875 3.5801 0.020 *
CCA2 1 0.23718 2.6640 0.074 .
CCA3 1 0.13217 1.4845 0.326
CCA4 1 0.09168 1.0297 0.430
Residual 15 1.33549
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
This partials out the effect of Moisture before analysing the effects of A1 and
Management. This also influences the significances of the terms:
> anova(ord, by="term", permutations=499)
Permutation test for cca under reduced model
Terms added sequentially (first to last)
Permutation: free
Number of permutations: 499
11
permutation is based on the powerful permute package. Function how() can
be used to define permutation schemes. In the following, we set the levels with
plots argument:
> how <- how(nperm=499, plots = Plots(strata=dune.env$Moisture))
> anova(ord, by="term", permutations = how)
Permutation test for cca under reduced model
Terms added sequentially (first to last)
Plots: dune.env$Moisture, plot permutation: none
Permutation: free
Number of permutations: 499
12