robertness
7/28/2015 - 12:08 AM

Downloading and visualizing p53 pathway, and finding all of p53's causal neighbors

Downloading and visualizing p53 pathway, and finding all of p53's causal neighbors

library(KEGGgraph)
library(dplyr)
library(magrittr)
library(graph)
# install.packages("devtools")
devtools::install_github("robertness/lucy")
library(lucy)
map <- "04115"
g_nell <- tempfile() %T>%
  {retrieveKGML(map, organism="hsa", destfile=., method="curl", quiet=TRUE)} %>%
  parseKGML2Graph(expandGenes=FALSE) 
vertex_list <- getKEGGnodeData(g_nell) %>%
  {data.frame(
    kegg = unlist(lapply(., function(item) item@name[1])),
    label = unlist(lapply(., function(item)
    strsplit(item@graphics@name, ",")[[1]][1])),
    stringsAsFactors = F)}
g_init <- igraph.from.graphNEL(g_nell) 
V(g_init)$name <- vertex_list$kegg 
vertex_list <- filter(vertex_list, !duplicated(kegg))
edge_list <- getKEGGedgeData(g_nell) %>%
  lapply(function(item){
    if(length(item@subtype) > 0) return(item@subtype$subtype@name)
    NA
  }) %>%
  unlist %>%
  {cbind(get.edgelist(g_init), type = .)} %>%
  data.frame
g <- graph.data.frame(edge_list, vertices = vertex_list)
igraphviz(g)
markov_blanket <- imb(g, V(g)["hsa:7157"])
(pairs <- cbind(V(g)["hsa:7157"]$label, V(g)[markov_blanket]$label))