How to create two different network views according to the imported sif file?

5 views
Skip to first unread message

javacookie

unread,
Jan 3, 2010, 12:41:39 AM1/3/10
to cytoscape-discuss
Happy new year,everyone. I am new to Cytoscape.Recently, I am
developing a plugin for Cytoscape.However, a trouble stops me!
The trouble is:
A sif file is imported into the Cytoscape.Actually, the content in the
sif file includes two different network data.The content is like this:
CAA p2 CNN
CAA p2 CQQ
CAA p2 CZZ
CBB p2 CDD
CBB p2 CHH
CBB p2 CJJ
CBB p2 CQQ
CCC p2 CMM
CCC p2 CNN
CCC p2 CZZ
CDD p2 COO
CDD p2 CWW
YA p1 YB
YA p1 YC
YA p1 YD
YB p1 YD
YB p1 YG
YB p1 YI
YC p1 YF
YC p1 YG
YD p1 YE
YD p1 YF
YE p1 YI
YG p1 YH
YI p1 YJ
YI p1 YK
YI p1 YL

"CXX" and "YX" represent the nodes while "p2" and "p1" are the edge
label.
As shown above, the data of network1 is:
CAA p2 CNN
CAA p2 CQQ
CAA p2 CZZ
CBB p2 CDD
CBB p2 CHH
CBB p2 CJJ
CBB p2 CQQ
CCC p2 CMM
CCC p2 CNN
CCC p2 CZZ
CDD p2 COO
CDD p2 CWW

the data of network2 is:
YA p1 YB
YA p1 YC
YA p1 YD
YB p1 YD
YB p1 YG
YB p1 YI
YC p1 YF
YC p1 YG
YD p1 YE
YD p1 YF
YE p1 YI
YG p1 YH
YI p1 YJ
YI p1 YK
YI p1 YL

Now my task is that when I click one button of my plugin,Cytoscape
shows the network1' view and network2' view in Cytoscape.

I have tried my best to achieve this functionality,but the result is
failed.
The key point of the trouble is that how to select the corresponding
nodes according to the edge
label?
Could anyone show me the example codes of how to select the
corresponding nodes according to the edge label? Many thanks.

Russ

unread,
Jan 14, 2010, 12:14:54 PM1/14/10
to cytoscape-discuss

> Now my task is that when I click one button of my plugin,Cytoscape
> shows the  network1' view and network2' view in Cytoscape.
>
> I have tried my best to achieve this functionality,but the result is
> failed.
> The key point of the trouble is that how to select the corresponding
> nodes according to the edge
> label?
> Could anyone show me the example codes of how to select the
> corresponding nodes according to the edge label? Many thanks.

R: I'm not quite sure what the problem is here. By 'when I click one
button of my plugin,Cytoscape
shows the network1' view and network2' view in Cytoscape', do you
mean you want to view two networks at the same time within Cytoscape
because this can be done using View->Arrange Network Windows->Tiled.

Or, is the problem that you start with a single network containing all
your nodes and edges and you want to split this network into two
separate networks based on the edge label?

Regards
Russ

Russ

unread,
Jan 15, 2010, 9:04:55 AM1/15/10
to cytoscape-discuss
Please reply to the message board instead of my work email.

It goes something like
CyNetwork inputNet = Cytoscape.getCurrentNetwork(); //the network you
importted from .sif
CyNetwork outputNet1 = Cytoscape.createNetwork(String title1);
CyAttributes edgeAtt = Cytoscape.getEdgeAttributes();

Iterator edgeIt = inputNet.edgesIterator();
while(edgeIt.hasNext()){
CyEdge edge = edgeIt.next();
if(edgeAtt.getStringAttribute(edge.getIdentifier() ,
"interaction" ).equals("p1")){outputNet1.addEdge(edge); /** not sure
if you have to have already added the relevant nodes to outputNet1 */
}
}

Similarly for your 'p2' attribvalue
To do this non-programmatically is really easy using the cytoscape
edge filters
R

javacookie

unread,
Jan 16, 2010, 11:20:01 AM1/16/10
to cytoscape-discuss
It's so kind of Russ.With your enthusiastic help,the problem is
solved.
Thanks again for your kindness.

javacookie

Reply all
Reply to author
Forward
0 new messages