Brief Cytoscape Tutorial on Visualizing Graphs

Before using Cytoscape, download it from and install it.

Consider the graph given by the example edge list:

1 2
1 3
2 4
4 1
3 4
3 5
5 4
4 6
6 7
7 6
6 8
8 9
9 10
10 8
11 9
16 11
16 15
15 12
12 16
11 12
11 13
15 14
14 13
13 12
13 14

Save it in a text file named fig1.txt (make sure there are no empty lines after the last line).

Viewing a Graph

Open Cytoscape. In the File menu, find File→Import→Network from Table. You will be presented with a window similar to the following:

Import the file using “Select File”.

After the import, take a look at the dropdown boxes that are selected for “Column 1” and “Column 2”. This is important as it tells Cytoscape which column contains what kind of data. After importing the graph, you should see

The graph is drawn with default values which is not attractive and has some problems. Tthe layout simply fits on a grid and the graph looks somewhat disorganized. Also, the edges shown have no directions.

To show the directions of the edges (as present in the input), find the “VizMapper” tab in the left window pane. Click on the image of the two nodes with an edge between them. You should get a window similar to the following:

Find the edge tab on the right pane and then choose an appropriate arrow for EDGE_TGTARROW_SHAPE by clicking it and selecting one. Click apply to apply the new style. Going back to the main graph, we now see the directions on the edges.

There exist a number of ways to generate better layouts. As an example, in the layout menu select Layout→yFiles→Circular. If you have done this correctly, you should see:

Notice that Cytoscape lets you can interact with the layout by clicking and dragging nodes around. Depending on the structure and size of a graph, different layouts may yield more useful results.

It is also possible to save the result as an image. To do so, see File→Export→Network view as Graphics. Here you will be given the option to choose among a number of image formats.

Adding node attributes

in the project it is important to note which nodes belong to which clusters. Conveniently, the MCL algorithm gives identical results to the Scc calculation for our example graph (however in general this is not the case). Node attributes can be dumped to a file by using the write_node_attributes function from

To import this file into Cytoscape, use File→Import→Node attributes. After this, in the VizMapper tab find the “Node Color” item and expand it by clicking the +. On the right, choose clusterId. For Mapping Type choose Discrete Mapper. Next, right click on Node Color and select Generate Discrete Values→Rainbow 1 (or one of the other schemes). If you've done this correctly you should see something like:

Notice that in this part of the project we are working with an undirected graph, so if you are following along after the previous section you will need to go back and disable the arrows.

cs190c/cytoscape_tutorial.txt · Last modified: 2008/03/26 03:40 by jvalko
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki