1 ## identify.phylo.R (2011-03-23)
3 ## Graphical Identification of Nodes and Tips
5 ## Copyright 2008-2011 Emmanuel Paradis
7 ## This file is part of the R-package `ape'.
8 ## See the file ../COPYING for licensing issues.
10 identify.phylo <- function(x, nodes = TRUE, tips = FALSE,
11 labels = FALSE, quiet = FALSE, ...)
14 cat("Click close to a node of the tree...\n")
16 if (is.null(xy)) return(NULL)
17 lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
18 ## rescale the coordinates (especially if the x- and
19 ## y-scales are very different):
21 rescaleX <- pin[1]/max(lastPP$xx)
22 xx <- rescaleX * lastPP$xx
23 rescaleY <- pin[2]/max(lastPP$yy)
24 yy <- rescaleY * lastPP$yy
25 xy$x <- rescaleX * xy$x
26 xy$y <- rescaleY * xy$y
28 d <- (xy$x - xx)^2 + (xy$y - yy)^2 # no need to sqrt()
31 if (NODE <= lastPP$Ntip) {
32 res$tips <- if (labels) x$tip.label[NODE] else NODE
36 TIPS <- prop.part(x)[[NODE - lastPP$Ntip]]
37 res$tips <- if (labels) x$tip.label[TIPS] else TIPS
40 if (is.null(x$node.label)) labels <- FALSE
41 res$nodes <- if (labels) x$node.label[NODE - lastPP$Ntip] else NODE