]> git.donarmstrong.com Git - ape.git/blob - man/makeNodeLabel.Rd
various corrections
[ape.git] / man / makeNodeLabel.Rd
1 \name{makeNodeLabel}
2 \alias{makeNodeLabel}
3 \title{Makes Node Labels}
4 \description{
5   This function makes node labels in a tree in a flexible way.
6 }
7
8 \usage{
9 makeNodeLabel(phy, method = "number", prefix = "Node", nodeList = list(), ...)
10 }
11 \arguments{
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
16     of these.}
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}.}
21 }
22 \details{
23   The three methods are described below:
24
25   \itemize{
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}.}
41   }
42
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.
47 }
48 \value{
49   an object of class \code{"phylo"}.
50 }
51 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
52 \seealso{
53   \code{\link{makeLabel}}, \code{\link[base]{grep}}
54 }
55 \examples{
56 tr <-
57 "((Pan_paniscus,Pan_troglodytes),((Homo_sapiens,Homo_erectus),Homo_abilis));"
58 tr <- read.tree(text = tr)
59 tr <- makeNodeLabel(tr, "u", nodeList = list(Pan = "Pan", Homo = "Homo"))
60 plot(tr, show.node.label = TRUE)
61 ### does not erase the previous node labels:
62 tr <- makeNodeLabel(tr, "u", nodeList = list(Hominid = c("Pan","Homo")))
63 plot(tr, show.node.label = TRUE)
64 ### the two previous commands could be combined:
65 L <- list(Pan = "Pan", Homo = "Homo", Hominid = c("Pan","Homo"))
66 tr <- makeNodeLabel(tr, "u", nodeList = L)
67 ### combining different methods:
68 tr <- makeNodeLabel(tr, c("n", "u"), prefix = "#", nodeList = list(Hominid = c("Pan","Homo")))
69 plot(tr, show.node.label = TRUE)
70 }
71 \keyword{manip}