# Generate a random tree
tree <- ape::rcoal(20)
# Create a presence-absence matrix
mat <- matrix(sample(c(1,0), 20*10, replace = TRUE), ncol = 20, nrow = 10)
colnames(mat) <- tree$tip.label
# Create a random adjacency matrix
adj <- matrix(sample(c(1,0), 10*10, replace = TRUE), ncol = 10, nrow = 10)
# Fill the diagonals with 1
diag(adj) <- 1
# Calculate the relative PD for 100 slices
rPD <- r_phylo(tree, n = 100, mat = mat, index = "PD")
# Plot the relative PD of the first assemblage
plot(rPD[[1]])
# Calculate the relative PE for 100 slices
rPE <- r_phylo(tree, n = 100, mat = mat, index = "PE")
# Plot the relative PE of the first assemblage
plot(rPE[[1]])
# Calculate the relative PB for 100 slices
rPB <- r_phylo(tree, n = 100, mat = mat, adj = adj, index = "PB")
# Plot the relative PB of the first assemblage
plot(rPB[[1]])
# Calculate the relative PB_RW for 100 slices
rPB_RW <- r_phylo(tree, n = 100, mat = mat, adj = adj, index = "PB_RW")
# Plot the relative PB_RW of the first assemblage
plot(rPB_RW[[1]])
Run the code above in your browser using DataLab