2

I'm trying to represent a bidirectional graph structure using graphviz. Say I have 3 nodes A, B, C, corresponding to DNA fragments. I want to represent some structure inside each node, but also the relationship among the nodes, which let's say is A+ -> B- -> C+. That is, the positive strand in A is followed by the negative strand in B, then by the positive strand in C. The best I could come up with is:

digraph G {
  subgraph cluster_A {
    Aa0 -> Ab0
    Ab1 -> Aa1
    {rank=same; Aa0 Aa1}
    {rank=same; Ab0 Ab1}
  }
  subgraph cluster_B {
    Ba0 -> Bb0
    Bb1 -> Ba1
    {rank=same; Ba0 Ba1}
    {rank=same; Bb0 Bb1}
  }
  subgraph cluster_C {
    Ca0 -> Cb0
    Cb1 -> Ca1
    {rank=same; Ca0 Ca1}
    {rank=same; Cb0 Cb1}
  }
  Ab0 -> Bb1
  Bb0 -> Ab1
  Ba1 -> Ca0
  Ca1 -> Ba0
}

Here, the a/b labels correspond to the 5'/3' ends, and 0/1 labels correspond to positive/negative strands. What I get is: enter image description here

My main question is: Is it possible to tell dot to freely rotate individual subgraphs, while keeping their inner structure intact? In this example, I would've liked B to be rotated upside down. If it's not possible, are there any hacks that could accomplish this? Like introducing hidden nodes, placing weights on nodes/edges? I'm not that familiar with graphviz/dot, and I don't know exactly what it can do.

To clarify, there is more structure that I want to represent inside each cluster (other than its 5' and 3' ends), and that structure should be consistent within the cluster. But I don't know the best orientation of each cluster a priori, and I want to let dot compute that.

Matei David
  • 2,322
  • 3
  • 23
  • 36

1 Answers1

0

Small change in order of appearance

digraph G {
  subgraph cluster_A {
    Aa0 -> Ab0
    Ab1 -> Aa1
    {rank=same; Aa0 Aa1}
    {rank=same; Ab0 Ab1}
  }
  subgraph cluster_B {
    Bb1 -> Ba1
    Ba0 -> Bb0
    {rank=same; Ba0 Ba1}
    {rank=same; Bb0 Bb1}
  }
  subgraph cluster_C {
    Ca0 -> Cb0
    Cb1 -> Ca1
    {rank=same; Ca0 Ca1}
    {rank=same; Cb0 Cb1}
  }
  Ab0 -> Bb1
  Bb0 -> Ab1
  Ba1 -> Ca0
  Ca1 -> Ba0
}
stefan
  • 3,681
  • 15
  • 25
  • 3
    Sorry if I'm not being clear. I'm not interested in this particular graph. I'm trying to visualize the output of an assembler program, which produces, say, 100 such clusters. I'm trying to avoid having to compute myself their relative orientation, and I'm hoping to get `dot` to do that for me. – Matei David Oct 21 '15 at 14:49
  • For the dot layout engine there is no rotation of clusters after the definition of the cluster. however if you somehow know the rotation before, you may define the clusters in correct orientation. if you cannot do the orientation beforehand you may try the neato layout engine instead of dot. finally you could do some processing on the dot file with the programming language of your choice. there is even a built in script language gvpr. – stefan Oct 23 '15 at 11:54