2.1 Main callback methods
The first step is to build the server port, which will be required in all remote procedure calls. By default the constructor RedPort
should set all details:
library(RedeR)
## ***This is RedeR 1.28.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, invoke RedeR using the method calld
:
calld(rdp)
Within an active interface, then the method addGraph
can easily send R graphs to the application. For example, the following chunk adds an igraph object (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 addGraph
function.
Conversely, RedeR graphs can be transferred to R and wrapped in 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 getGraph
and addGraph
specification for additional details).
Another strategy is to wrap graphs into containers and then send it to the Java application. Next, the subgraphs g3
and 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 addGraph
.
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!).