Wednesday, November 29, 2017

More user control in co-phylogenetic plotting with phytools

I just added a little more user control of the S3 plot method for the object class "cophylo" for co-phylogenetic plotting.

Firstly, I allow the user to access the internally-used argument part which can be adjusted to permit more space between the two plotted trees. For instance:

library(phytools)
t1
## 
## Phylogenetic tree with 26 tips and 25 internal nodes.
## 
## Tip labels:
##  R, Q, A, P, F, B, ...
## 
## Rooted; includes branch lengths.
t2
## 
## Phylogenetic tree with 20 tips and 19 internal nodes.
## 
## Tip labels:
##  t4, t6, t13, t16, t15, t14, ...
## 
## Rooted; includes branch lengths.
assoc
##    tree 1 tree 2
## 1       S    t14
## 2       V    t18
## 3       L    t19
## 4       X    t12
## 5       D    t20
## 6       E    t16
## 7       I    t15
## 8       Z    t11
## 9       N     t7
## 10      R     t2
## 11      F     t1
## 12      G     t4
## 13      B     t3
## 14      Y    t13
## 15      U     t8
## 16      Q     t9
## 17      F     t5
## 18      J    t10
## 19      N     t6
## 20      C    t17
obj<-cophylo(t1,t2,assoc=assoc)
## Rotating nodes to optimize matching...
## Done.
plot(obj) ## the default

plot of chunk unnamed-chunk-1

plot(obj,part=0.3)

plot of chunk unnamed-chunk-1

Secondly, I added control over the lines linking the tips of the tree to the tip labels. This is because sometimes when rendered as a PDF this lines can seem just too fine! So, for instance:

plot(obj,tip.lwd=2,link.type="curved",link.lwd=3,
    link.col=make.transparent("grey",0.4),
    part=0.35,lwd=2)

plot of chunk unnamed-chunk-2

## or
plot(obj,tip.lty="solid",link.lwd=3,link.lty="solid",
    link.col=make.transparent("blue",0.2),
    part=0.3,lwd=3,pts=F)

plot of chunk unnamed-chunk-2

Kind of neat. Of course, in this case the two trees have no genuine association - but nonetheless.

These updates can be obtained by installing phytools directly from GitHub using the package devtools.

No comments:

Post a Comment

Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.