These are general functions to expand vertices by their attributes, i.e. create a separate vertex for each attribute value.

expandComplexes(
  graph,
  v.attr,
  keep.parent.attr = "^pathway",
  expansion.method = c("normal", "duplicate"),
  missing.method = c("keep", "remove", "reconnect")
)

makeGeneNetwork(
  graph,
  v.attr = "genes",
  keep.parent.attr = "^pathway",
  expansion.method = "duplicate",
  missing.method = "remove"
)

Arguments

graph

An annotated igraph object.

v.attr

Name of the attribute which vertices are expanded to.

keep.parent.attr

A (List of) regex experssions representing attributes to be inherited by daughter vertices. If "all" is passed, all parent attributes are inherited.

expansion.method

If "duplicate", attribute values sharing more than one parent vertex are duplicated for each vertex they participate in. For exmaple, if one gene G1 catalyzes reactions R1, R2; then G1##R1, and G1##R2 vertices are created. If "normal" only one vertex (G1) is created, and inherit all R1 and R2 connections and attributes.

missing.method

How to deal with vertices with no attribute values. "keep" retains the parent node, "remove" simply deletes the vertex, and "reconnect" removes the vertex and connect its neighbours to each other (to prevent graph cuts).

Value

A new graph with vertices expanded.

makeGeneNetwork returns a graph, where nodes are genes, and edges represent participation in succesive reactions.

Details

These functions can be very useful when merging networks constructed from different databases. For example, to match a network created from Reactome to a KEGG network, you can expand metabolite vertices by "miriam.kegg.compound" attribute.

Author

Ahmed Mohamed

Examples

 ## Make a gene network from a reaction network.
 data(ex_sbml)  # A bipartite metbaolic network.
 rgraph <- makeReactionNetwork(ex_sbml, simplify=TRUE)
#> This graph was created by an old(er) igraph version.
#>  Call `igraph::upgrade_graph()` on it to use with the current igraph version.
#> For now we convert it on the fly...
 ggraph <- makeGeneNetwork(rgraph)

 ## Expand vertices into their contituent genes.
 data(ex_kgml_sig)  # Ras and chemokine signaling pathways in human
  ggraph <- expandComplexes(ex_kgml_sig, v.attr = "miriam.ncbigene",
            keep.parent.attr= c("^pathway", "^compartment"))
#> This graph was created by an old(er) igraph version.
#>  Call `igraph::upgrade_graph()` on it to use with the current igraph version.
#> For now we convert it on the fly...

 ## Create a separate vertex for each compartment. This is useful in duplicating
  ##  metabolite vertices in a network.
if (FALSE) { # \dontrun{
 graph <- expandComplexes(graph, v.attr = "compartment",
        keep.parent.attr = "all",
        expansion.method = "duplicate",
        missing.method = "keep")
} # }