an example of drawing beast tree using ggtree

421 篇文章 15 订阅
(This article was first published on  YGC » R, and kindly contributed to R-bloggers)     

FigTree is designed for viewing beast output as demonstrated by their example data:

BEAST output is well supported by ggtree and it's easy to reproduce such a tree view. ggtree supports parsing beast output by read.beast function. We can visualize the tree directly by using ggtree function. Since this is a time scale tree, we can set the parameter time_scale = TRUE and ggtree will parse the time and use it as branch length.

? View Code RSPLUS
1
2
3
4
5
6
7
8
9
10
11
12
require(ggplot2)
require(ggtree)
x <- read.beast("/Applications/FigTree/influenza.tree")
cols <- scale_color(x, by="height")
ggtree(x, right=TRUE, time_scale=TRUE, color=cols) + theme_tree2() +
    geom_text(aes(x=max(x), label=label), size=1, color=cols, hjust=-.3) +
        scale_x_continuous(breaks=c(1992, 1995, 1997, 2000, 2002, 2005), minor_breaks=seq(1992, 2005, 1)) +
            geom_segment(aes(xend=max(x)+.20, yend=y), linetype="dotted", size=.1, color=cols) +
                theme(panel.grid.major   = element_line(color="black", size=.2),
                      panel.grid.minor   = element_line(color="grey", size=.2),
                      panel.grid.major.y = element_blank(),
                      panel.grid.minor.y = element_blank())

Related Posts
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值