Wednesday, September 16, 2015

Print method for fastAnc

I just added a print method for the ancestral state estimation function, fastAnc. Here is a quick demo of how it works:

library(devtools)
install_github("liamrevell/phytools",quiet=TRUE)
library(phytools)
## Loading required package: ape
## Loading required package: maps

Simulate a tree & data:

x<-fastBM(tree<-rtree(n=12))
tree
## 
## Phylogenetic tree with 12 tips and 11 internal nodes.
## 
## Tip labels:
##  t5, t6, t8, t7, t3, t4, ...
## 
## Rooted; includes branch lengths.
x
##          t5          t6          t8          t7          t3          t4 
##  0.08020791  0.90090545 -0.52120123 -0.70089226  0.60523627  0.32977174 
##         t10          t2         t12         t11          t1          t9 
## -1.35329157 -0.41231935 -0.12192103  0.56163234 -1.40509098 -1.52915450
obj<-fastAnc(tree,x)
obj
## Ancestral character estimates using fastAnc:
##        13        14        15        16        17        18        19 
## -0.613584 -0.333720  0.311369 -0.667771 -0.805572 -0.640828  0.133491 
##        20        21        22        23 
## -0.665823 -1.137190 -0.402258  0.504335
obj<-fastAnc(tree,x,CI=TRUE)
obj
## Ancestral character estimates using fastAnc:
##        13        14        15        16        17        18        19 
## -0.613584 -0.333720  0.311369 -0.667771 -0.805572 -0.640828  0.133491 
##        20        21        22        23 
## -0.665823 -1.137190 -0.402258  0.504335 
## 
## Lower & upper 95% CIs:
##        lower     upper
## 13 -1.872864  0.645696
## 14 -1.649728  0.982288
## 15 -0.648504  1.271242
## 16 -1.773040  0.437499
## 17 -1.911716  0.300572
## 18 -1.048660 -0.232996
## 19 -0.697674  0.964656
## 20 -1.724715  0.393068
## 21 -1.890327 -0.384054
## 22 -1.274650  0.470134
## 23  0.242778  0.765892
print(obj,printlen=6)
## Ancestral character estimates using fastAnc:
##         13       14       15        16        17        18     
##  -0.613584 -0.33372 0.311369 -0.667771 -0.805572 -0.640828 ....
## 
## Lower & upper 95% CIs:
##        lower     upper
## 13 -1.872864  0.645696
## 14 -1.649728  0.982288
## 15 -0.648504  1.271242
## 16  -1.77304  0.437499
## 17 -1.911716  0.300572
## 18  -1.04866 -0.232996
##         ....      ....

That's it.

No comments:

Post a Comment

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