# first, delete existing windows to save memory:
  deleteAllWindows(CytoscapeConnection())
  cw <- CytoscapeWindow ('setNodeSizeRule.test', graph=makeSimpleGraph())
  displayGraph (cw)
  layoutNetwork (cw, 'grid')
  control.points <- c (10, 30, 80)
  node.sizes  <- c (20, 50, 80)
  node.attribute.name <- 'count'   # previously defined, has values which range between 2 and 100
    # remind yourself of the values of count on each of the three nodes
  print (noa (getGraph (cw), 'count'))
    #  A   B   C 
    #  2  30 100
  setNodeSizeRule (cw, node.attribute.name, control.points, node.sizes, mode='interpolate')
    # a warning is issued; below and above sizes must be inferred
    # now make a new rule. Explicitly specify below and above sizes
  node.sizes  <- c(1, 20, 50, 80, 200)
    # anything below 20 will have size of 1; anything above 80 will be 200.
  setNodeSizeRule (cw, node.attribute.name, control.points, node.sizes, mode='interpolate')
    # a warning is issued; below and above sizes must be inferred
    # now use a mode='lookup' rule. Specify a size for two of the molecule types
    # look to see that the third type, glycoprotein, gets the tiny default.size of 5
  molecule.types <- c('kinase', 'transcription factor')
  node.sizes  <- c(60, 80)
  setNodeSizeRule (cw, 'type', molecule.types,  node.sizes, default.size= 5, mode='lookup')
Run the code above in your browser using DataLab