marbl / MetagenomeScope

Visualization tool for (meta)genome assembly graphs
https://marbl.github.io/MetagenomeScope/
GNU General Public License v3.0
24 stars 8 forks source link

Circularized semilinear layout #209

Open fedarko opened 3 years ago

fedarko commented 3 years ago

One of the slight downsides of using a semilinear layout is that some types of assembly graph components (e.g. almost-finished circular bacterial chromosomes) could be best represented as a circle, depending on whom you ask. See, for example, Figure 4a in the metaFlye paper:

image

Representing this chromosome linearly would work, but it necessitates the presence of at least one long "back edge" in the graph visualization.

Given a DOT layout that is oriented from left --> right (using standard Cartesian coordinates), representing a graph that is mostly linear but still has an overall circular structure, we should be able to convert the positions of nodes within this layout to be kinda like a circle.

We can do this by mapping nodes' Cartesian coordinates to polar coordinates (not converting: we'd be scaling the coordinates to fit on a "circle"), and then converting these polar coordinates back to Cartesian.

  1. Map nodes' x-coordinates to theta values, and nodes' y-coordinates to r values (there will be some weird details that come up, but the broad idea here is pretty straightforward). This will yield a circular representation of a linear graph.

    • There are a few parameters here -- e.g. we could adjust where on the circle (i.e. in the range [0, 2pi]) we "start" the graph, we'd probably need to mess around with radius scaling in the case of really "tall" parts of the graph, etc.
  2. Convert these (r, theta) values from polar to Cartesian coordinates (using x = rcos(theta), y = rsin(theta)). The graph can then be drawn as normal.

Sticking points: