Node and Edge Attributes
Attributes and File Format
Cytoscape allows the user to add arbitrary node
and edge information to Cytoscape as node and edge attributes.
Attributes could be, for example, annotation data on a gene or
confidence values in a protein-protein interaction. These attributes
can then be visualized in a user-defined way by setting up a
mapping from data attributes to visual attributes (colors, shapes,
etc.) (see section 9. Visual Styles).
Node and edge attribute files are simply
formatted: A node attribute file begins with the name of the
attribute on the first line, and on each following line, has the name
of the node, followed by an equals sign, followed by the value of
that attribute. Numbers and text strings are the most common
attribute types. All values for a given attribute must have the same
type. For example:
FunctionalCategory
YAL001C
= metabolism
YAR002W
= apoptosis
YBL007C
= ribosome
An edge attribute file has much the
same structure, except that the name of the edge is the source node
name, followed by the interaction type in parentheses, followed by
the target node name. Directionality counts, so switching the source
and target will refer to a different (or perhaps non-existent) edge.
The following is an example edge attributes file:
InteractionStrength
YAL001C
(pp) YBR043W = 0.82
YMR022W
(pd) YDL112C = 0.441
YDL112C
(pd) YMR022W = 0.9013
Cytoscape treats edge attributes as
directional, so note that the second and third edge attribute values
refer to two different edges (source and target are reversed, though
the nodes involved are the same).
Each attribute is stored in a
separate file. Node and edge attribute files use the same format.
Node attribute file names often use the suffix ".noa",
while edge attribute file names use the suffix ".eda".
Cytoscape recognizes these suffixes when browsing for attribute
files.
Node and edge attributes may be
loaded at the command line using the –n and –j options or via the
File / Load menu.
When expression data is loaded using
an expression matrix file (See 6. Loading Gene Expression Data),
it is automatically copied into the Node Attributes data structure
unless explicitly specified not to.
Detailed file format (Advanced
users)
Every attribute file has one header
line that gives the name of the attribute, and optionally some
additional meta-information about that attribute. The format is as
follows:
attributeName
class=formal.class.of.value category=attributeCategory
The
first field is always the attribute name: it cannot contain spaces.
The file may optionally include either of the class and category
fields.
The
category, if present, is saved and can be used by Cytoscape tools and
plugins to group or filter the set of available attributes.
If
present, the class field defines the formal (package qualified) name
of the class of the attribute values. For example, java.lang.String
for Strings, java.lang.Double
for floating point values, java.lang.Integer
for integer values, etc. If the value is actually a list of values,
the class should be the type of the objects in the list. The value
class must implement the Serializable interface (see the object
serialization section of the Java tutorial), allowing the data to be
saved in an efficient binary form (this binary attribute format is
not directly supported by Cytoscape). If the class is not a basic
String or Number class, it should have a String representation and a
constructor that takes a String argument, allowing Cytoscape to
construct an instance from the String representation in the file.
If
no class is specified in the header line, Cytoscape will attempt to
guess the type from the first value. If the first value contains
numbers in a floating point format, Cytoscape will assume
java.lang.Double;
if the first value contains only numbers with no decimal point,
Cytoscape will assume java.lang.Integer;
otherwise Cytoscape will assume java.lang.String.
Note that the first value can lead Cytoscape astray: for example,
floatingPointAttribute
firstName
= 1
secondName
= 2.5
In
this case, the first value will make Cytoscape think the values
should be integers, when in fact they should be floating point
numbers. It's safest to explicitly specify the value type to prevent
confusion.
Every
line past the first line identifies the name of an object and the
String representation of the attribute value. The delimiter is always
an equals sign; whitespace (spaces and/or tabs) before and after the
equals sign is ignored. This means that your names and values can
contain whitespace, but object names cannot contain an equals sign
and no guarantees are made concerning leading or trailing whitespace.
Usually the object names should be the same as the names in your
graph file, unless name conversion is being used (see the section on
name resolution in section 5. Building and Storing Interaction
Networks).
Edge names are all of the form
sourceName
(edgeType) targetName
Note
that this format is different from the specification of interactions
in the SIF file format. To be explicit: in a SIF file, an interaction
looks like
sourceName
edgeType targetName
To
set an attribute for the edge defined by this interaction, the
matching line in a attributes file should look like
sourceName
(edgeType) targetName = value
(Yes,
this is confusing; we're planning on fixing this in the next file
format update for Cytoscape).
To
specify lists of values, use the following syntax:
listAttributeName
class=java.lang.String
firstObjectName
= (firstValue::secondValue::thirdValue)
secondObjectName
= (onlyOneValue)
This
defines an attribute which is a list of Strings. The first object has
three strings, and thus three elements in its list, while the second
object has a list with only one member. In the case of a list every
attribute value should be specified as a list, and every member of
the list should be of the same class. Again, the class will be
inferred if it is not specified in the header line. Lists are not
supported by the visual mapper, so can’t be mapped to visual
attributes.
Attribute Browser
When Cytoscape is started, the Attribute Browser appears in the bottom Cytopanel.
This browser can be hidden and restored using the F5 key.
Like other Cytopanels, the browser can be undocked by pressing the little icon
in the browser’s top right corner.

To swap between displaying node attributes and edge attributes use the bottom tabs “Node Attribute Browser” and “Edge Attribute Browser”.
The attribute browser displays attributes belonging to selected nodes and/or edges. To populate the browser with rows (as pictured above), simply select nodes and/or edges in a loaded network. By default, only the “ID” of nodes and edges is shown. To display more than just the ID, click the “Select Attributes” button and choose the attributes that are to be displayed. Each selection of an attribute will result in one column in the attribute browser (in the screenshot above there are 5 columns total including the ID).
Most attribute values can be edited by double-clicking an attribute cell; list values cannot be edited, and neither can the ID.
Attribute rows in the browser can be sorted alphabetically by specific attribute by clicking on a column heading.
A new attribute can be created using the “Create New Attribute” button. Attributes created using the attribute browser must be one of four types – integer, string, floating point, or boolean.
The right-click menu on the Attribute Browser has several functions. This menu is useful for exporting attribute information to spreadsheet applications. For example, choose “Select All” and then “Copy” from the right-click and then paste into a spreadsheet application.