ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

What is a transformation that is being done for layout="circle"?

Open yuliaUU opened this issue 4 years ago • 1 comments

I am trying to add an additional layer to tree

tree=rtree(10)
ggtree(tree, layout="circular")

I need my additional layer to contain 10 points aligned horizontally ( ina straight line)

v <- data.frame( z = 3, j= c(3.2, 3.2+1, 3.2+2, 3.2+3))
ggtree(tree, layout="circular")+geom_point(data=v, aes(x=z, y=j), color="green")

I can't seem to figure out what transformation been done to get my points to display in a linear fashion.

image

yuliaUU avatar Apr 24 '20 08:04 yuliaUU

I guess you want this.

library(ggtree)
library(ggtreeExtra)
library(ggplot2)
set.seed(1024)
tree <- rtree(10)
#p <- ggtree(tree, layout="circular")
tree$tip.label
v <- data.frame(z = c(rep("t5",4), rep("t8",4), rep("t6", 4)), j= c(rep(c(3.2, 3.2+1, 3.2+2, 3.2+3),3)))
v
p <- ggtree(tree)+
        geom_tiplab()+                                                                                                                                                              
        geom_fruit(data=v,
                           geom=geom_point,
                           mapping=aes(y=z, x=j),
                           pwidth=0.4,
                           color="green")

test_point1 or

p <- ggtree(tree, layout="fan", open.angle=195)+
    geom_tiplab()+
    geom_fruit(data=v,
               geom=geom_point,
               mapping=aes(y=z, x=j),
               pwidth=0.4,
               color="green")

test_point2 geom_fruit is a function from ggtreeExtra

xiangpin avatar Jun 15 '20 09:06 xiangpin