Extracting subnetwork from main network

97 views
Skip to first unread message

srikanth bezawada

unread,
Jul 23, 2014, 10:12:28 AM7/23/14
to cytoscap...@googlegroups.com
Hello Cytoscape,

I would like to extract a subnetwork from my main network in my app. Basically I need to remove some nodes from the main network and present the remaining nodes as a seperate network in the control panel.

CyNetworkFactory networkFactory = CyActivator.networkFactory;
CyNetwork subNetwork = networkFactory.createNetwork();


Is there anyway to initialize the newly created network to main network ( so that i can use newnetwork.getnodeList(), newnetwork.getnodeTable(), edgeTable() etc. as well)? and then iterate through the newnodeList and remove the corresponding nodes from the new network.  



Thanks,
Srikanth.B,
Information Systems,
Bits-Pilani , Goa

Scooter Morris

unread,
Jul 23, 2014, 11:03:20 AM7/23/14
to cytoscap...@googlegroups.com
Hi Srikanth,
    I think what you want to do is a little different.  You probably need to look at org.cytoscape.model.subnetwork and do something like:

CyRootNetwork root = ((CySubNetwork)network).getRootNetwork();
List<CyNode> nodes = network.getNodeList();
List<CyEdge> edges = network.getEdgeList();
// Remove the nodes you want removed from the list
// Adjust your edges

CyNetwork newNetwork = root.addSubNetwork(nodes, edges);

-- scooter
--
You received this message because you are subscribed to the Google Groups "cytoscape-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-disc...@googlegroups.com.
To post to this group, send email to cytoscap...@googlegroups.com.
Visit this group at http://groups.google.com/group/cytoscape-discuss.
For more options, visit https://groups.google.com/d/optout.

srikanth bezawada

unread,
Jul 31, 2014, 5:29:53 PM7/31/14
to cytoscap...@googlegroups.com
Hello Scooter,

Thanks for letting me know on how to use subnetwork package. Seems like this approach is intuitive rather than using CyNetworkFactory. I have a doubt on the expected output. When we create a subnetwork using the above approach, a new network(subnetwork) would be created in the control panel, right ?



Thanks,
Srikanth.B,
Information Systems,
Bits-Pilani , Goa



Scooter Morris

unread,
Jul 31, 2014, 5:33:35 PM7/31/14
to cytoscap...@googlegroups.com
Hi Srikanth,
    I *think* so, but if it doesn't, just register the subnetwork with the CyNetworkManager.

-- scooter

Luiz Henrique Rauber Rodrigues

unread,
Aug 9, 2014, 8:29:56 AM8/9/14
to cytoscap...@googlegroups.com
err... I think do not understand perfectly you question, probably because I has noob :P, but... do try create a subnetwork from the click over the node, and in the cytoscape tools panel chose "first neighbors of selected nodes" and before in the left button in "new network from selection"

the neighbors you can change that in "undirected" and "direct: incoming" and "direct: incoming"in the menu select>nodes>first neighbors.

if I said bullshit, smile and ignore :P

srikanth bezawada

unread,
Sep 18, 2014, 6:05:09 PM9/18/14
to Scooter Morris, cytoscap...@googlegroups.com
Hello Scooter,

A new subnetwork is created in the same network collection in control panel when registered with network manager. Thanks again for letting me know on this approach.

Best,
Srikanth.B.

srikanth bezawada

unread,
Jun 2, 2015, 3:46:44 PM6/2/15
to cytoscap...@googlegroups.com, Scooter Morris
Hello Scooter,

When a new subnetwork is created in the control panel, all the nodes are getting overlapped at a single place(They disperse once I apply a layout). Any idea why this is happening ? Also, can you please let me know how to programmatically apply a layout like grid layout so as to disperse the nodes. 



 Inline image 1

Thanks,
Srikanth.B.

Scooter Morris

unread,
Jun 2, 2015, 5:10:58 PM6/2/15
to srikanth bezawada, cytoscap...@googlegroups.com
On 06/02/2015 12:46 PM, srikanth bezawada wrote:
Hello Scooter,

When a new subnetwork is created in the control panel, all the nodes are getting overlapped at a single place(They disperse once I apply a layout). Any idea why this is happening ? Also, can you please let me know how to programmatically apply a layout like grid layout so as to disperse the nodes. 



 Inline
          image 1

Thanks,
Srikanth.B.
That's expected.  Your new network doesn't have either a style nor a layout.  Look at http://wiki.cytoscape.org/Cytoscape_3/AppDeveloper/Cytoscape_3_App_Cookbook#Code_snippet_for_updating_the_network_view to see how to apply a layout algorithm.

-- scooter

srikanth bezawada

unread,
Jun 30, 2015, 4:58:14 PM6/30/15
to Scooter Morris, cytoscap...@googlegroups.com
Hi Scooter,
Please guide me regarding following issues.

1) I want to programmatically change the color (visual styles) of some nodes & some edges in my current network. I also want to do the same for some nodes & some edges in my subnetwork (which was extracted from the main network during runtime of my app and registered using CyNetworkManager). 

2) Also while using the app adapter, I'm getting the following error and hence the view is not getting updated programmatically.
 
Exception in thread "Thread-20" java.lang.NullPointerException at this line
final CyLayoutAlgorithmManager alMan = appAdapter.getCyLayoutAlgorithmManager();

This worked fine for cyspanningtree app, but in an another app it's giving NullPointerException as shown above(last line of stack trace).   

Thanks,
Srikanth.B.


srikanth bezawada

unread,
Jul 25, 2015, 6:32:30 PM7/25/15
to cytoscap...@googlegroups.com
Hello,

I had resolved the above issues while back and just to close this thread :)

1) I was able to figure out how to color the nodes(manipulate visual style programmatically) using 
networkView.getNodeView(currNode).setVisualProperty( ,) and it works like charm. 
Also, for newly created nodes I had used eventHelper.flushPayloadEvents();. Thanks to cookbook.


2) Code to initialize appAdapter from CyActivator was found missing and it worked fine after that.

Thanks,
Srikanth.
Reply all
Reply to author
Forward
0 new messages