ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Plotting circular and fan trees: root length and "vertical" branch layout

Open RaSieb opened this issue 9 years ago • 5 comments
trafficstars

I am using ggtree for circular / fan tree images and would like to create publishable images. I have two major issues:

  1. When a tree has short branch lenghts close to the root, the tree is hardly readable (especially when plotting tip labels). In FigTree, there is a parameter called "Root Length", which can be very usefull to increase readibility of the tree by moving all nodes and branches further out and closer together. Is there a way to do this in ggtree?
  2. The circular "branches" (vertical in square plot) are plotted as a number of straight segments instead of real circle fragments (see around node 84 in example tree below). This is disturbing for the reader. Is there a way to get around this?

I use a random tree for illustration: set.seed(6464); t <- rtree(60); r <- ggtree(t, layout="fan", open.angle=1); r + theme_tree() + geom_text2(aes(label=node, subset=!isTip), color="red"); tree_out_pdf.pdf

One solution to no. 1 would be to align the tip labels. However, this would not increase readibility of the tree itself.

Thanks a lot for your help in advance! R

RaSieb avatar Nov 16 '16 12:11 RaSieb

sorry to comment on my own post, but would like to let you know this: ape:::plot.phylo(t, root.edge=T) can do it using the t$root.edge component in the phylo class. But plot.phylo of cours has some restrictions, why I would like to use ggtree. Could it be an option to add that in ggtree?
with the example above: t$root.edge <- 8 ape:::plot.phylo(t, root.edge = T, "fan") results in: t

RaSieb avatar Nov 16 '16 13:11 RaSieb

I think you want to produce something like Figure 1 and 2 in https://www.ncbi.nlm.nih.gov/pubmed/27605062, which were generated by ggtree.

The answer was already posted in google forum.

GuangchuangYu avatar Nov 17 '16 02:11 GuangchuangYu

Thanks a lot, r2 = r + xlim(-5, NA) solves issue 1 perfectly.

Any idea about issue 2 ?

RaSieb avatar Nov 17 '16 10:11 RaSieb

issue 2 is not an issue, the segments are not straight. them seem to be straight since they are short.

GuangchuangYu avatar Nov 17 '16 10:11 GuangchuangYu

could the radius then be adjusted, so several segments join nicely into one bow?

RaSieb avatar Nov 17 '16 10:11 RaSieb