Control Cytoscape from R Console

Introduction

CytoscapeRPC is a plugin for Cytoscape to use Cytoscape as a RPC server. You can call Cytoscape functions from variety of languages including Perl, Python, Ruby, and R. In this tutorial, you learn how to use Cytoscape from R console.

Setup

You need to install the following plugins/packages.

Cytoscape Plugin

Just copy the following jar files to Cytoscape plugin directory.

R Packages

Tutorial

Start Cytoscape RPC

  1. Start Cytoscape. If you want to see the all messages (including Exceptions from CytoscapeRPC plugin), start Cytoscape from command line (by executing cytoscape.sh or cytoscape.bat)

  2. Select Plugins-->CytoscapeRPC-->Activate RPC

  3. Modify port number if necessary. Default port is 9000.

Start R

  1. Start R console
  2. Load required libraries
    • > library(igraph)
      > library(XMLRPC)
  3. Test RPC Plugin.
    • > testResponse = xml.rpc('http://localhost:9000', 'Cytoscape.test')
      > testResponse
      [1] "It works!"

Create Network with igraph and Visualize It in Cytoscape

  1. Create an empty network.
    • > networkID = xml.rpc('http://localhost:9000', 'Cytoscape.createNetwork', 'R-Cytoscape Test')
      > networkID
      [1] "2"
      > networkTitle = xml.rpc('http://localhost:9000', 'Cytoscape.getNetworkTitle', networkID)
      > networkTitle
      [1] "R-Cytoscape Test"
  2. Generate a scale-free graph according to the Barabasi-Albert model
    • > g1 <- barabasi.game(200)
      > g1
      Vertices: 200 
      Edges: 199 
      Directed: TRUE 
      Edges:
                      
      [0]     1 ->   0
      [1]     2 ->   0
      [2]     3 ->   1
      .
      .
      .
  3. Create Cytoscape network from the generated graph
    • > edgelist1 <- get.edgelist(g1)
      > edgelist1
             [,1] [,2]
        [1,]    1    0
        [2,]    2    0
        [3,]    3    1
      .
      .
      .
      > edgeIDs <- xml.rpc('http://localhost:9000', 'Cytoscape.createEdgesFromVector', edgelist1[,1], edgelist1[,2])
  4. In the Cytoscape window, you can see one red node. Actually, it's a graph with 200 nodes without any visual properties. After applying layout and vizmap, you can see something like this:
    • igraph1.png

(to be continued...)

CytoscapeAndR (last edited 2010-07-01 06:20:34 by KeiichiroOno)

Funding for Cytoscape is provided by a federal grant from the U.S. National Institute of General Medical Sciences (NIGMS) of the Na tional Institutes of Health (NIH) under award number GM070743-01. Corporate funding is provided through a contract from Unilever PLC.

MoinMoin Appliance - Powered by TurnKey Linux