# 1) load GO Molelular Function as igraph object
load(url("http://dnet.r-forge.r-project.org/data/Obo/ig.GOMF.RData"))
g <- ig.GOMF
# 2) randomly select vertices as the query nodes
nodes_query <- sample(V(g),5)$name
# 3) obtain the complete subgraph induced
subg <- dDAGinduce(g, nodes_query)
# 4) calculate the node levels
# 4a) definition based on the longest path
dDAGlevel(subg, level.mode="longest_path")
# 4b) definition based on the shortest path
dDAGlevel(subg, level.mode="shortest_path")
# 4b) definition based on the longest path, and return nodes for each level
dDAGlevel(subg, level.mode="longest_path", return.mode="level2node")Run the code above in your browser using DataLab