13 December 2024

The Dataset

The Dataset: islands

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.

The Dataset: ant traits

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

The Dataset: ant composition

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)
  • Other columns show the presence (1) or absence (0) of each species (one column = one species) in the islands.

Question #1

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).

Question #2

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").

Question #3

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).

<<<<<<< HEAD

Question #1

Can you identify the general differences between ant species in morhpological traits?

=======

Question #1

Can you identify the general differences between ant species in morhpological traits?

>>>>>>> 0f9eeaf2bb6928b36cf132b3ee25a828e07f017d

Hint: Use a PCA approach (prcomp()) and the traits table (ant_traits.csv).

Answer #1

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

Answer #1

biplot(pca_traits, xlabs = rep("+", nrow(traits)), col = c("grey20", "blue"))

Answer #1

pairs(traits, pch = 20, cex = 1, lower.panel = panel.smooth, upper.panel = panel.cor)

Answer #1

Gradient from ants with short body but long mandibles to ants with long body but short mandibles to ants.

Question #2

Can you arrange the islands in a plot ordering them by similarity in species composition?

Answer #2

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.

Answer #1

biplot(pca_traits, xlabs = rep("+", nrow(traits)), col = c("grey20", "blue"))

  1. Lengths all correlated (slightly or strongly)
  2. Exception is mandible_length which is negatively correlated with most lengths.
  3. In general, the longer the legs (leg_Length) and the torax (torax_length), the smaller the mandibles (mandible_length).

Answer #1

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.

Answer #1

Gradient from ants with short body but long mandibles to ants with long body but short mandibles to ants.

Two species as example.

Question #2

Can you arrange the islands in a plot ordering them by similarity in species composition?

Answer #2

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.

Answer #2

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

Answer #2

plot(nMDS$points, pch = 20, asp = 1)
text(nMDS$points, labels = composition[, 1], adj = c(0.5, -0.5))

Question #3

Can you identify a spatial gradient in the dissimilarities of ant composition between islands?

=======

Answer #2

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))

Question #3

Can you identify a spatial gradient in the dissimilarities of ant composition between islands?

>>>>>>> 0f9eeaf2bb6928b36cf132b3ee25a828e07f017d

Answer #3

islands <- 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])

Answer #3

No clear spatial pattern from this.

======= # just plotting longitude and latitude against nMDS axes 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])

Answer #3

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.

>>>>>>> 0f9eeaf2bb6928b36cf132b3ee25a828e07f017d