DigiHard DigiHard - 1 year ago 146
R Question

How to plot Motifs in igraph?

I use igraph package to get motifs in Protein-Protein interaction network, It has a vector output, But I need plot or draw of motifs, figure of motifs.

code in R:

motifs(graph_object, size = 3)


1 NA NA 5 3

How to I get plot of motifs in R and igraph? Here have we four motifs?

Note: This question is different from How to mine for motifs in R with iGraph

Answer Source

Construct the motif that you want to search for as a "template graph" (for instance, create a triangle graph), then use subgraph_isomorphisms to find all the mappings from the vertices of the template graph from the vertices of your protein-protein interaction network, and induced_subgraph combined with lapply to transform the list of mappings into the actual motifs. Example:

> pattern <- graph.full(3)
> my.graph <- grg.game(100, 0.2)        # just an example graph, use yours
> iso <- subgraph_isomorphisms(pattern, my.graph)      # takes a while
> motifs <- lapply(iso, function (x) { induced_subgraph(my.graph, x) })

motifs will then be a list of graphs, and you can plot them one by one using plot().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download