# Measuring phylogenetic signal in species interactions using a Mantel test
# (do closely related species interact with similar partners?)
library(RPANDA)
# Load the data
data(mycorrhizal_network)
network <- mycorrhizal_network[[1]] # bipartite interaction matrix
tree_orchids <- mycorrhizal_network[[2]] # phylogenetic tree (phylo object)
network <- network[,tree_orchids$tip.label]
ecological_distances <- as.matrix(vegan::vegdist(t(network), "jaccard", binary=FALSE))
phylogenetic_distances <- cophenetic.phylo(tree_orchids)
mantel_test(as.dist(ecological_distances) ~ as.dist(phylogenetic_distances),
correlation="Pearson", nperm = 10000)
Run the code above in your browser using DataLab