Tutorial:Cytoscape Developers Tutorial

From OpenTutorials
Jump to: navigation, search


Slideshow Cytoscape_Developers_Tutorial (about 20 minutes)
Handout Cytoscape_Developers_Tutorial.pdf (5 pages)

Tutorial Sources
Tutorial Curators Anna Kuchinsky


Graphs and Data

The Root Graph is one graph to rule them all. All nodes and edges are part of the root graph. A network is a subset (projection of the root graph, and a network view is a visualization of a network. The Vizmapper maps attributes and values for a visual presentation.

Attributes

Attributes are typed values that can be associated with CyNetworks, CyNodes, and CyEdges. Attributes are not really "attributes," but data values that might be associated with networks, nodes, and edges. You can read in attributes for nodes/edges you haven't created yet. Attributes are associated to nodes/edges by identifier (name).

Attributes are typed, and accessed by type, attribute name, and object identifier (name). There is support for Integers, Doubles, Booleans, Strings, Lists, and Maps (dictionaries).

Root Graph Implications

Two nodes with the same identifier in different networks are the same node. They will have the same attributes. VizMap overrides (which are implemented as attributes) will effect all presentations of the node. Groups exist across networks.

Layers

Graphs, Views, and Data (Attributes):

  • Views depend on Graphs
  • Data doesn't depend on anything

Graph:

  • CyNetwork->GraphPerspective (giny)->FGraphPerspective (fing)
  • CyNode->Node (giny)->FNode (fing)
  • CyEdge->Edge (giny)->FEdge (fing)

View:

  • CyNetworkView->GraphView (giny)->DGraphView (ding)
  • CyNodeView->NodeView (giny)->DNodeView (ding)
  • CyEdgeView->EdgeView (giny)->DEdgeView (ding)

Data:

  • CyAttributes

Navigating the Cytoscape API

Start with the Cytoscape class. The Singleton class is the starting point for most Cytoscape functionality. Other useful singletons include...

  • CyGroupManager: group-related information
  • CyLayouts: information about currently loaded layout algorithms

But it's not all in Cytoscape. Cytoscape has four different groups of functionality:

  • Cytoscape: the core application
  • Corelibs: Corelibs are parts of Cytoscape that are called by core routines, but never call any core routines. Much of the graph implementation is here
  • Coreplugins: a significant piece of the Cytoscape functionality is "hidden" in the plugins that are delivered with Cytoscape. As with any plugin, these are not directly available through the API. These include...
    • Layouts
    • Data browser
    • Editor
    • Table import, SBML reader, and PSI-MI readers
    • Filters
  • CsPlugins: User-developed plugins add significant functionality. Many of those are available as source.

Visual Styles

Cytoscape allows the user to create their own visual style. This visual style includes creating node, edge, and global appearance calculators. Users can construct a calculator for each VisualProperty, and create a PassThrough, Discrete, or Continuous mapper that maps an attribute to a VisualProperty. Users can also create the style with all three AppearanceCalculators.

Tunables

Tunables serve three purposes: the persistence of values, automatic UI generation, and external access to plugin parameters. The tunables are typed, and the objects take 7 arguments:

  1. name: the name of the tunable
  2. description: the description of the tunable
  3. type: the tunable type
  4. value: the initial value of the tunable
  5. lowerBound: the lower bound of the tunable
  6. upperBound: the upper bound of the tunable
  7. flag: flags to provide hints to the UI generators

Types

  1. Integer
  2. Double
  3. Boolean
  4. String
  5. NodeAttribute
  6. EdgeAttribute
  7. List
  8. Group
  9. Button

Bounds and Flags

Bounds provide upper/lower bounds of numeric quantities, the list for a List, and an initial list for attributes to allow alternative choices.

Flags provide hints for the UI.

  • MULTISELECT to allow multiple selection in a list
  • USESLIDER to use a slider for numeric values (must also have bounds)
  • IMMUTABLE to display the value but not allow editing
  • COLLAPSABLE to implement collapsible groups
  • NOINPUT for internal parameters that aren't presented to the user
  • NUMERICATTRIBUTE to restrict attribute presentation to numeric values

Interaction

BUTTON tunable:

  • lower bound is an ActionListener
  • Called when the button is pressed

A TunableValueListener:

  • can be added to any Tunable
  • caller will be notified when a tunable value changes

Layout

There are two functions for the Layout Properties:

  1. Collect all Tunables into a list
  2. Generate a single JPanel with all of the Tunable interfaces. LayoutProperties handles GROUPing

Layouts should all inherit from AbstractLayout. Cytoscape's layout menu takes care of tasks. Use LayoutTask if you want to call a layout yourself on a separate thread.

AbstractLayout fields

  • Set<NodeView> staticNodes: the set of nodes that should not be moved
  • CyNetworkView networkView: the view this layout should operate on
  • CyNetwork network: the network this layout should operate on
  • boolean selectedOnly: true if only selected (unlocked) nodes should be laid out
  • String edgeAttribute: the edge attribute to use for the layout
  • String nodeAttribute: the node attribute to use for the layout
  • boolean canceled: true if the user requested that the layout be aborted
  • TaskMonitor taskMonitor: the TaskMonitor used for the layout

Layout Callbacks

  • String getName():
    • returns the short name for this layout
    • name used to get this layout from CyLayouts
  • String toString():
    • the readable name for this layout
    • used for menus
  • boolean supportsSelectedOnly():
    • true if this layout will support only operating on a subset of the nodes
  • byte supportsNodeAttributes():
    • an array of supported attribute type for the layout (or null)
  • byte supportsEdgeAttributes():
    • an array of supported attribute type for the layout (or null)
  • List<String>getInitialAttributeList():
    • a list of values to add to the list of attributes
    • allows for an "unweighted" value or any special list values to be added to the menu presented to the user