3 ## Ancestral Character Estimation
5 ## Copyright 2009 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 if (length(tips) == 1) return(TRUE)
16 n <- length(phy$tip.label)
17 if (length(tips) == n) return(TRUE)
19 if (is.numeric(tips)) {
21 stop("incorrect tip#: should not be greater than the number of tips")
24 if (is.character(tips))
25 tips <- which(phy$tip.label %in% tips)
28 outgrp <- phy$tip.label[-tips][1]
29 phy <- root(phy, outgroup = outgrp, resolve.root = TRUE)
31 } else rerooted <- FALSE
35 seq.nod <- .Call("seq_root2tip", phy$edge, n, phy$Nnode, PACKAGE = "ape")
40 x <- unique(unlist(lapply(sn, "[", i)))
41 if (length(x) != 1) break
45 desc <- which(unlist(lapply(seq.nod, function(x) any(x %in% newroot))))
47 zoom(phy, tips, subtree = FALSE, ...)
49 mtext("Input tree arbitrarily rerooted", side = 1, cex = 0.9)
51 ## assuming that both vectors are sorted:
53 } # end of is.monophyletic