ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

how to use ggtree to draw fan-shaped tree with geological time scale

Open CretaceousBird opened this issue 3 years ago • 4 comments
trafficstars

Hi Dr. Yu, First, thank your for the ggtree package. I was wondering if you could help with this issue: can ggtree could produce a fan-shaped phylogeny with time scale as shown here. The circular lines denote the geological time. I found your previous reply about similar issue (https://github.com/YuLab-SMU/ggtree/issues/415), and the code is: ggtree(x) + theme(panel.grid.major=element_line()) + layout_circular() However, the circular line is equally spaced, rather than corresponding to geological time scale. Thank you in advance. Min

example

CretaceousBird avatar Jul 01 '22 07:07 CretaceousBird

I also want to ask this

ChenXi1201 avatar Jul 01 '22 14:07 ChenXi1201

try:

set.seed(1)
tree <- rtree(100)
ggtree(tree) + theme(panel.grid.major=element_line(), 
                   panel.grid.major.y=element_blank()) + 
  layout_circular() + scale_x_continuous(breaks=c(1,4,6))

We can use scale_x_continuous to specify the break points.

GuangchuangYu avatar Jul 06 '22 06:07 GuangchuangYu

I would note that with @GuangchuangYu's solution, the breaks need to specified in terms of the amount of time since the root of the tree. This is because with the circular layout the root is put at the origin (polar coordinate x = 0).

brj1 avatar Jul 06 '22 15:07 brj1

您的来信已收到,我会尽快查看,谢谢陈曦

ChenXi1201 avatar Oct 11 '22 07:10 ChenXi1201