Skip to content

dendrogram with branch lengths determined by edge attribute? #124

Description

@cboettig

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions