Saturday, March 19, 2016

Update to evol.vcv to fit one-matrix model only

I just pushed an update to the phytools function evol.vcv for fitting multiple evolutionary covariance matrices of the Brownian process in different parts of a phylogeny. This update is really simple in that it also allows a single- matrix model to be fit if the tree does not contain a mapped character. It does this simply by first checking the object class, and if no mapped history is detected, defaults to the one-matrix method.

In addition, I also updated the S3 print method for objects of class "evol.vcv" so that it will correctly interact with the object in cases in which the multi-matrix model has not been fit.

Here's a demo:

library(phytools)
tree
## 
## Phylogenetic tree with 26 tips and 25 internal nodes.
## 
## Tip labels:
##  A, B, C, D, E, F, ...
## 
## Rooted; includes branch lengths.
X
##          [,1]        [,2]
## A -1.00695016 -2.06793511
## B -0.87033217 -2.10422394
## C  1.29819001  4.03403880
## D -0.05848995 -0.30219213
## E  0.45863441  0.34757660
## F  0.39518949  0.28150017
## G -0.99733970 -1.06831419
## H  1.65832398  2.09205018
## I  0.87054014  1.66383419
## J  0.19177496  0.42037481
## K -2.93950359 -4.28924289
## L -1.62166199 -2.47866641
## M  0.29796980 -1.10294629
## N -0.90080841 -1.64759349
## O -0.93375179 -1.71649635
## P -1.36587353 -2.43703534
## Q -1.16325826 -1.96215059
## R -0.48938600  1.01795287
## S -2.64530264 -2.51334888
## T -2.56304676 -2.35011154
## U  0.27324578  0.09549933
## V  0.65280452  0.24877137
## W  2.98139254  5.12524270
## X  1.99631404  3.80703412
## Y  2.87246726  4.60435552
## Z  1.63347964  3.13330346
fit<-evol.vcv(tree,X)
fit
## ML single-matrix model:
##  R[1,1]  R[1,2]  R[2,2]  k   log(L)
## fitted   0.9988  1.2926  2.1252  5   -50.3123    
## 
## R thinks it has found the ML solution.

The data for this demo were simulated as follows:

tree<-pbtree(n=26,tip.label=LETTERS)
vcv<-matrix(c(1,1.25,1.25,2),2,2)
X<-sim.corrs(tree,vcv)

No comments:

Post a Comment