Sunday, April 24, 2016

Update to cophylo to permit links in assoc for taxa not in the tree

I just added a small update (1, 2) to cophylo that permits links to be specified in assoc for taxa that are absent from the tree.

So, for instance:

library(phytools)
t1
## 
## Phylogenetic tree with 20 tips and 19 internal nodes.
## 
## Tip labels:
##  A, B, C, D, F, G, ...
## 
## Rooted; includes branch lengths.
t2
## 
## Phylogenetic tree with 23 tips and 22 internal nodes.
## 
## Tip labels:
##  t16, t3, t15, t2, t13, t6, ...
## 
## Rooted; includes branch lengths.
assoc
##       LETTERS      
##  [1,] "A"     "t17"
##  [2,] "B"     "t7" 
##  [3,] "C"     "t6" 
##  [4,] "D"     "t26"
##  [5,] "E"     "t21"
##  [6,] "F"     "t9" 
##  [7,] "G"     "t20"
##  [8,] "H"     "t23"
##  [9,] "I"     "t8" 
## [10,] "J"     "t18"
## [11,] "K"     "t12"
## [12,] "L"     "t10"
## [13,] "M"     "t11"
## [14,] "N"     "t1" 
## [15,] "O"     "t5" 
## [16,] "P"     "t4" 
## [17,] "Q"     "t19"
## [18,] "R"     "t24"
## [19,] "S"     "t22"
## [20,] "T"     "t13"
## [21,] "U"     "t2" 
## [22,] "V"     "t16"
## [23,] "W"     "t15"
## [24,] "X"     "t3" 
## [25,] "Y"     "t14"
## [26,] "Z"     "t25"

Both assoc[,1] has species not present in t1, and assoc[,2] has species not present in t2:

setdiff(assoc[,1],t1$tip.label)
## [1] "E" "I" "O" "R" "W" "Z"
setdiff(assoc[,2],t2$tip.label)
## [1] "t21" "t12" "t25"

Nonetheless (and this wouldn't have worked before):

obj<-cophylo(t1,t2,assoc)
## Rotating nodes to optimize matching...
## Done.
plot(obj)

plot of chunk unnamed-chunk-3

That's it.

The version of phytools with this update can be installed from GitHub as follows:

library(devtools)
install_github("liamrevell/phytools")

No comments:

Post a Comment