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

dendrogram with branch lengths determined by edge attribute? #124

Closed
cboettig opened this issue Apr 21, 2018 · 3 comments
Closed

dendrogram with branch lengths determined by edge attribute? #124

cboettig opened this issue Apr 21, 2018 · 3 comments

Comments

@cboettig
Copy link

this is probably a stupid question, but it isn't obvious to me how to plot a dendrogram in which branch lengths are determined by the data (i.e. a 'chronogram' in phylogenetics, where branch lengths represent evolutionary time). Consider this example:

In ape, an example phylogeny has branch length data, which is reflected in the plot:

library(ape)
data("bird.orders")
plot(bird.orders)

Using the awesome tidygraph, we coerce this:

library(tidygraph)
library(ggraph)
bird <- as_tbl_graph(bird.orders) 

looks like edge lengths are lost in this transformation? (guess that's a tidygraph issue>). Even if I just manually add a column of branch lengths (below just picking lengths at random), I'm not sure how to map the length column of the edge table to branch lengths to get a plot like the ape plot above... is this possible with the current layout? If not, is this something you would consider supporting?

bird %>% activate(edges) %>%
  mutate(length = abs(rnorm(44))) %>%
  ggraph(layout="dendrogram") + geom_edge_elbow()
@thomasp85
Copy link
Owner

Both are issues that I would like to support. Can I get you to open the relevant issue at tidygraph so phylo conversion can be fixed?

@thomasp85
Copy link
Owner

Oh - you already did. Thanks🙂

@cboettig
Copy link
Author

🎉

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

No branches or pull requests

2 participants