ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Adding inset on circular tree

Open Allerdnec opened this issue 8 years ago • 2 comments
trafficstars

Hi Guangchuang Yu,

First I really like ggtree and could already do a lot of cool graphs with it ! So thanks for developing the package !

Second, I have tried to find a solution to my problem through all the ggtree issues (github) and in the google group but did not find anybody that had the same issue. So if I missed something, I apologize in advance.

I have a very large/complicated dataset and I would like to combine a circular tree with bar charts like in the link below but with an offset. http://blog.phytools.org/2014/05/plotting-bars-at-tips-of-circular-tree.html Obviously you can achieve that result with phytools but as I would like to also implement several heatmap rings in between the tree and the bar charts I would like to do it with ggtree.

I have tried to do it with the inset function but then I got the following error.

'Error: annotation_custom only works with Cartesian coordinates'

Would it be possible to implement inset for circular trees ? The other issue is that I would also need to flip the bar charts.

Thank you so much in advance, Allerdnec

Here is the code I've tried based on your examples

`tr <- rtree(15) p <- ggtree(tr, layout="circular", branch.length="none")

a <- runif(15, 0, 0.33) b <- runif(15, 0, 0.33) c <- runif(15, 0, 0.33) d <- 1 - a - b - c dat <- data.frame(a=a, b=b, c=c, d=d) test <- subset(p$data, p$data$isTip == TRUE)

input data should have a column of node that store the node number dat$node <- test$node

cols parameter indicate which columns store stats (a, b, c and d in this example) bars <- nodebar(dat, cols=1:4)

inset(p, bars, width=.03, height=.06) `

Allerdnec avatar Jun 09 '17 09:06 Allerdnec

unfortunately, inset is only work for Cartesian coordinates.

GuangchuangYu avatar Jun 18 '17 17:06 GuangchuangYu

I would like to see an implementation of this approach as well (if possible).

AEgit avatar Oct 04 '19 10:10 AEgit