This function allows users to replace vertex ids with another attribute, calculating connectivities based on the new attribute.

reindexNetwork(graph, v.attr)

Arguments

graph

An annotated igraph object.

v.attr

Name of the attribute to use as vertex ids.

Value

A new graph with vertices expanded.

Details

This 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 reindex the vertices by "miriam.kegg.compound" attribute. Another usage is to remove duplicated vertices (in case of different subcellular compartments, for example). if a network has ATP_membrane & ATP_cytoplasm vertices, reindexing by chemical name will collapse them into one `ATP` vertex.

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")
} # }