vegan nMDS PERMANOVA SIMPER
Scott Gabara
5/16/2019
Look at dataframe and treat morphometrics as community abundance
library(vegan)
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.5-5
head(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
tail(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 145 6.7 3.3 5.7 2.5 virginica
## 146 6.7 3.0 5.2 2.3 virginica
## 147 6.3 2.5 5.0 1.9 virginica
## 148 6.5 3.0 5.2 2.0 virginica
## 149 6.2 3.4 5.4 2.3 virginica
## 150 5.9 3.0 5.1 1.8 virginica
summary(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width
## Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100
## 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300
## Median :5.800 Median :3.000 Median :4.350 Median :1.300
## Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199
## 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800
## Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500
## Species
## setosa :50
## versicolor:50
## virginica :50
##
##
##
str(iris)
## 'data.frame': 150 obs. of 5 variables:
## $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
## $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
## $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
## $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
## $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
vare.mds <- metaMDS(iris[,1:4]) #using all the defaults
## Run 0 stress 0.03775523
## Run 1 stress 0.04709662
## Run 2 stress 0.06000342
## Run 3 stress 0.04355805
## Run 4 stress 0.0436754
## Run 5 stress 0.04367544
## Run 6 stress 0.0435579
## Run 7 stress 0.03775588
## ... Procrustes: rmse 6.916813e-05 max resid 0.0002465258
## ... Similar to previous best
## Run 8 stress 0.06032474
## Run 9 stress 0.04367562
## Run 10 stress 0.05224664
## Run 11 stress 0.05306067
## Run 12 stress 0.0471379
## Run 13 stress 0.03775529
## ... Procrustes: rmse 1.663269e-05 max resid 4.796168e-05
## ... Similar to previous best
## Run 14 stress 0.04355798
## Run 15 stress 0.4150982
## Run 16 stress 0.04355838
## Run 17 stress 0.03775603
## ... Procrustes: rmse 8.61862e-05 max resid 0.0003113646
## ... Similar to previous best
## Run 18 stress 0.03775562
## ... Procrustes: rmse 1.825305e-05 max resid 0.0001462147
## ... Similar to previous best
## Run 19 stress 0.0518364
## Run 20 stress 0.05317313
## *** Solution reached
vare.mds #display the results
##
## Call:
## metaMDS(comm = iris[, 1:4])
##
## global Multidimensional Scaling using monoMDS
##
## Data: iris[, 1:4]
## Distance: bray
##
## Dimensions: 2
## Stress: 0.03775523
## Stress type 1, weak ties
## Two convergent solutions found after 20 tries
## Scaling: centring, PC rotation, halfchange scaling
## Species: expanded scores based on 'iris[, 1:4]'
#plot(vare.mds, type = "p") #plots with points
#plot(vare.mds, type = "t") #plots with text
plot(vare.mds, type = "t")
points(vare.mds, cex = 1, pch = 16, col = iris$Species)
points(vare.mds, cex = 1, pch = 1, col = "black")
ordiellipse(vare.mds, iris$Species, draw="polygon", conf = 0.95, label = TRUE, col = c("black", "red", "green"), alpha=0.25)
``Note that the
echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.