ggtree
ggtree copied to clipboard
Adding inset on circular tree
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) `
unfortunately, inset is only work for Cartesian coordinates.
I would like to see an implementation of this approach as well (if possible).