3 \title{Swapping sister clades}
5 For a given node, rotate exchanges the position of two clades descending from this node. It can handle dichotomies as well as polytomies. In the latter case, two clades from the polytomy are selected for swapping.}
7 rotate(phy, node, polytom = c(1, 2))
10 \item{phy}{an object of class \code{"phylo"}.}
11 \item{node}{a vector of mode numeric or character specifying the number of the node}
12 \item{polytom}{a vector of mode numeric and length two specifying the two clades that should be exchanged in a polytomy}
15 phy can be either rooted or unrooted, contain polytomies and lack branch lengths. In the presence of very short branch lengths it is convenient to plot the phylogenetic tree without branch lengths in order to identify the number of the node in question.
17 node can be any of the interior nodes of a phylogenetic tree including the root node. Number of the nodes can be identified by the nodelabels function. Alternatively, you can specify a vector of length two that contains either the number or the names of two tips that coalesce in the node of interest.
19 If the node subtends a polytomy, any two clades of the the polytomy can be chosen by polytom. On a plotted phylogeny, the clades are numbered from bottom to top and polytom is used to index the two clades one likes to swop.
22 an object of class \code{"phylo"}.
24 \author{Christoph Heibl \email{heibl@lmu.de}}
26 \code{\link{plot.phylo}},
27 \code{\link{nodelabels}},
29 \code{\link{drop.tip}}}
31 # create a random tree:
34 # visualize labels of internal nodes:
35 plot.phylo(tre, use.edge.length=FALSE)
38 # rotate clades around node 30:
39 tre.new <- rotate(tre, 30)
41 # compare the results:
42 par(mfrow=c(1,2)) # split graphical device
43 plot(tre) # plot old tre
44 plot(tre.new) # plot new tree
46 # visualize labels of terminal nodes:
50 # rotate clades containing nodes 12 and 20:
51 tre.new <- rotate(tre, c(12, 21))
53 # compare the results:
54 par(mfrow=c(1,2)) # split graphical device
55 plot(tre) # plot old tre
56 plot(tre.new) # plot new tree
58 # or you migth just specify tiplabel names:
59 tre.new <- rotate(tre, c("t3", "t14"))
61 # compare the results:
62 par(mfrow=c(1,2)) # devide graphical device
63 plot(tre) # plot old tre
64 plot(tre.new) # plot new tree