library(mvabund) # spider data
library(vegan) # metaMDS(), envfit()
library(tidyverse) # ggplot()
library(GGally) # ggpairs()
library(corrplot) # corrplot()
library(PNWColors) # pnw_palette()
library(dendextend) # color_branches(), color_labels()
# Color Palettes
pal1 <- pnw_palette("Bay", 6)
pal2 <- pnw_palette("Bay", 4)
data(spider)
# ?spider
These data consist of community abundance for twelve hunting spider species, as well as six environmental variables describing the species’ habitats.
Spider Species:
Species are abbreviated with the first four letters of the genus name followed by the first four letters of the species name.
Environmental Variables:
The environmental variables were log(x+1)-transformed.
spider.abund <- data.frame(spider$abund)
spider.env <- data.frame(spider$x)
ggpairs(spider.abund[,1:6])
ggpairs(spider.abund[,7:12])
M <- cor(spider.abund)
corrplot(M)
Distribution plots of spider species abundances do not have a bell curve typical of normal data, and pairwise plots show a strong tendency towards zeros. Since this is community abundance data, this is unsurprising. The correlation plot and correlation coefficients in the pairs plots show that most spider species are moderately correlated with one another, justifying the use of multivariate methods.
The goal of this analysis is to answer the questions:
To better visualize these data, I used nonmetric Multidimensional Scaling (nMDS), an iterative ordination method ideal for community abundance data. For distance/dissimilarity measures in nMDS, I used Bray-Curtis measurements because they better account for non-normal data with many zeros than Euclidean measurements. I chose two axes for the ordination plot, as the stress was very low (0.065) and the non-metric R^2 quite high (0.996), showing that the two axes describe the majority of variation.
I used averages of each species weighted by nMDS axes 1 and 2 to plot the species scores alongside the sample points to show which species are common among certain plots.
set.seed(42)
spider.nmds <- metaMDS(spider.abund, k = 2)
## Square root transformation
## Wisconsin double standardization
## Run 0 stress 0.06467442
## Run 1 stress 0.08232483
## Run 2 stress 0.0645855
## ... New best solution
## ... Procrustes: rmse 0.002992821 max resid 0.01210801
## Run 3 stress 0.06467444
## ... Procrustes: rmse 0.00302695 max resid 0.0122488
## Run 4 stress 0.08232494
## Run 5 stress 0.06458549
## ... New best solution
## ... Procrustes: rmse 3.483421e-05 max resid 6.726472e-05
## ... Similar to previous best
## Run 6 stress 0.06458549
## ... New best solution
## ... Procrustes: rmse 1.106072e-05 max resid 2.143237e-05
## ... Similar to previous best
## Run 7 stress 0.0645855
## ... Procrustes: rmse 1.060649e-05 max resid 1.943873e-05
## ... Similar to previous best
## Run 8 stress 0.06458549
## ... Procrustes: rmse 1.356735e-05 max resid 2.777284e-05
## ... Similar to previous best
## Run 9 stress 0.06458549
## ... New best solution
## ... Procrustes: rmse 4.697532e-06 max resid 9.423984e-06
## ... Similar to previous best
## Run 10 stress 0.0645855
## ... Procrustes: rmse 8.841729e-06 max resid 1.575745e-05
## ... Similar to previous best
## Run 11 stress 0.082325
## Run 12 stress 0.08167515
## Run 13 stress 0.06467448
## ... Procrustes: rmse 0.00304999 max resid 0.01236465
## Run 14 stress 0.0645855
## ... Procrustes: rmse 1.994735e-05 max resid 3.950017e-05
## ... Similar to previous best
## Run 15 stress 0.06458549
## ... Procrustes: rmse 3.356573e-06 max resid 7.894465e-06
## ... Similar to previous best
## Run 16 stress 0.06629184
## Run 17 stress 0.06458549
## ... Procrustes: rmse 4.867972e-06 max resid 9.919909e-06
## ... Similar to previous best
## Run 18 stress 0.06458549
## ... Procrustes: rmse 8.448034e-06 max resid 1.728475e-05
## ... Similar to previous best
## Run 19 stress 0.0824332
## Run 20 stress 0.06629184
## *** Best solution repeated 6 times
stressplot(spider.nmds)
I used hierarchical clustering with Ward’s linkage to determine if the spider communities naturally grouped based on species abundances. Ward’s linkage is an agglomerative algorithm that minimizes the variance among points in a group, making it a good choice for these data. After visualizing the clusters with a dendrogram, I decided to cut the tree at k = 4 with four clusters, since four fairly distinct groups arise at a distance of approximately 0.5 - 0.7.
spider.dist <- vegdist(spider.abund, method = "bray")
spider.hcl <- hclust(spider.dist)
spider.dend <- as.dendrogram(spider.hcl)
spider.clust <- cutree(spider.hcl, k = 4)
spider.dend <- spider.dend |>
color_branches(k = 4, col = pal2) |>
color_labels(k = 4, col = pal2)
plot(spider.dend)
To fit environmental variables back onto the ordination space, I regressed each continuous variable onto nMDS1 and nMDS2. This produced a vector in the nMDS space that shows the maximum gradient of change for each variable, as well as R^2 goodness of fit values, and permuted p-values for the significance of that R^2. The length of the vector represents the scaled magnitude of that gradient.
set.seed(42)
my.fit <- envfit(spider.nmds, spider.env, choices = c(1,2))
my.fit
##
## ***VECTORS
##
## NMDS1 NMDS2 r2 Pr(>r)
## soil.dry 0.92607 -0.37735 0.8754 0.001 ***
## bare.sand -0.88772 0.46039 0.6225 0.001 ***
## fallen.leaves 0.62677 0.77920 0.8001 0.001 ***
## moss -0.90185 -0.43205 0.7144 0.001 ***
## herb.layer 0.03014 -0.99955 0.4530 0.002 **
## reflection -0.86687 -0.49853 0.7996 0.001 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation: free
## Number of permutations: 999
To assess the significance of environmental variables, I used a Permutational Multivariate Analysis of Variance (PERMANOVA) with Bray-Curtis distance/dissimilarity measures. I first included all 6 environmental variables (added in order of highest R^2 from the nMDS), then excluded those which explained similar variance among communities.
\(Y \sim soil.dry + fallen.leaves + reflection + moss + bare.sand + herb.layer\)
# nMDS Scores and Clusters for Abundance Dataframe for Plotting
spiderPlot <- data.frame(
NMDS1 <- spider.nmds$points[,1],
NMDS2 <- spider.nmds$points[,2],
Cluster <- as.factor(spider.clust))
# Environmental Variables Dataframe for Plotting
vecPlot <- as.data.frame(scores(my.fit,
display = "vectors"))
vecPlot <- cbind(vecPlot,
Vname = rownames(vecPlot),
Pvalues = my.fit$vectors$pvals,
R_squared = my.fit$vectors$r)
# Filter by significant p value (not necessary here but kept for reference)
vecPlot <- subset(vecPlot, Pvalues < 0.05)
# Species Scores Dataframe for Plotting
Species1 <- spider.nmds$species[,1]
Species2 <- spider.nmds$species[,2]
Names <- rownames(spider.nmds$species)
speciesPlot <- data.frame(Species1, Species2, Names)
# Ordination Plot
plot1 <- ggplot() +
geom_point(data = spiderPlot,
aes(x = NMDS1, y = NMDS2, color = Cluster),
size = 3) +
coord_fixed() +
xlab("NMDS1") +
ylab("NMDS2") +
scale_color_manual(values = pal2) +
geom_segment(data = vecPlot,
aes(x = 0, xend = NMDS1,
y = 0, yend = NMDS2),
arrow =
arrow(length = unit(0.5, "cm"))) +
geom_text(data = speciesPlot,
aes(x = Species1, y = Species2,
label = Names),
size = 2.5, color = "coral4") +
geom_text(data = vecPlot,
aes(x = NMDS1, y = NMDS2,
label = Vname),
color = "grey30",
size = 3,
nudge_x = c(0.1, -0.05, 0, -0.1, 0, 0),
nudge_y = c(0, 0.05, 0.05, 0, -0.025, -0.025))
plot1
Figure 1. Non-Metric Multidimensional Scaling of hunting spider communities (stress = 0.0646, non-metric \(R^2\) = 0.996). Colors depict clusters determined from hierarchical cluster analysis. Arrow vectors show fitted environmental variables in the direction of strongest gradient of change. Vector lengths represent scales magnitude of the gradient. Maroon text shows the species scores for each spider.
abundPlot <- data.frame(Cluster <- as.factor(spider.clust),
ID <- as.factor(1:nrow(spider.abund)))
abundPlot <- cbind(abundPlot,
spider.abund)
abundPlot
## Cluster....as.factor.spider.clust. ID....as.factor.1.nrow.spider.abund..
## 1 1 1
## 2 1 2
## 3 1 3
## 4 1 4
## 5 1 5
## 6 1 6
## 7 1 7
## 8 2 8
## 9 3 9
## 10 3 10
## 11 3 11
## 12 3 12
## 13 1 13
## 14 1 14
## 15 2 15
## 16 2 16
## 17 2 17
## 18 2 18
## 19 2 19
## 20 2 20
## 21 2 21
## 22 4 22
## 23 4 23
## 24 4 24
## 25 4 25
## 26 4 26
## 27 4 27
## 28 4 28
## Alopacce Alopcune Alopfabr Arctlute Arctperi Auloalbi Pardlugu Pardmont
## 1 25 10 0 0 0 4 0 60
## 2 0 2 0 0 0 30 1 1
## 3 15 20 2 2 0 9 1 29
## 4 2 6 0 1 0 24 1 7
## 5 1 20 0 2 0 9 1 2
## 6 0 6 0 6 0 6 0 11
## 7 2 7 0 12 0 16 1 30
## 8 0 11 0 0 0 7 55 2
## 9 1 1 0 0 0 0 0 26
## 10 3 0 1 0 0 0 0 22
## 11 15 1 2 0 0 1 0 95
## 12 16 13 0 0 0 0 0 96
## 13 3 43 1 2 0 18 1 24
## 14 0 2 0 1 0 4 3 14
## 15 0 0 0 0 0 0 6 0
## 16 0 3 0 0 0 0 6 0
## 17 0 0 0 0 0 0 2 0
## 18 0 1 0 0 0 0 5 0
## 19 0 1 0 0 0 0 12 0
## 20 0 2 0 0 0 0 13 0
## 21 0 1 0 0 0 0 16 1
## 22 7 0 16 0 4 0 0 2
## 23 17 0 15 0 7 0 2 6
## 24 11 0 20 0 5 0 0 3
## 25 9 1 9 0 0 2 1 11
## 26 3 0 6 0 18 0 0 0
## 27 29 0 11 0 4 0 0 1
## 28 15 0 14 0 1 0 0 6
## Pardnigr Pardpull Trocterr Zoraspin
## 1 12 45 57 4
## 2 15 37 65 9
## 3 18 45 66 1
## 4 29 94 86 25
## 5 135 76 91 17
## 6 27 24 63 34
## 7 89 105 118 16
## 8 2 1 30 3
## 9 1 1 2 0
## 10 0 0 1 0
## 11 0 1 4 0
## 12 1 8 13 0
## 13 53 72 97 22
## 14 15 72 94 32
## 15 0 0 25 3
## 16 2 0 28 4
## 17 0 0 23 2
## 18 0 0 25 0
## 19 1 0 22 3
## 20 0 0 22 2
## 21 0 1 18 2
## 22 0 0 1 0
## 23 0 0 1 0
## 24 0 0 0 0
## 25 6 0 16 6
## 26 0 0 1 0
## 27 0 0 0 0
## 28 0 0 2 0
abund.long <- abundPlot |>
gather(key = "Species", value = "Count", 3:14)
colnames(abund.long) <- c("Cluster", "ID", "Species", "Count")
abund.long
## Cluster ID Species Count
## 1 1 1 Alopacce 25
## 2 1 2 Alopacce 0
## 3 1 3 Alopacce 15
## 4 1 4 Alopacce 2
## 5 1 5 Alopacce 1
## 6 1 6 Alopacce 0
## 7 1 7 Alopacce 2
## 8 2 8 Alopacce 0
## 9 3 9 Alopacce 1
## 10 3 10 Alopacce 3
## 11 3 11 Alopacce 15
## 12 3 12 Alopacce 16
## 13 1 13 Alopacce 3
## 14 1 14 Alopacce 0
## 15 2 15 Alopacce 0
## 16 2 16 Alopacce 0
## 17 2 17 Alopacce 0
## 18 2 18 Alopacce 0
## 19 2 19 Alopacce 0
## 20 2 20 Alopacce 0
## 21 2 21 Alopacce 0
## 22 4 22 Alopacce 7
## 23 4 23 Alopacce 17
## 24 4 24 Alopacce 11
## 25 4 25 Alopacce 9
## 26 4 26 Alopacce 3
## 27 4 27 Alopacce 29
## 28 4 28 Alopacce 15
## 29 1 1 Alopcune 10
## 30 1 2 Alopcune 2
## 31 1 3 Alopcune 20
## 32 1 4 Alopcune 6
## 33 1 5 Alopcune 20
## 34 1 6 Alopcune 6
## 35 1 7 Alopcune 7
## 36 2 8 Alopcune 11
## 37 3 9 Alopcune 1
## 38 3 10 Alopcune 0
## 39 3 11 Alopcune 1
## 40 3 12 Alopcune 13
## 41 1 13 Alopcune 43
## 42 1 14 Alopcune 2
## 43 2 15 Alopcune 0
## 44 2 16 Alopcune 3
## 45 2 17 Alopcune 0
## 46 2 18 Alopcune 1
## 47 2 19 Alopcune 1
## 48 2 20 Alopcune 2
## 49 2 21 Alopcune 1
## 50 4 22 Alopcune 0
## 51 4 23 Alopcune 0
## 52 4 24 Alopcune 0
## 53 4 25 Alopcune 1
## 54 4 26 Alopcune 0
## 55 4 27 Alopcune 0
## 56 4 28 Alopcune 0
## 57 1 1 Alopfabr 0
## 58 1 2 Alopfabr 0
## 59 1 3 Alopfabr 2
## 60 1 4 Alopfabr 0
## 61 1 5 Alopfabr 0
## 62 1 6 Alopfabr 0
## 63 1 7 Alopfabr 0
## 64 2 8 Alopfabr 0
## 65 3 9 Alopfabr 0
## 66 3 10 Alopfabr 1
## 67 3 11 Alopfabr 2
## 68 3 12 Alopfabr 0
## 69 1 13 Alopfabr 1
## 70 1 14 Alopfabr 0
## 71 2 15 Alopfabr 0
## 72 2 16 Alopfabr 0
## 73 2 17 Alopfabr 0
## 74 2 18 Alopfabr 0
## 75 2 19 Alopfabr 0
## 76 2 20 Alopfabr 0
## 77 2 21 Alopfabr 0
## 78 4 22 Alopfabr 16
## 79 4 23 Alopfabr 15
## 80 4 24 Alopfabr 20
## 81 4 25 Alopfabr 9
## 82 4 26 Alopfabr 6
## 83 4 27 Alopfabr 11
## 84 4 28 Alopfabr 14
## 85 1 1 Arctlute 0
## 86 1 2 Arctlute 0
## 87 1 3 Arctlute 2
## 88 1 4 Arctlute 1
## 89 1 5 Arctlute 2
## 90 1 6 Arctlute 6
## 91 1 7 Arctlute 12
## 92 2 8 Arctlute 0
## 93 3 9 Arctlute 0
## 94 3 10 Arctlute 0
## 95 3 11 Arctlute 0
## 96 3 12 Arctlute 0
## 97 1 13 Arctlute 2
## 98 1 14 Arctlute 1
## 99 2 15 Arctlute 0
## 100 2 16 Arctlute 0
## 101 2 17 Arctlute 0
## 102 2 18 Arctlute 0
## 103 2 19 Arctlute 0
## 104 2 20 Arctlute 0
## 105 2 21 Arctlute 0
## 106 4 22 Arctlute 0
## 107 4 23 Arctlute 0
## 108 4 24 Arctlute 0
## 109 4 25 Arctlute 0
## 110 4 26 Arctlute 0
## 111 4 27 Arctlute 0
## 112 4 28 Arctlute 0
## 113 1 1 Arctperi 0
## 114 1 2 Arctperi 0
## 115 1 3 Arctperi 0
## 116 1 4 Arctperi 0
## 117 1 5 Arctperi 0
## 118 1 6 Arctperi 0
## 119 1 7 Arctperi 0
## 120 2 8 Arctperi 0
## 121 3 9 Arctperi 0
## 122 3 10 Arctperi 0
## 123 3 11 Arctperi 0
## 124 3 12 Arctperi 0
## 125 1 13 Arctperi 0
## 126 1 14 Arctperi 0
## 127 2 15 Arctperi 0
## 128 2 16 Arctperi 0
## 129 2 17 Arctperi 0
## 130 2 18 Arctperi 0
## 131 2 19 Arctperi 0
## 132 2 20 Arctperi 0
## 133 2 21 Arctperi 0
## 134 4 22 Arctperi 4
## 135 4 23 Arctperi 7
## 136 4 24 Arctperi 5
## 137 4 25 Arctperi 0
## 138 4 26 Arctperi 18
## 139 4 27 Arctperi 4
## 140 4 28 Arctperi 1
## 141 1 1 Auloalbi 4
## 142 1 2 Auloalbi 30
## 143 1 3 Auloalbi 9
## 144 1 4 Auloalbi 24
## 145 1 5 Auloalbi 9
## 146 1 6 Auloalbi 6
## 147 1 7 Auloalbi 16
## 148 2 8 Auloalbi 7
## 149 3 9 Auloalbi 0
## 150 3 10 Auloalbi 0
## 151 3 11 Auloalbi 1
## 152 3 12 Auloalbi 0
## 153 1 13 Auloalbi 18
## 154 1 14 Auloalbi 4
## 155 2 15 Auloalbi 0
## 156 2 16 Auloalbi 0
## 157 2 17 Auloalbi 0
## 158 2 18 Auloalbi 0
## 159 2 19 Auloalbi 0
## 160 2 20 Auloalbi 0
## 161 2 21 Auloalbi 0
## 162 4 22 Auloalbi 0
## 163 4 23 Auloalbi 0
## 164 4 24 Auloalbi 0
## 165 4 25 Auloalbi 2
## 166 4 26 Auloalbi 0
## 167 4 27 Auloalbi 0
## 168 4 28 Auloalbi 0
## 169 1 1 Pardlugu 0
## 170 1 2 Pardlugu 1
## 171 1 3 Pardlugu 1
## 172 1 4 Pardlugu 1
## 173 1 5 Pardlugu 1
## 174 1 6 Pardlugu 0
## 175 1 7 Pardlugu 1
## 176 2 8 Pardlugu 55
## 177 3 9 Pardlugu 0
## 178 3 10 Pardlugu 0
## 179 3 11 Pardlugu 0
## 180 3 12 Pardlugu 0
## 181 1 13 Pardlugu 1
## 182 1 14 Pardlugu 3
## 183 2 15 Pardlugu 6
## 184 2 16 Pardlugu 6
## 185 2 17 Pardlugu 2
## 186 2 18 Pardlugu 5
## 187 2 19 Pardlugu 12
## 188 2 20 Pardlugu 13
## 189 2 21 Pardlugu 16
## 190 4 22 Pardlugu 0
## 191 4 23 Pardlugu 2
## 192 4 24 Pardlugu 0
## 193 4 25 Pardlugu 1
## 194 4 26 Pardlugu 0
## 195 4 27 Pardlugu 0
## 196 4 28 Pardlugu 0
## 197 1 1 Pardmont 60
## 198 1 2 Pardmont 1
## 199 1 3 Pardmont 29
## 200 1 4 Pardmont 7
## 201 1 5 Pardmont 2
## 202 1 6 Pardmont 11
## 203 1 7 Pardmont 30
## 204 2 8 Pardmont 2
## 205 3 9 Pardmont 26
## 206 3 10 Pardmont 22
## 207 3 11 Pardmont 95
## 208 3 12 Pardmont 96
## 209 1 13 Pardmont 24
## 210 1 14 Pardmont 14
## 211 2 15 Pardmont 0
## 212 2 16 Pardmont 0
## 213 2 17 Pardmont 0
## 214 2 18 Pardmont 0
## 215 2 19 Pardmont 0
## 216 2 20 Pardmont 0
## 217 2 21 Pardmont 1
## 218 4 22 Pardmont 2
## 219 4 23 Pardmont 6
## 220 4 24 Pardmont 3
## 221 4 25 Pardmont 11
## 222 4 26 Pardmont 0
## 223 4 27 Pardmont 1
## 224 4 28 Pardmont 6
## 225 1 1 Pardnigr 12
## 226 1 2 Pardnigr 15
## 227 1 3 Pardnigr 18
## 228 1 4 Pardnigr 29
## 229 1 5 Pardnigr 135
## 230 1 6 Pardnigr 27
## 231 1 7 Pardnigr 89
## 232 2 8 Pardnigr 2
## 233 3 9 Pardnigr 1
## 234 3 10 Pardnigr 0
## 235 3 11 Pardnigr 0
## 236 3 12 Pardnigr 1
## 237 1 13 Pardnigr 53
## 238 1 14 Pardnigr 15
## 239 2 15 Pardnigr 0
## 240 2 16 Pardnigr 2
## 241 2 17 Pardnigr 0
## 242 2 18 Pardnigr 0
## 243 2 19 Pardnigr 1
## 244 2 20 Pardnigr 0
## 245 2 21 Pardnigr 0
## 246 4 22 Pardnigr 0
## 247 4 23 Pardnigr 0
## 248 4 24 Pardnigr 0
## 249 4 25 Pardnigr 6
## 250 4 26 Pardnigr 0
## 251 4 27 Pardnigr 0
## 252 4 28 Pardnigr 0
## 253 1 1 Pardpull 45
## 254 1 2 Pardpull 37
## 255 1 3 Pardpull 45
## 256 1 4 Pardpull 94
## 257 1 5 Pardpull 76
## 258 1 6 Pardpull 24
## 259 1 7 Pardpull 105
## 260 2 8 Pardpull 1
## 261 3 9 Pardpull 1
## 262 3 10 Pardpull 0
## 263 3 11 Pardpull 1
## 264 3 12 Pardpull 8
## 265 1 13 Pardpull 72
## 266 1 14 Pardpull 72
## 267 2 15 Pardpull 0
## 268 2 16 Pardpull 0
## 269 2 17 Pardpull 0
## 270 2 18 Pardpull 0
## 271 2 19 Pardpull 0
## 272 2 20 Pardpull 0
## 273 2 21 Pardpull 1
## 274 4 22 Pardpull 0
## 275 4 23 Pardpull 0
## 276 4 24 Pardpull 0
## 277 4 25 Pardpull 0
## 278 4 26 Pardpull 0
## 279 4 27 Pardpull 0
## 280 4 28 Pardpull 0
## 281 1 1 Trocterr 57
## 282 1 2 Trocterr 65
## 283 1 3 Trocterr 66
## 284 1 4 Trocterr 86
## 285 1 5 Trocterr 91
## 286 1 6 Trocterr 63
## 287 1 7 Trocterr 118
## 288 2 8 Trocterr 30
## 289 3 9 Trocterr 2
## 290 3 10 Trocterr 1
## 291 3 11 Trocterr 4
## 292 3 12 Trocterr 13
## 293 1 13 Trocterr 97
## 294 1 14 Trocterr 94
## 295 2 15 Trocterr 25
## 296 2 16 Trocterr 28
## 297 2 17 Trocterr 23
## 298 2 18 Trocterr 25
## 299 2 19 Trocterr 22
## 300 2 20 Trocterr 22
## 301 2 21 Trocterr 18
## 302 4 22 Trocterr 1
## 303 4 23 Trocterr 1
## 304 4 24 Trocterr 0
## 305 4 25 Trocterr 16
## 306 4 26 Trocterr 1
## 307 4 27 Trocterr 0
## 308 4 28 Trocterr 2
## 309 1 1 Zoraspin 4
## 310 1 2 Zoraspin 9
## 311 1 3 Zoraspin 1
## 312 1 4 Zoraspin 25
## 313 1 5 Zoraspin 17
## 314 1 6 Zoraspin 34
## 315 1 7 Zoraspin 16
## 316 2 8 Zoraspin 3
## 317 3 9 Zoraspin 0
## 318 3 10 Zoraspin 0
## 319 3 11 Zoraspin 0
## 320 3 12 Zoraspin 0
## 321 1 13 Zoraspin 22
## 322 1 14 Zoraspin 32
## 323 2 15 Zoraspin 3
## 324 2 16 Zoraspin 4
## 325 2 17 Zoraspin 2
## 326 2 18 Zoraspin 0
## 327 2 19 Zoraspin 3
## 328 2 20 Zoraspin 2
## 329 2 21 Zoraspin 2
## 330 4 22 Zoraspin 0
## 331 4 23 Zoraspin 0
## 332 4 24 Zoraspin 0
## 333 4 25 Zoraspin 6
## 334 4 26 Zoraspin 0
## 335 4 27 Zoraspin 0
## 336 4 28 Zoraspin 0
abund.sub <- filter(abund.long, Count > 0)
abund.sub
## Cluster ID Species Count
## 1 1 1 Alopacce 25
## 2 1 3 Alopacce 15
## 3 1 4 Alopacce 2
## 4 1 5 Alopacce 1
## 5 1 7 Alopacce 2
## 6 3 9 Alopacce 1
## 7 3 10 Alopacce 3
## 8 3 11 Alopacce 15
## 9 3 12 Alopacce 16
## 10 1 13 Alopacce 3
## 11 4 22 Alopacce 7
## 12 4 23 Alopacce 17
## 13 4 24 Alopacce 11
## 14 4 25 Alopacce 9
## 15 4 26 Alopacce 3
## 16 4 27 Alopacce 29
## 17 4 28 Alopacce 15
## 18 1 1 Alopcune 10
## 19 1 2 Alopcune 2
## 20 1 3 Alopcune 20
## 21 1 4 Alopcune 6
## 22 1 5 Alopcune 20
## 23 1 6 Alopcune 6
## 24 1 7 Alopcune 7
## 25 2 8 Alopcune 11
## 26 3 9 Alopcune 1
## 27 3 11 Alopcune 1
## 28 3 12 Alopcune 13
## 29 1 13 Alopcune 43
## 30 1 14 Alopcune 2
## 31 2 16 Alopcune 3
## 32 2 18 Alopcune 1
## 33 2 19 Alopcune 1
## 34 2 20 Alopcune 2
## 35 2 21 Alopcune 1
## 36 4 25 Alopcune 1
## 37 1 3 Alopfabr 2
## 38 3 10 Alopfabr 1
## 39 3 11 Alopfabr 2
## 40 1 13 Alopfabr 1
## 41 4 22 Alopfabr 16
## 42 4 23 Alopfabr 15
## 43 4 24 Alopfabr 20
## 44 4 25 Alopfabr 9
## 45 4 26 Alopfabr 6
## 46 4 27 Alopfabr 11
## 47 4 28 Alopfabr 14
## 48 1 3 Arctlute 2
## 49 1 4 Arctlute 1
## 50 1 5 Arctlute 2
## 51 1 6 Arctlute 6
## 52 1 7 Arctlute 12
## 53 1 13 Arctlute 2
## 54 1 14 Arctlute 1
## 55 4 22 Arctperi 4
## 56 4 23 Arctperi 7
## 57 4 24 Arctperi 5
## 58 4 26 Arctperi 18
## 59 4 27 Arctperi 4
## 60 4 28 Arctperi 1
## 61 1 1 Auloalbi 4
## 62 1 2 Auloalbi 30
## 63 1 3 Auloalbi 9
## 64 1 4 Auloalbi 24
## 65 1 5 Auloalbi 9
## 66 1 6 Auloalbi 6
## 67 1 7 Auloalbi 16
## 68 2 8 Auloalbi 7
## 69 3 11 Auloalbi 1
## 70 1 13 Auloalbi 18
## 71 1 14 Auloalbi 4
## 72 4 25 Auloalbi 2
## 73 1 2 Pardlugu 1
## 74 1 3 Pardlugu 1
## 75 1 4 Pardlugu 1
## 76 1 5 Pardlugu 1
## 77 1 7 Pardlugu 1
## 78 2 8 Pardlugu 55
## 79 1 13 Pardlugu 1
## 80 1 14 Pardlugu 3
## 81 2 15 Pardlugu 6
## 82 2 16 Pardlugu 6
## 83 2 17 Pardlugu 2
## 84 2 18 Pardlugu 5
## 85 2 19 Pardlugu 12
## 86 2 20 Pardlugu 13
## 87 2 21 Pardlugu 16
## 88 4 23 Pardlugu 2
## 89 4 25 Pardlugu 1
## 90 1 1 Pardmont 60
## 91 1 2 Pardmont 1
## 92 1 3 Pardmont 29
## 93 1 4 Pardmont 7
## 94 1 5 Pardmont 2
## 95 1 6 Pardmont 11
## 96 1 7 Pardmont 30
## 97 2 8 Pardmont 2
## 98 3 9 Pardmont 26
## 99 3 10 Pardmont 22
## 100 3 11 Pardmont 95
## 101 3 12 Pardmont 96
## 102 1 13 Pardmont 24
## 103 1 14 Pardmont 14
## 104 2 21 Pardmont 1
## 105 4 22 Pardmont 2
## 106 4 23 Pardmont 6
## 107 4 24 Pardmont 3
## 108 4 25 Pardmont 11
## 109 4 27 Pardmont 1
## 110 4 28 Pardmont 6
## 111 1 1 Pardnigr 12
## 112 1 2 Pardnigr 15
## 113 1 3 Pardnigr 18
## 114 1 4 Pardnigr 29
## 115 1 5 Pardnigr 135
## 116 1 6 Pardnigr 27
## 117 1 7 Pardnigr 89
## 118 2 8 Pardnigr 2
## 119 3 9 Pardnigr 1
## 120 3 12 Pardnigr 1
## 121 1 13 Pardnigr 53
## 122 1 14 Pardnigr 15
## 123 2 16 Pardnigr 2
## 124 2 19 Pardnigr 1
## 125 4 25 Pardnigr 6
## 126 1 1 Pardpull 45
## 127 1 2 Pardpull 37
## 128 1 3 Pardpull 45
## 129 1 4 Pardpull 94
## 130 1 5 Pardpull 76
## 131 1 6 Pardpull 24
## 132 1 7 Pardpull 105
## 133 2 8 Pardpull 1
## 134 3 9 Pardpull 1
## 135 3 11 Pardpull 1
## 136 3 12 Pardpull 8
## 137 1 13 Pardpull 72
## 138 1 14 Pardpull 72
## 139 2 21 Pardpull 1
## 140 1 1 Trocterr 57
## 141 1 2 Trocterr 65
## 142 1 3 Trocterr 66
## 143 1 4 Trocterr 86
## 144 1 5 Trocterr 91
## 145 1 6 Trocterr 63
## 146 1 7 Trocterr 118
## 147 2 8 Trocterr 30
## 148 3 9 Trocterr 2
## 149 3 10 Trocterr 1
## 150 3 11 Trocterr 4
## 151 3 12 Trocterr 13
## 152 1 13 Trocterr 97
## 153 1 14 Trocterr 94
## 154 2 15 Trocterr 25
## 155 2 16 Trocterr 28
## 156 2 17 Trocterr 23
## 157 2 18 Trocterr 25
## 158 2 19 Trocterr 22
## 159 2 20 Trocterr 22
## 160 2 21 Trocterr 18
## 161 4 22 Trocterr 1
## 162 4 23 Trocterr 1
## 163 4 25 Trocterr 16
## 164 4 26 Trocterr 1
## 165 4 28 Trocterr 2
## 166 1 1 Zoraspin 4
## 167 1 2 Zoraspin 9
## 168 1 3 Zoraspin 1
## 169 1 4 Zoraspin 25
## 170 1 5 Zoraspin 17
## 171 1 6 Zoraspin 34
## 172 1 7 Zoraspin 16
## 173 2 8 Zoraspin 3
## 174 1 13 Zoraspin 22
## 175 1 14 Zoraspin 32
## 176 2 15 Zoraspin 3
## 177 2 16 Zoraspin 4
## 178 2 17 Zoraspin 2
## 179 2 19 Zoraspin 3
## 180 2 20 Zoraspin 2
## 181 2 21 Zoraspin 2
## 182 4 25 Zoraspin 6
set.seed(42)
Y <- as.matrix(spider.abund)
spider.PERM <- adonis2(Y ~ spider.env$soil.dry + spider.env$fallen.leaves + spider.env$reflection + spider.env$moss + spider.env$bare.sand + spider.env$herb.layer, method = "bray")
spider.PERM
## Permutation test for adonis under reduced model
## Permutation: free
## Number of permutations: 999
##
## adonis2(formula = Y ~ spider.env$soil.dry + spider.env$fallen.leaves + spider.env$reflection + spider.env$moss + spider.env$bare.sand + spider.env$herb.layer, method = "bray")
## Df SumOfSqs R2 F Pr(>F)
## Model 6 5.8906 0.72157 9.0705 0.001 ***
## Residual 21 2.2730 0.27843
## Total 27 8.1636 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Environmental variables mapped into different areas of the nMDS space. Fallen leaves were positive in nMDS1 and nMDS2, opposite from high values of moss and reflection. Furthermore, moss and reflection mapped onto similar gradients, so they likely explain similar variation among sites. Bare sand and dry soil are also mapped opposite one another, implying that they explain similar variation in opposite directions. Herb layer is not strongly represented in nMDS1, but has a noticeable influence on nMDS2, with high herb layer values reflected in negative nMDS2 scores.
Clusters show apparent trends to have similar environmental characteristics. Cluster 1 sites typically have dry soil and some herb layer. Cluster 2 sites are dominated by fallen leaves. Cluster 3 tends toward high values of moss and reflection, and cluster 4 consists of mainly bare sand habitats.
Cluster analysis showed that there do appear to be patterns in hunting spider community composition among sites. These clusters separate well in an nMDS ordination space. Fitting environmental variables onto the nMDS shows that habitat influences these patterns: groups can be categorized by being dominated by fallen leaves, dry soil and herb layer, moss and high reflection, or bare sand. Further analysis with hypothesis tests (i.e., PERMANOVA) would be needed to determine if the apparent groupings are significant and how much variation each environmental variable is explaining.
I actually really enjoyed this assignment - it felt like a solid synthesis and conclusion of the ordinations we have been working with.
I wanted to go a little further with this one for the draft, but with a proposal deadline the same evening, this is as far as I got. If I have the time before Wednesday, I would like to include the PERMANOVA to see how the environmental variables are actually explaining the data. I also would like to include abundance bar plots for each cluster to better show how each differs.