# Distance matrix based on a simplified phylogenetic classification
# Retrieve hierarchical classification from species list
splist <- as.character(fishtraits$LatinName)
spcla <- classification(splist, db = "gbif")
# Compute the distance matrix and the phylogenetic tree
tr <- class2tree(spcla)
tr$classification
tr$distmat
# Convert the tree to a cophenetic matrix
# constrained between 0 and 1
phylo.d <- cophenetic(tr$phylo) / 100
# Replace full species names by name codes
rownames(phylo.d) <- names(spe)
colnames(phylo.d) <- names(spe)
Hint We used the argument db = "gbif" to retrieve the current taxonomic
classification from the GBIF database (Global Biodiversity Information Facility,
www.gbif.org). Other databases are available, such as "ncbi", related to the
Genbank database.
We also need a functional dissimilarity matrix of the fish species based on their
functional traits. Since the trait matrix contains both quantitative and binary variables, we compute Gower dissimilarities with the gowdis() function. We can then
plot the tree of the simplified phylogenetic classification and the dendrogram of a
Ward clustering of the functional dissimilarity matrix (Fig. 8.11).
# Functional dissimilarity matrix (Gower dissimilarity)
trait.d <- gowdis(tra, asym.bin = 4:9)
# Plot the tree and the dendrogram
trait.gw <- hclust(trait.d, "ward.D2")
par(mfrow = c(1, 2))
plot(tr)
plot(trait.gw, hang = -1, main = "")
We are now ready to run the Rao() function to compute species (i.e., taxonomic
without reference to phylogeny), phylogenetic and functional diversity indices and
their decomposition into alpha, beta and gamma components.
8.5 Functional Diversity, Functional Composition and Phylogenetic. . .
409
# Retrieve hierarchical classification from species list
splist <- as.character(fishtraits$LatinName)
spcla <- classification(splist, db = "gbif")
# Compute the distance matrix and the phylogenetic tree
tr <- class2tree(spcla)
tr$classification
tr$distmat
# Convert the tree to a cophenetic matrix
# constrained between 0 and 1
phylo.d <- cophenetic(tr$phylo) / 100
# Replace full species names by name codes
rownames(phylo.d) <- names(spe)
colnames(phylo.d) <- names(spe)
Hint We used the argument db = "gbif" to retrieve the current taxonomic
classification from the GBIF database (Global Biodiversity Information Facility,
www.gbif.org). Other databases are available, such as "ncbi", related to the
Genbank database.
We also need a functional dissimilarity matrix of the fish species based on their
functional traits. Since the trait matrix contains both quantitative and binary variables, we compute Gower dissimilarities with the gowdis() function. We can then
plot the tree of the simplified phylogenetic classification and the dendrogram of a
Ward clustering of the functional dissimilarity matrix (Fig. 8.11).
# Functional dissimilarity matrix (Gower dissimilarity)
trait.d <- gowdis(tra, asym.bin = 4:9)
# Plot the tree and the dendrogram
trait.gw <- hclust(trait.d, "ward.D2")
par(mfrow = c(1, 2))
plot(tr)
plot(trait.gw, hang = -1, main = "")
We are now ready to run the Rao() function to compute species (i.e., taxonomic
without reference to phylogeny), phylogenetic and functional diversity indices and
their decomposition into alpha, beta and gamma components.
8.5 Functional Diversity, Functional Composition and Phylogenetic. . .
409
