1 ## is.monophyletic.R (2012-03-23)
5 ## Copyright 2009-2012 Johan Nylander and Emmanuel Paradis
7 ## This file is part of the R-package `ape'.
8 ## See the file ../COPYING for licensing issues.
11 function(phy, tips, reroot = !is.rooted(phy), plot = FALSE, ...)
13 if (!inherits(phy, "phylo"))
14 stop("object 'phy' is not of class 'phylo'")
15 n <- length(phy$tip.label)
16 if (length(tips) %in% c(1L, n)) return(TRUE)
18 if (is.numeric(tips)) {
20 stop("incorrect tip#: should not be greater than the number of tips")
21 tips <- sort(as.integer(tips))
23 if (is.character(tips))
24 tips <- which(phy$tip.label %in% tips)
27 outgrp <- phy$tip.label[-tips][1]
28 phy <- root(phy, outgroup = outgrp, resolve.root = TRUE)
30 } else rerooted <- FALSE
34 seq.nod <- .Call("seq_root2tip", phy$edge, n, phy$Nnode, PACKAGE = "ape")
39 x <- unique(unlist(lapply(sn, "[", i)))
40 if (length(x) != 1) break
44 desc <- which(unlist(lapply(seq.nod, function(x) any(x %in% newroot))))
46 zoom(phy, tips, subtree = FALSE, ...)
48 mtext("Input tree arbitrarily rerooted", side = 1, cex = 0.9)
50 ## assuming that both vectors are sorted: