paste.tree | R Documentation |
Internal function for posterior.evolrate
.
paste.tree(tr1, tr2)
tr1 |
receptor tree. |
tr2 |
donor clade. |
Primarily designed as an internal function for posterior.evolrate
; however, can be used to graft a clade onto a receptor tree at the "sticky tip" labeled with "NA"
.
The donor clade needs to have a root edge, even if it is zero length.
A tree.
Liam Revell liam.revell@umb.edu
Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). PeerJ, 12, e16505.
## create two random trees
tr1<-rtree(10)
tr2<-rtree(10)
## make one tip "sticky" by renaming it "NA"
tr1$tip.label[sample(1:10,1)]<-"NA"
tr2$root.edge<-0
## paste the two trees together
tr3<-paste.tree(tr1,tr2)
## plot the results
layout(matrix(c(1,1,2,2,4,3,3,4),2,4,byrow=TRUE))
plotTree(tr1,direction="upwards",
mar=c(1.1,1.1,3.1,1.1))
add.arrow(tree=tr1,tip=which(tr1$tip.label=="NA"),
hedl=0.2,arrl=0.2,offset=1)
mtext("a) recipient tree",adj=0)
plotTree(tr2,direction="upwards",plot=FALSE)
pp<-get("last_plot.phylo",envir=.PlotPhyloEnv)
plotTree(tr2,direction="upwards",
mar=c(1.1,1.1,3.1,1.1),
ylim=c(-0.2,pp$y.lim[2]),add=TRUE)
arrows(pp$xx[11],pp$yy[11],pp$xx[11],-0.2,
length=0.1,lwd=2)
mtext("b) donor tree",adj=0)
plotTree(tr3,direction="upwards",
mar=c(1.1,1.1,3.1,1.1))
mtext("c) grafted tree",adj=0)
## reset par to default
par(mfrow=c(1,1),mar=c(5.1,4.1,4.1,2.1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.