Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding inset on circular tree #132

Open
Allerdnec opened this issue Jun 9, 2017 · 2 comments
Open

Adding inset on circular tree #132

Allerdnec opened this issue Jun 9, 2017 · 2 comments

Comments

@Allerdnec
Copy link

Allerdnec commented Jun 9, 2017

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) `

@GuangchuangYu
Copy link
Member

unfortunately, inset is only work for Cartesian coordinates.

@AEgit
Copy link

AEgit commented Oct 4, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants