Notes from Vizbi: automation in Cytoscape

Cytoscape is a popular network visualisation and analysis tool. It’s great because it’s so easy to create plug-ins. Today I was fortunate enough to be attending the Cytoscape developer workshop at Vizbi 2012, where I learned a few new things.

Firstly, one of my goals was to find out about the current state of Cytoscape development. Cytoscape is a great tool as long as you don’t look too closely at what’s going on inside. The upcoming third version promises to fix all the minor and major problems that exist under the hood. But Cytoscape 3 has been in the making for a long time. As a plug-in developer, you have to choose between something that works right now, but will go away eventually, or something that is clearly the future, but might take a long time to materialise.

The feeling I got from the workshop is that there is light at the end of the Cytoscape 3 tunnel. For a plug-in developer with a deadline, it’s probably best to stick with the current version for now. But if you’re not under pressure to release, it’s definitely possible to write for Cytoscape 3 and make use of a nicer and more pleasant working environment.

Besides that news, I learned some cool new tricks. Using Cytoscape Commands you can write simple macros for repetitive tasks. For example, to generate the network below, first you have to import a SIF (Simple Interaction Format) file, then import a file with node attributes, then apply a layout, and then apply a visual style. If you have to do this a couple of times it gets quite tedious. But here is how all that can be automated:

Take the following SIF data, and save it using a text editor as network.sif

Martijn is_involved_with    LibSBGN
Chaouiya    is_involved_with    SBML-qual
Martijn is_involved_with    SBML-qual
Martijn is_involved_with    BioPreDyn
Emanuel is_involved_with    LibSBGN
Emanuel is_funded_by    Erasmus
Martijn is_funded_by    FP7

Here are the Node attributes, saved it as node_types.txt

type
LibSBGN=Project
BioPreDyn=Project
Chaouiya=Collaborator
SBML-qual=Project
Martijn=Member
Emanuel=Member
FP7=Funding
Erasmus=Funding

For the visual style, I created one in Cytoscape and saved it as style.props, using Export->Vizmap property file. And here is the magic bit: If you save the above three files in your work directory, then you can generate that picture with the script below.

network import file=network.sif
layout force-directed
node import attributes file=node_types.txt
vizmap import file=style.props

Run it from within Cytoscape with Plugins->Command Tool->Run script…, or from the command line with

./cytoscape.sh -S scriptfile

Tags: , , , ,

2 Responses to “Notes from Vizbi: automation in Cytoscape”

  1. Manuel says:

    Dear Martijn,

    Thanks a lot for your post.
    I have problems replicating your example.
    I’m using everything as posted by you, except the line
    ‘vizmap import file=net.props’
    which I deleted from the script.

    I’m using:
    Cytoscape_v2.6.3
    Ubuntu 11.04

    This is the content of my cytoscape.sh file:
    java -Dswing.aatext=true -Xss5M -Xmx512M -jar cytoscape.jar cytoscape.CyMain -p plugins “$@”

    Here is the output:

    $./cytoscape.sh -S cyto_script
    cytoscape.CytoscapeInit[INFO]: CytoscapeInit static initialization
    cytoscape.CytoscapeInit[INFO]: Log information can now be found in the Help->Error Console menu
    cytoscape[INFO]: starting delete action
    cytoscape[INFO]: ending delete action
    cytoscape[INFO]: PreferenceAction()…
    cytoscape.actions.BookmarkAction[INFO]: BookmarkAction()…
    BatchTool initializing
    BatchTool: args = cytoscape.CyMain -p plugins -S cyto_script
    Opening file cyto_script
    Processing script file cyto_script
    Parsing exception: Unknown command: network

    (and at this point Cytoscape GUI remains open but no network is loaded)

    I would appreciate your help on this regard.

    One more thing, supposing I get the script to work, is it possible to use another command line in the script for saving the network generated in graphic format (PDF, PNG, etc) ?

    Best regards,

    Manuel

  2. Hey Manuel,

    I think I forgot to mention that you need the command plug-in installed. You can find it here: http://apps.cytoscape.org/apps/commandtool (also through the Plugin Manager in Cytoscape).

    Give it a try. This plugin will also add a command console, accessible through the plugins menu, where you can experiment with commands. For example, try opening the command console and typing “help network”.


    Martijn