This section provides a sequence of steps that illustrates how users might integrate its own pre-processed data in a given network to visualize subgraphs and nested networks. Please refer to Castro et al. (2012) for more details about the biological background and experimental design of each example.
Subgraphs
Start the app (i.e. run the ‘calld’ method), and then get the indicated data frame and interactome:
data(ER.limma)
data(hs.inter)
dt <- ER.limma
gi <- hs.inter
Extract and set attributes to a subgraph represented by genes differentially expressed at a given time point (i.e. logFC from t3-t0 contrast):
gt3 <- subg(g=gi, dat=dt[dt$degenes.t3!=0,], refcol=1)
## ...note: not all genes found in the network!
gt3 <- att.setv(g=gt3, from="Symbol", to="nodeAlias")
gt3 <- att.setv(g=gt3, from="logFC.t3", to="nodeColor", breaks=seq(-2,2,0.4), pal=2)
Note that some genes will not be found in the interactome, and that’s okay. Extract another subgraph and set its attributes (i.e. logFC from t6-t0 contrast):
gt6 <- subg(g=gi, dat=dt[dt$degenes.t6!=0,], refcol=1)
## ...note: not all genes found in the network!
gt6 <- att.setv(g=gt6, from="Symbol", to="nodeAlias")
gt6 <- att.setv(g=gt6, from="logFC.t6", to="nodeColor", breaks=seq(-2,2,0.4), pal=2)
Extract another subgraph and set its attributes (i.e. logFC from t12-t0 contrast):
gt12 <- subg(g=gi, dat=dt[dt$degenes.t12!=0,], refcol=1)
## ...note: not all genes found in the network!
gt12 <- att.setv(g=gt12, from="Symbol", to="nodeAlias")
gt12 <- att.setv(g=gt12, from="logFC.t12", to="nodeColor", breaks=seq(-2,2,0.4), pal=2)
Now add all subgraphs to the app (Fig.7):
addGraph(rdp, gt3, gcoord=c(10,25), gscale=20, isNest=TRUE, theme='tm1', zoom=30)
addGraph(rdp, gt6, gcoord=c(20,70), gscale=50, isNest=TRUE, theme='tm1', zoom=30)
addGraph(rdp, gt12, gcoord=c(70,55), gscale=80, isNest=TRUE, theme='tm1', zoom=30)
… and nest overlapping subgraphs (i.e. indicating overlapping time series!):
nestNodes(rdp, nodes=V(gt3)$name, parent="N1", theme='tm2')
nestNodes(rdp, nodes=V(gt6)$name, parent="N2", theme='tm2')
nestNodes(rdp, nodes=V(gt3)$name, parent="N4", theme='tm3')
To simplify the graph, the mergeOutEdges
method assigns edges to containers:
mergeOutEdges(rdp)
Relax the network:
relax(rdp,50,400)
Add color legend (other types are available):
scl <- gt3$legNodeColor$scale
leg <- gt3$legNodeColor$legend
addLegend.color(rdp, colvec=scl, labvec=leg, title="node color (logFC)")
Select a gene:
selectNodes(rdp,"RET")
Reset graph:
resetd(rdp)
Figure 7. Nested subnetworks. This graph shows genes differentially expressed in estrogen-treated MCF-7 cells at 3, 6 and 12 h (relative to 0 h). The insets correspond to the overlap between consecutive time points (adapted from Castro et al. (2012))
Nested networks and clustering
Get the indiated data frame and igraph object:
data(ER.deg)
dt <- ER.deg$dat
sg <- ER.deg$ceg
Map the data frame to the graph:
sg <- att.mapv(sg, dat=dt, refcol=1)
Set attributes to the graph (i.e. gene symbols and two available numeric data):
sg <- att.setv(sg, from="Symbol", to="nodeAlias")
sg <- att.setv(sg, from="logFC.t3", to="nodeColor", breaks=seq(-1,1,0.2), pal=2)
sg <- att.setv(sg, from="ERbdist", to="nodeSize", nquant=10, isrev=TRUE, xlim=c(5,40,1))
Add graph to the app (Fig.8):
addGraph(rdp,sg)
Compute a hierarchical clustering using standard R functions:
hc <- hclust(dist(get.adjacency(sg, attr="weight")))
Map the hclust
object onto the network and return corresponding ids (pvclust
objects are also compatible):
nestID <- nesthc(rdp,hc, cutlevel=3, nmemb=5, cex=0.3, labels=V(sg)$nodeAlias)
…at this point nested objects from the network should appear mapped onto a dendrogram. Different levels of the nested structure can be set by the nesthc
method. Additionally, clustering stability can be assessed by the pvclust package, which is already compatible with the interface.
Assign edges to containers:
mergeOutEdges(rdp,nlev=2)
Relax the network:
relax(rdp)
Add color and size legends:
scl <- sg$legNodeColor$scale
leg <- sg$legNodeColor$legend
addLegend.color(rdp, colvec=scl, labvec=leg, title="diff. gene expression (logFC)")
scl <- sg$legNodeSize$scale
leg <- sg$legNodeSize$legend
addLegend.size(rdp, sizevec=scl, labvec=leg, title="bd site distance (kb)")
Reset graph:
resetd(rdp)
Figure 8. Hierarchical networks. This graph is obtained by superimposing a dendrogram onto the corresponding co-expression gene network (adapted from Castro et al. (2012)).