Save and Restore Layout

Cytoscape provides many layout algorithms. They can be run through the Cytoscape menus, and by calling RCytoscape methods.

But even if a supplied algorithm is well-matched to your needs, an effective display may need some fine-tuning, some manual repositioning of nodes. And when no Cytoscape algorithm is a good fit to your needs, you can get the job done by some combination of writing R code (creating a one-off layout, or perhaps inventing a new general-purpose layout) along with manual node placements. Those techniques are not covered here. Rather, this recipe shows what to do to save and reuse a layout once you have one you want.

  library (RCytoscape)
  cw = new.CytoscapeWindow ('save layout demo', makeSimpleGraph ())
  displayGraph (cw)
  layoutNetwork (cw)
  redraw (cw)
Now you will see a 3-node, 3-edge graph in a Cytoscape window. Adjust these positions manually, as you might if you were working on a large network, and wanted the layout to be just right, perhaps a knowledge-based layout in which the knowledge is your own.

  saveLayout (cw, 'someLayoutFileName')
At a later date, you can restore this layout precisely:

  restoreLayout (cw, 'someLayoutFileName')
See saveLayout and restoreLayout documentation.