1 speciesTree <- function(x, FUN = min)
2 ### FUN = min => MAXTREE (Liu et al. 2010)
3 ### FUN = sum => shallowest divergence (Maddison & Knowles 2006)
5 test.ultra <- which(!unlist(lapply(x, is.ultrametric)))
6 if (length(test.ultra))
7 stop(paste("the following trees were not ultrametric:\n",
8 paste(test.ultra, collapse = " ")))
11 D <- lapply(x, cophenetic.phylo)
12 nms <- rownames(D[[1]])
14 M <- matrix(0, n*(n - 1)/2, Ntree)
15 for (i in 1:Ntree) M[, i] <- as.dist(D[[i]][nms, nms])
17 attributes(Y) <- list(Size = n, Labels = nms, Diag = FALSE,
18 Upper = FALSE, class = "dist")
19 as.phylo(stats::hclust(Y, "single"))