3 \title{Makes Node Labels}
5 This function makes node labels in a tree in a flexible way.
9 makeNodeLabel(phy, method = "number", prefix = "Node", nodeList = list(), ...)
12 \item{phy}{an object of class \code{"phylo"}.}
13 \item{method}{a character string giving the method used to create the
14 labels. Three choices are possible: \code{"number"} (the default),
15 \code{"md5sum"}, and \code{"user"}, or any unambiguous abbreviation
17 \item{prefix}{the prefix used if \code{method = "number"}.}
18 \item{nodeList}{a named list specifying how nodes are names if
19 \code{method = "user"} (see details and examples).}
20 \item{\dots}{further arguments passed to \code{grep}.}
23 The three methods are described below:
26 \item{``number''}{The labels are created with 1, 2, \dots prefixed
27 with the argument \code{prefix}; thus the default is to have
28 Node1, Node2, \dots Set \code{prefix = ""} to have only numbers.}
29 \item{``md5sum''}{For each node, the labels of the tips descendant
30 from this node are extracted, sorted alphabetically, and written
31 into a temporary file, then the md5sum of this file is extracted
32 and used as label. This results in a 32-character string which is
33 unique (even accross trees) for a given set of tip labels.}
34 \item{``user''}{the argument \code{nodeList} must be a list with
35 names, the latter will be used as node labels. For each element of
36 \code{nodeList}, the tip labels of the tree are searched for
37 patterns present in this element: this is done using
38 \code{\link[base]{grep}}. Then the most recent common ancestor of
39 the matching tips is given the corresponding names as labels. This
40 is repeated for each element of \code{nodeList}.}
43 The method \code{"user"} can be used in combination with either of the
44 two others (see examples). Note that this method only modifies the
45 specified node labels (so that if the other nodes have already labels
46 they are not modified) while the two others change all labels.
49 an object of class \code{"phylo"}.
51 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
53 \code{\link{makeLabel}}, \code{\link[base]{grep}},
54 \code{\link{mixedFontLabel}}
58 "((Pan_paniscus,Pan_troglodytes),((Homo_sapiens,Homo_erectus),Homo_abilis));"
59 tr <- read.tree(text = tr)
60 tr <- makeNodeLabel(tr, "u", nodeList = list(Pan = "Pan", Homo = "Homo"))
61 plot(tr, show.node.label = TRUE)
62 ### does not erase the previous node labels:
63 tr <- makeNodeLabel(tr, "u", nodeList = list(Hominid = c("Pan","Homo")))
64 plot(tr, show.node.label = TRUE)
65 ### the two previous commands could be combined:
66 L <- list(Pan = "Pan", Homo = "Homo", Hominid = c("Pan","Homo"))
67 tr <- makeNodeLabel(tr, "u", nodeList = L)
68 ### combining different methods:
69 tr <- makeNodeLabel(tr, c("n", "u"), prefix = "#", nodeList = list(Hominid = c("Pan","Homo")))
70 plot(tr, show.node.label = TRUE)