Tutorial:Introduction to Cytoscape 3.1-part2
Cytoscape is an open source software tool for integrating, visualizing, and analyzing data in the context of networks. This tutorial covers network loading, importing data, visualizing data using Styles, network layout and App manager.
- 1 Loading a Simple Network
- 2 Manipulating Your Network
- 3 Visualizing Data on Networks
- 3.1 Importing and Exploring Your Data
- 3.2 Visualizing Data with Styles
- 3.3 Laying Out Your Network
- 4 App Manager
Loading a Simple Network
- Go to File → Import → Network → File...
- You should see a file chooser dialog.
- In the Cytoscape 3 directory, open the sampleData folder and select galFiltered.sif and then click on Open.
The first time you import a network, it will automatically create a new network collection. If you import an additional network during the same session, you should see the following dialog:
In the dialog, you can select to create a new network collection or add the new network to an existing network collection in the drop-down. You can also select which column should be used for mapping between networks.
Manipulating Your Network
Now that you have a network loaded, you can interact with it in a number of ways:
- Start by clicking on the node at the upper left corner of the network. The node with turn yellow. If you hold your mouse down over the node and drag it around the node will move on the screen.
- Now add another node to the selection by holding down the Shift key and clicking on another node. Note that both nodes are now selected (yellow). Again, move the nodes around. Node that both nodes will move.
- To select a group of nodes, hold the mouse down in the upper left-hand corner and drag your mouse over a region of the network. Again, a group of nodes will be selected and can be moved around on the screen.
- To zoom in on the selected nodes, click on the icon.
- To move the window around the network, you can either use the middle mouse button, or drag the small window outlined in blue around in the Network Overview Pane in the bottom section of the Network tab in the Control Panel.
- Finally, zoom your network out by clicking on the icon.
While useful, hand selecting nodes in dense networks can be error-prone and difficult. However, you can specifically search for a node by name or data value:
- In the Search input field on the toolbar, type in ynr050c. This will select that node.
The search interface will also allow you to select nodes by other columns, but first, we need to import more data columns...
Visualizing Data on Networks
Cytoscape provides a number of features to load arbitrary data and visualize that data by mapping the column values to styles. Note that this tutorial focuses on importing data from a file to a network that is already loaded in Cytoscape, in this case the galFiltered network. The data mapping requires that an attribute in the existing network match a column in the data file to be imported.
Importing and Exploring Your Data
Cytoscape can read file structures that are delimited Text or Excel files.
- Go to File → Import → Table → File...
- You will see a file chooser dialog. Select the galExpData.csv from the sampleData folder and then click on Open.
You should see the following dialog:
Note that the Key Column for Network represents the attribute in the already loaded network (in this case galFiltered) that will be used for mapping. In the data file, this matches the column shown in blue in the preview. The data column to use can be changed under Show Mapping Options.
- In the Select a Network Collection section, choose the network to import the data columns to, and the column used as key to map to.
- Next, under Import Data As, select Node Table Columns.
- Click OK to import.
NOTE: If the data preview shows data from all columns as one field, you need to change which delimiter is used:
- Click the Advanced Options... button
- In the Delimiter field, deselect Tab and instead select Comma.
- Select Use first line as column names
Viewing Data Columns
Now explore the Table Panel to confirm the mapping of the data to the network.
- Locate the Show Column button in the Table Panel.
- Select the following data columns: gal1RGexp, gal4RGexp, and gal80Rexp.
- Return to the Table Panel by clicking away from the column list
- Select some nodes in the network (ctrl-A selects all nodes) and see the associated data in the Table Panel
You now have access to your networked data and can begin playing with visualization.
- Go to Layout → Prefuse Force Directed Layout.
- Go to the Style tab in the Control Panel and select Sample1 in the Current Style drop-down.
Style lists a set of default styles. In the next section you will customize a style to highlight your data values. Details on editing and creating Styles here.
Editing Data Columns
So far, we have selected a couple of columns to display in the Table Panel. Next, we will explore columns and the Table Panel in more depth.
- Type mcm1 in the search box. This will select the node:YMR043W, and display the columns for that node in the Table Panel.
- We're going add a new column for MCM1. Click on the Create New Column icon and select New Single Column → String.
- Type in pdb for the name of the column -- this will define a new string column type for nodes, and add it to the Table Panel.
- Now click into the empty cell for newly-created pdb column for YMR043W and type 1mnm, which is the PDB ID for the yeast protein mcm1. You need to hit Return or Tab to enter the data.
- Move the pdb column to be the second column position by dragging the column header to be behind the name column.
- Finally, select a number of nodes and note that the columns for all of the nodes are shown in the Table Panel.
- By clicking on the column header, you can sort the columns. Clicking again changes the order of the sort.
Visualizing Data with Styles
- Go to File → Open.... If you already have a network loaded you will get a message warning you that any current session will be lost, click ‘Yes’ to continue.
- You should see the Session file to load dialog.
- Open the sampleData folder and select galFiltered.cys and then click on Open.
Modifying the Style
Customizing the way you visualize and manipulate networks is a key function of Cytoscape. This is achieved through the use of Styles:
The Style interface exists as a tab in the Control Panel and is divided into 3 tabs, for Node, Edge and Network properties. For each property, there are 3 columns describing the current Default (meaning the default value for the current mapping), Mapping and any Bypass. A pre-defined set of properties is displayed by default. Additional properties for display can be selected by clicking the Properties drop-down at the top of the list of properties. The Styles interface also lists any pre-defined styles in the drop-down at the top of the interface. The below figures shows the default style for the galFiltered session file.
- Try changing the style for one of the properties, for example Label Color for nodes. Click on the default column for Label Color in the Node tab, and select green in the color chart.
- Notice that the Node Label Color changes in the network. You can also try changing other properties, like setting the Edge Line Type to dashed.
Creating a Style
- In the Current Style section, start a new style by clicking the Options... button and selecting Create new Style.
- Enter a name for your custom style and click OK.
- Find Fill Color under the Node tab and click the right-side arrow to expand.
- For Column, click on -- select value -- and select the value ‘gal1RGexp’ to map expression fold values. For Mapping Type select ‘Continuous Mapping’. Click on the gradient to open the gradient editor:
- Click on Min/Max button and set to -1 and 1, respectively.
- Double-click on gradient handles to set colors, e.g.
- below -1.0 = green
- -0.8 = green
- 0.8 = red
- above 1.0 = red
- Click Add to add another gradient handle. Drag to center at 0.0. Leave as white color.
- Close the gradient dialog.
- Next, we want to edit the properties for Node Size.
- Under the Node tab, expand Size and select ‘gal1RGsig’ to map p-values. For Mapping Type select ‘Continuous Mapping’. Click on gradient to open dialog:
- Note: We want smaller p-values (more significant) to show as larger nodes
- Click Min/Max and set the values accordingly: 1.0E-8 and 1.0E-3.
- Double-click on solid red box for p-values below the minimum (far left) to set the maximum node size. Set to 70.0.
- Double-click on solid red box for p-values below the maximum (far right) to set the minimum node size. Set to 20.0.
- Set the left open box to Node Size 70.0 and the right open box to 20.0. This defines the range of the gradient.
- Click Add to add a new gradient handle. Set it to data value = 1E-4 and Node Size = 40.0.
- Click OK in the gradient dialog and explore the visualization you have created!
This creates a pseudo-exponential gradient mapping:
- Zoom by selecting an area and clicking
- Use the bird’s-eye-view panel (bottom-left) to pan around network
- Try switching the Style by switching mappings to another column of data:
- For Node Color select ‘gal4RG’.
- For Node Size select ‘gal4RGsig’.
Notice the change in the view of the network! You can reuse the mappings across multiple data sets. Now is a good time to save your Cytoscape session, to save the style you’ve created.
Laying Out Your Network
A network layout is a process that positions the nodes and edges for the network. There are a large variety of layouts in Cytoscape and plugins might add new layouts. All of the layouts will appear under the Layouts menu. In this section, we will explore some of the layouts which are the core layouts supported by the Cytoscape team. Most layouts support the ability to only layout a portion of the network, and most expose parameters that can be used to tune the layout algorithm.
The simplest layout that Cytoscape provides is the Grid Layout, which simply places all of the nodes in a grid arrangement.
- Using the network you loaded before, select Layout → Grid Layout. You should see the image below:
- Now, select Edit → Undo: Grid Layout and notice how your network reverts to the previous condition. Many (but not all) of Cytoscape's actions may be undone.
- Select a group of nodes in your network and again select Layout → Grid Layout. Notice that this now has a sub-menu with two options: All Nodes and Selected Nodes Only.
- Choose Selected Nodes Only. Note that only the nodes you selected are changed.
Grid is very fast, but it's of limited usefulness. Alternatives:
- Circular Layout places all of the nodes in a circular arrangement.
- Very quick
- Partitions the network into disconnected parts and independently lays out those parts.
- Hierarchical Layout forces the nodes into a tree structure.
- Works best when the network is naturally tree-structured
- Also works reasonably well when the network is mostly hierarchical.
Data-Driven Simple Layouts
Often what is desired is to organize the nodes in space to reflect some data property of the nodes themselves. We'll look at three of the simple ones:
- Degree Sorted Circle: Orders the node around a circle based on node degree (number of edges)
- Attribute Circle Layout: Orders the node around a circle based on the value of a selected column
- Group Attributes Layout: Groups the nodes based on the value of a selected column
Degree Sorted Circle Layout
For example, assume you are interested in hubs (nodes with high degree):
- Select Layout → Degree Sorted Circle Layout.
- Note the highest degree nodes are in the same region of the circle and the degree decreases as you proceed counter-clockwise around the circle.
- Also note that this layout supports partitioning of the network into disconnected components.
- This layout algorithm adds the column degree to every node, which is very useful for coloring nodes.
Attribute Circle Layout
- Now try Layout → Attribute Circle Layout → Degree.
- This should give you a very similar layout to the Degree sorted circle layout.
- You should also try using other columns to layout.
Group Attributes Layout
- Finally, select Layout → Group Attributes Layout → Degree.
- Note that this layout organizes all of the nodes with the same degree into a circle and then positions the circles into a grid.
- Partitions the graph before layouts.
- These layouts are useful to represent data columns associated with the nodes of a network, however, they don't provide much information about the network structure itself. For that, using more complicated layouts are required.
The force-directed methods for laying out graphs all use some kind of physical simulation that models the nodes as physical objects and the edges as springs connecting those objects together.
- Cytoscape provides 3 force-directed layouts:
- Edge-weighted Force directed (BioLayout)
- Edge-weighted Spring Embedded
- Prefuse Force Directed
- In this exercise, we'll use the Prefuse Force-Directed Layout (see prefuse.org).
- We'll do all of our work from the Layout settings dialog, so bring up the dialog by Layout → Settings...
- In the Layout Settings dialog:
- Select Prefuse Force Directed Layout under Layout Algorithm.
- Lets start by creating a layout using the default parameters.
- Select Execute Layout.
- Note how this exposes more of the structure of the network than any of the previous layouts.
- Now, let's see what the parameters do.
- Start by changing the Default Spring Length to 20, and select Execute Layout. The default spring length is the length of a spring (edge) with no forces exerted upon it. Essentially, it's the length of an edge connecting two nodes with no other connections.
- Note how the layout has changed. The resulting network tends to be more closely packed in the denser regions.
- Finally, lets change Default Spring Length back to 50 and the Default Spring Coefficient to 1E-3. The spring coefficient is a measure of the strength of the spring.
- Now click Execute Layout. Note that the network remains pretty compact, even though we've reset the default spring length back to 50.
Prefuse Force Directed Layout is also a good layout to use for circumstances when you want to have the length of your edges reflect some numeric weight on each edge.
- Select the column containing your edge weights from the drop-down menu Weight using.
- This often requires some tuning of the spring coefficient and the spring length to get an aesthetically pleasing layout.
The App Manager allows users to quickly and conveniently add extra features to Cytoscape directly from within Cytoscape, eliminating the need for manual searches through different websites to install and update apps.
If you do not have Internet access enabled, you will not see the list of available apps or be able to automatically update existing ones; however, you will still be able to view and delete previously installed apps.
- Go to Apps → App Manager. The App Manager has three tabs: Install Apps, Currently Installed and Check for Updates.
- Currently Installed folder lists any apps already installed. To find out more about a specific app, click on its name to display some basic information on the bottom of the window.
- Install Appa tab displays an interface for interacting with the Cytoscape App Store.
- To install jActiveModules: Search for "jactive". Select jActiveModules from the middle column.
- Click on the Install button at the bottom of the window.
- Click on close to exit the App Manager.
- Go to the Apps menu and jActiveModules should appear in the list of apps.