2.1 Main callback methods
The first step is to build the server port, which will be required for all graph calls. By default the constructor
RedPort should set all details:
## ***This is RedeR 1.42.0! For a quick start, please type 'vignette('RedeR')'. ## Supporting information is available at Genome Biology 13:R29, 2012, ## (doi:10.1186/gb-2012-13-4-r29).
rdp <- RedPort()
Next, launch the RedeR interface using the
Then the method
addGraph can be used to send R graphs to the application. For example, the following chunk sends an igraph object to RedeR (Fig. 2):
library (igraph) g1 <- graph.lattice(c(5,5,5)) addGraph( rdp, g1, layout.kamada.kawai(g1) )
Figure 2. A toy example added to RedeR by the
Conversely, RedeR graphs can be transferred to R and wrapped into igraph objects:
g2 <- getGraph(rdp) resetd(rdp)
The interface accepts additional graph attributes, as for example edge direction, edge width, edge weight, node shape, node size, node color, etc. In order to pass these extensible features the attributes must be provided in a valid syntax (see
addGraph specification for additional details).
Another strategy is to wrap graphs into containers and then send it to the Java application. Next, the subgraphs
g4 are assigned to different nested structures (Fig. 3).
g3 <- barabasi.game(10) g4 <- barabasi.game(10) V(g3)$name<-paste("sn",1:10,sep="") V(g4)$name<-paste("sm",1:10,sep="") addGraph(rdp, g3, isNest =TRUE, gcoord=c(25,25), gscale=50) addGraph(rdp, g4, isNest =TRUE, gcoord=c(75,75), gscale=50)
Figure 3. Nested graphs in RedeR using the command
In this case, the subgraphs can be handled apart from each other. For example, the following chunk selects all nodes assigned to the container “N0” and then gets back the subgraph (the selection step can also be done interactively).
selectNodes(rdp,"N0") g5 <- getGraph(rdp, status= "selected") resetd(rdp)
As a suggestion, try some RedeR features in the Java side (e.g. open samples s2 or s3 in the main panel and enjoy the dynamic layout options!).