download code
## Chunk 1
library("yeastExpData")
data("litG")
litG
## Chunk 2
library("RBGL")
cc = connectedComp(litG)
len = sapply(cc, length)
table(len)
ord = order(len, decreasing=TRUE)
g = subGraph(cc[[ord[4]]], litG)
## Chunk 3
library("Rgraphviz")
x = layoutGraph(g)
renderGraph(x)
## Chunk 4
graph.par(list(nodes=list(label="", fill="lightgray"),
               edges=list(lwd=3)))
## Chunk 5
renderGraph(x)
## Chunk 6
graph.par(list(nodes=list(label=NULL)))
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
## Chunk 11
nodeRenderInfo(x) = list(fill=c(YBR088C="red", 
                                YDR097="red")) 
## Chunk 12
edgeRenderInfo(x) = list(lty=c("YBR088C~YMR167W"="dotted", 
                               "YDR097C~YMR167W"="dotted")) 
  (solution chunk)
## Chunk 14
x = layoutGraph(x, attrs=list(node=list(shape="ellipse", 
    fixedsize=FALSE)))
renderGraph(x)
  (solution chunk)
## Chunk 16
data("integrinMediatedCellAdhesion")
IMCAGraph
IMCAGraph = layoutGraph(IMCAGraph)
renderGraph(IMCAGraph)
## Chunk 17
names(labels) = labels = nodes(IMCAGraph)
nc = nchar(labels)
table(nc)
long = labels[order(nc, decreasing=TRUE)][1:4]
long
## Chunk 18
labels[long] = c(paste("Phosphatidyl-\ninositol\n",
    "signaling\nsystem", sep=""), "cell\nproliferation", 
    "cell\nmaintenance", "cell\nmotility") 
## Chunk 19
nodeRenderInfo(IMCAGraph) = list(label=labels)
renderGraph(IMCAGraph)
## Chunk 20
attrs = list(node=list(fixedsize=FALSE), 
    graph=list(rankdir="LR"))
width = c(2.5, 1.5, 1.5, 1.5)
height = c(1.5, 1.5, 1.5, 1.5)
names(width) = names(height) = long
nodeAttrs = list(width=width, height=height)
IMCAGraph = layoutGraph(IMCAGraph, attrs=attrs, 
    nodeAttrs=nodeAttrs)
renderGraph(IMCAGraph)
## Chunk 21
shape <- rep("rectangle", length(labels))
names(shape) <- labels
shape[long[1]] <- "ellipse" 
shape[c(long[2:4], "F-actin")] <- "plaintext"
nodeRenderInfo(IMCAGraph) <- list(shape=shape)
IMCAGraph <- layoutGraph(IMCAGraph, attrs=attrs, 
                         nodeAttrs=nodeAttrs)
renderGraph(IMCAGraph)
  (solution chunk)
## Chunk 23
IMCAGraph = layoutGraph(IMCAGraph, attrs=attrs, 
    nodeAttrs=nodeAttrs, recipEdges="distinct")
renderGraph(IMCAGraph)
## Chunk 24
sg1 = subGraph(c("ITGA", "ITGB", "ILK", "CAV"), IMCAGraph)
sg2 = subGraph(c("cell maintenance", "cell motility", 
    "F-actin", "cell proliferation"), IMCAGraph)
sg3 = subGraph(c("ACTN", "VCL", "TLN", "PXN", "TNS", "VASP"), 
    IMCAGraph)
subGList = vector(mode="list", length=3)
subGList[[1]] = list(graph=sg1, attrs=c(rank="source"), 
    cluster=TRUE)
subGList[[2]] = list(graph=sg2, attrs=c(rank="sink"))
subGList[[3]] = list(graph=sg3)
IMCAGraph = layoutGraph(IMCAGraph, attrs=attrs, 
    nodeAttrs=nodeAttrs, subGList=subGList)
renderGraph(IMCAGraph)
  (solution chunk)
## Chunk 26
library("org.Hs.eg.db")
library("biocGraph")
g1   = "1736"
paps = org.Hs.egPMID[[g1]]
genes = mget(paps, org.Hs.egPMID2EG)
names(genes) = paps
len = sapply(genes, length)
table(len)
## Chunk 27
sel = len < 5 
genes = genes[sel] 
paps = paps[sel]
LLstring = function(i) paste("LL", i, sep=":")
PMstring = function(i) paste("PM", i, sep=":")
nd = c(LLstring(unique(unlist(genes))),
    PMstring(paps))
ed = lapply(nd, function(z) list(edges=integer(0)))
names(ed) = nd
## Chunk 28
for(i in 1:length(genes)) {
    p = PMstring(names(genes)[i])
    g = LLstring(genes[[i]])
    ed[[p]] = list(edges=match(g, nd))
}
bpg = new("graphNEL", nodes=nd, edgeL=ed, 
    edgemode="directed")
## Chunk 29
nt = match(substr(nodes(bpg), 1, 2), c("LL", "PM"))
fill = c("lightblue", "salmon")[nt]
shape = c("ellipse", "rect")[nt]
names(fill) = names(shape) = nodes(bpg)
attrs = list(node=list(fixedsize=TRUE, shape=shape))
nodeRenderInfo(bpg) = list(fill=fill)
graph.par(list(nodes=list(fontsize=10)))
## Chunk 30
## imgname = "graph.png"
## png(imgname, width=1024, height=768)
## bpg = layoutGraph(bpg, layoutType="neato", attrs=attrs)
## bpg = renderGraph(bpg)
## dev.off()
## Chunk 31
## library(geneplotter)
## fhtml = "index.html"
## con = openHtmlPage(fhtml, paste("PubMed co-citations of",
##     "gene '1736' Please click on the nodes"))
## Chunk 32
pnodes = nodes(bpg)[nt==2]
links = character(length(pnodes))
tooltips = pnodes
links =  paste("http://www.ncbi.nih.gov/entrez/query.fcgi",
    "?tool=bioconductor&cmd=Retrieve&db=PubMed&",
    "list_uids=", gsub("PM:", "", pnodes), sep="")
names(links) = names(tooltips) = pnodes
tags = list(HREF=links, TITLE=tooltips)
## Chunk 33
imageMap(bpg, con=con, tags=tags, imgname=imgname)
closeHtmlPage(con)
## Chunk 34
## fhtml
## browseURL(fhtml)