Rotate network by code

62 views
Skip to first unread message

Emanuel

unread,
May 28, 2012, 5:54:51 AM5/28/12
to cytoscap...@googlegroups.com

Hi all,

I’m using the Cytoscape Hierarchical Layout, because the yFiles hierarchical layout is not accessible by code. Though, the networks with Cytoscape hierarchical layout appear vertically inverted (the top nodes appear on the bottom and vice versa) and this makes the understanding of the network a lot harder.  

I notice that I can rotate de network 180 degrees using the rotate function, but I can’t figure out how I can do it by code.

So does anyone know how I can rotate a network 180 degrees by code?

Any help with this?

Many thanks.

Cheers,

Alexander Pico

unread,
May 31, 2012, 12:55:08 PM5/31/12
to cytoscap...@googlegroups.com
Hi Emanuel,

Rather than rotate, you could mirror the network and get a similar effect that might work for your purposes. MIrroring would simply involve taking the negative of the y-values. You could also look into the rotation function in the open source code base for cytoscape:


 - Alex

Matthias König

unread,
May 31, 2012, 2:33:54 PM5/31/12
to cytoscap...@googlegroups.com
Apply a rotation matrix to all your coordinate tuples (x,y) with the rotation matrix being
R = [r11 r12; r21 r22]; with r11 = cos w; r12 = -sin w; r21= - sin w; r12  = sin w; r22 = cos w
and rotation angle w around the origin.
Is mainly linear Algebra in 2D, if you need a translation in addition apply translation matrix also.

Write a function for 
xnew = cos w *x -sin w*y
ynew = sin w *x + cos w*y
and apply to all x,y coordinates of the nodes in the network

Matthias

Emanuel

unread,
Jun 1, 2012, 6:32:28 AM6/1/12
to cytoscap...@googlegroups.com
Hi,

Many thanks for your replies.

I'll try them asap.

Cheers,

Emanuel

unread,
Jun 1, 2012, 8:11:29 AM6/1/12
to cytoscap...@googlegroups.com
Hi,

So I checked both solutions and I decided to apply the easiest one (Alexander's solution) for my connivence :)

It worked very well. The only thing I should mention is when you have anchor points in the edges it's also required to mirror these ones.

Thank you very much for your replies.

Cheers,
Reply all
Reply to author
Forward
0 new messages