fmarotta / recPhylo

Parse recPhyloXML and phyloXML files in R.
Other
1 stars 0 forks source link

Add ability to use geom_segment() and compatible geoms #5

Open fmarotta opened 3 months ago

fmarotta commented 3 months ago

Currently the "edge data.frames" are built to work with the geom_line() geom. However, using geom_segment() might give more flexibility. In particular it would open the way to use geom_link(), geom_bezier() and so on from ggforce. See e.g. this:

ggplot(data.frame(id = 1, x = c(1, 2), xend = c(2, NA), y = c(1, 2), yend = c(2, NA))) + geom_step(aes(x, y, group = id), direction = "vh")
fmarotta commented 2 months ago

For phylogeny objects this is essentially done. We now support two broad classes of edges, "links" and "combs". They are both based on geom_segment, but they can also be used with geom_link or geom_diagonal; geom_line has been abandoned.

For recPhylo objects it's a bit more complex. The "comb" layout doesn't require big changes, but in order to have link-type edges we need to change the layout of the species and gene trees. In particular, the y-thickness should always be zero and the x position of the internal events must be interpolated on the line joining parent and child. At any rate, we should also add a callback or something to customize the way individual edges are drawn based on their type, especially bifurcationOut and transferBack. For example, transfers could be bezier curves while other edge types are links or combs. We just have to inject some config in the stat-like function that computes the edges.