dDAGinduce
is supposed to produce a subgraph induced by given
vertices, given a direct acyclic graph (DAG; an ontology). The input is
a graph of "igraph" or "graphNET" object, a list of the vertices of the
graph, and the mode defining the paths to the root of DAG. The
resultant subgraph inherits the class from the input one. The induced
subgraph contains exactly the vertices of interest and their defined
paths to the root of DAG.
dDAGinduce(g, nodes_query, path.mode = c("all_paths", "shortest_paths", "all_shortest_paths"))
subg
: an induced subgraph, an object of class "igraph" or
"graphNEL"
For the mode "shortest_paths", the induced subgraph is the most concise, and thus informative for visualisation when there are many nodes in query, while the mode "all_paths" results in the complete subgraph.
# 1) load HPPA as igraph object ig.HPPA <-dRDataLoader(RData='ig.HPPA')'ig.HPPA' (from package 'dnet' version 1.1.2) has been loaded into the working environment (at 2018-01-19 12:34:56)g <- ig.HPPA # 2) randomly select vertices as the query nodes # the query nodes can be igraph vertex sequences nodes_query <- sample(V(g),5) # more commonly, the query nodes can be term id nodes_query <- sample(V(g),5)$name # 3) obtain the induced subgraph # 3a) based on all possible paths (i.e. the complete subgraph induced) subg <- dDAGinduce(g, nodes_query, path.mode="all_paths") # 3b) based on shortest paths (i.e. the most concise subgraph induced) subg <- dDAGinduce(g, nodes_query, path.mode="shortest_paths")