R / Bioconductor has 'annotation' packages that map between common identifiers and other useful entities, e.g., the KEGG.db package to manage KEGG ids and pathway names, and the org.Hs.eg.db package to manage H. sapiens annotations, including Entrez, KEGG, SYMBOL, GENENAME, etc. There is also a graph package to create and manipulate graphs, and various alternatives for visualization such as the Rgraphviz and RCytoscape packages. Here's a work flow that retrieves the MAPK and Wnt pathways, finds human Entrez gene ids associated with these pathways, translates the Entrez gene ids to gene symbols, then plots the result using Rgraphviz.
library(KEGG.db)
library(org.Hs.eg.db)
library(graph)
library(Rgraphviz) # Rgraphviz can be tricky to install, esp. on Windows
## KEGG pathways of interest
terms <- c("MAPK signaling pathway", "Wnt signaling pathway")
## map -- KEGG id links the KEGG and org.Hs.eg packages
name2id <- toTable(KEGGPATHNAME2ID[ terms ])
id2gene <- toTable(revmap(org.Hs.egPATH)[ name2id$path_id ])
id2gene$symbol <- # add gene SYMBOL for each Entrez id
unlist(mget(id2gene$gene_id, org.Hs.egSYMBOL))
path2gene <- merge(name2id, id2gene, by="path_id") # 'join'
## create a graphBAM instance
df <- with(path2gene,
data.frame(from=symbol, to=path_id, weight=1,
stringsAsFactors=FALSE))
gr <- graphBAM(df, edgemode="directed")
## create a (random) subgraph
set.seed(123L)
nodes <- c(sample(df$from, 25), unique(df$to))
subgr <- subGraph(nodes, gr)
## display
to <- unique(df$to) # 'to' nodes, ...
nodeAttrs <- # ...colored organge
list(fillcolor=structure(rep("orange", length(to)), names=to))
plot(subgr, # display; uses Rgraphviz
"fdp", # a graphviz layout
nodeAttrs=nodeAttrs, # node attributes
attrs=list( # default attributes
node=list(shape="ellipse", # nodes are ellipses...
width="2"), # ... wide enough to contain symbol ids
edge=list(arrowsize="0.75") # edges are not-too-large arrows
))
Maybe not for the faint of heart, but hopefully showing the possibilities. There are instructions for installing R and Bioconductor packages, and many additional packages, some of which (e.g., KEGGgraph) provide a different interface; RCytoscape is interesting because the graph can be assembled programmatically, and then manipulated in Cytoscape.
Hi blenderous, then you finally could get the proteins and interactions from KEGG database? I'd like to know if you have done this, it's really interesting