Site icon R-bloggers

ggtree supports phylip tree format

[This article was first published on R on G. Yu, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Phylip is also a widely used tree format, which contains taxa sequences with Newick tree text.

In ggtree, we can use read.phylip() function to parse the file and use ggtree() to visualize the tree.

library(ggtree)
phyfile <- system.file("extdata", "sample.phy", package="ggtree")
phylip <- read.phylip(phyfile)
phylip

## 'phylip' S4 object that stored information of
##   '/Users/guangchuangyu/Library/R/3.2/library/ggtree/extdata/sample.phy'.
## 
## ...@ tree: 
## Phylogenetic tree with 15 tips and 13 internal nodes.
## 
## Tip labels:
##  K, N, D, L, J, G, ...
## 
## Unrooted; no branch lengths.
## 
## with sequence alignment available (15 sequences of length 2148)

ggtree(phylip) + geom_tiplab()

User can view the sequence alignment with the tree via msaplot() function.

msaplot(phylip, offset=1)

To leave a comment for the author, please follow the link and comment on their blog: R on G. Yu.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.