Ant community composition in 24 islands in the Thousands Island Lake, China.
https://emilio-berti.github.io/datasets/ants.zip
13 December 2024
Ant community composition in 24 islands in the Thousands Island Lake, China.
https://emilio-berti.github.io/datasets/ants.zip
islands <- read.csv("islands.csv") head(islands, 3)
island longitude latitude 1 S1 118.8865 29.52810 2 S2 118.8525 29.49686 3 S3 118.9067 29.50562
island
is the ID of the island (as in the prevous figure).longitude
and latitude
are the coordinates of the islands.traits <- read.csv("ant_traits.csv") head(traits, 3)
torax_length eye_width leg_length scape_length mandible_length 1 0.8844444 0.000000 1.458398 0.4617310 0.3879327 2 1.1768278 0.000000 1.552939 0.5216261 0.3639346 3 2.0600444 0.114711 1.361409 0.6837751 0.5864359
composition <- read.csv("ant_composition.csv") composition[1:3, 1:4]
island Aenictus_fuchuanensis Aenictus_laeviceps Anochetus_risii 1 S1 1 1 1 2 S10 1 1 1 3 S11 0 1 1
island
is the ID of the island (as in islands.csv
)1
) or absence (0
) of each species (one column = one species) in the islands.Can you identify the general differences between ant species in morhpological traits?
Hint: Use a PCA approach (prcomp()
) and the traits
table (ant_traits.csv).
Can you arrange the islands in a plot ordering them by similarity in species composition?
Hint: Use a nMDS approach (MASS::isoMDS()
) and the composition
table (ant_composition.csv).
Tip: Because you have presence/absence data, distance between communities should be calculated using an appropriate method, such a the Jaccard dissimilarity. In R, this can be done specifying method = "binary"
in dist()
, e.g., dist(<table>, method = "binary")
.
Can you identify a spatial gradient in the dissimilarities of ant composition between islands?
Hint: Plot the nMDS axes against longitude
and latitude
from the islands
table (islands.csv).
Can you identify the general differences between ant species in morhpological traits?
=======Can you identify the general differences between ant species in morhpological traits?
>>>>>>> 0f9eeaf2bb6928b36cf132b3ee25a828e07f017dHint: Use a PCA approach (prcomp()
) and the traits
table (ant_traits.csv).
pca_traits <- prcomp(traits, scale = TRUE, center = TRUE) summary(pca_traits)
Importance of components: PC1 PC2 PC3 PC4 PC5 Standard deviation 1.5656 1.0923 0.8970 0.66494 0.33020 Proportion of Variance 0.4903 0.2386 0.1609 0.08843 0.02181 Cumulative Proportion 0.4903 0.7289 0.8898 0.97819 1.00000<<<<<<< HEAD
biplot(pca_traits, xlabs = rep("+", nrow(traits)), col = c("grey20", "blue"))
pairs(traits, pch = 20, cex = 1, lower.panel = panel.smooth, upper.panel = panel.cor)
Gradient from ants with short body but long mandibles to ants with long body but short mandibles to ants.
Can you arrange the islands in a plot ordering them by similarity in species composition?
jaccard <- dist(composition[, -1], method = "binary") nMDS <- MASS::isoMDS(jaccard, k = 2)=======
The first 2 PCs explain 75% of the variability. I am happy with that and continue with only thos two PCs.
biplot(pca_traits, xlabs = rep("+", nrow(traits)), col = c("grey20", "blue"))
mandible_length
which is negatively correlated with most lengths.leg_Length
) and the torax (torax_length
), the smaller the mandibles (mandible_length
).If you plot all variables one against the other, you will also see these patterns…
… but you need to look at 10 figures instead of one.
Gradient from ants with short body but long mandibles to ants with long body but short mandibles to ants.
Can you arrange the islands in a plot ordering them by similarity in species composition?
First, we need to calculate the dissimilarity between islands. We do this using dist()
amd specifying method = "binary"
, as the data has 0
and 1
values.
jaccard <- dist(composition[, -1], method = "binary")
Binary distance is also known as Jaccard dissimiliarity.
We then can run a nMDS using MASS::isoMDS()
.
nMDS <- MASS::isoMDS(jaccard)>>>>>>> 0f9eeaf2bb6928b36cf132b3ee25a828e07f017d
initial value 27.717339 iter 5 value 24.592216 final value 24.496130 converged<<<<<<< HEAD
plot(nMDS$points, pch = 20, asp = 1) text(nMDS$points, labels = composition[, 1], adj = c(0.5, -0.5))
Can you identify a spatial gradient in the dissimilarities of ant composition between islands?
=======And we obtain the ordering of the islands on a plot.
plot(nMDS$points, pch = 20, asp = 1) text(nMDS$points, labels = composition[, 1], adj = c(0.5, -0.5))
Can you identify a spatial gradient in the dissimilarities of ant composition between islands?
>>>>>>> 0f9eeaf2bb6928b36cf132b3ee25a828e07f017dislands <- islands[order(islands$island, composition$island), ] # reorder to match par(mfrow = c(2, 2), mar = c(4, 4, 2, 2)) <<<<<<< HEAD scatter.smooth(islands$longitude, nMDS$points[, 1]); scatter.smooth(islands$longitude, nMDS$points[, 2]) scatter.smooth(islands$latitude, nMDS$points[, 1]); scatter.smooth(islands$latitude, nMDS$points[, 2])
No clear spatial pattern from this.
No clear spatial pattern from this, but remember: distances in nMDS space are not proportional to distances in real dissimilarities. So this is a bad approach: don’t get tempted to further analyze nMDS results.