How to plot two networks with overlapping nodes?
1
0
Entering edit mode
6.4 years ago

Hello,

I have two networks that share some common genes. Anyone know how to plot them in the same image with the share nodes connected? For example

https://postimg.cc/image/biusynvzv/

I have tried igraph, ggnet2, network, geomnet, but they cannot generate the image I want.

Thanks.

network • 2.6k views
ADD COMMENT
0
Entering edit mode
6.4 years ago

If the networks are small enough, I would draw the lines separately in Inkscape.
Alternatively, make the common nodes distinct (for example by appending 1 to the names of nodes in graph 1 and 2 for nodes in graph 2) and form a graph with the union of the two graphs then add edges between the common nodes. Give these edges a distinct attribute that will allow the software to draw them differently from the others.

ADD COMMENT
0
Entering edit mode

Hello Jean-Karim,

My network is large.

I understand you. When I plot the two graph objects (networks) in the same image, they are mixed. I want to separate the two graphs far apart (one is at left the other one is at right), then place edges connecting shared nodes between the two networks. Any solutions?

Regards

ADD REPLY
1
Entering edit mode

In R, using the igraph package, you can specify the coordinates of the nodes

plot.igraph(myGraph, layout = coordinates.matrix)

You can use your own function to generate the layout coordinates:

coordinates.matrix <- layout_(myGraph, my.layout.function()))

and/or you can manually rearrange the nodes and save the coordinates:

tkid <- tkplot(myGraph, layout = coordinates.matrix) # move the nodes manually in new window
coordinates.matrix <- tkplot.getcoords(tkid) # get new node coordinates

In your case, I would probably create a layout function for the union graph that applies contraints on the coordinates of the nodes depending on which of the two initial graphs they come from (e.g. nodes from graph 1 can only be in the left half of the drawing area and nodes from graph 2, only in the right half).

ADD REPLY
0
Entering edit mode

Hello Jean-Karim,

Thank you very much. I got the solution.

Regards.

ADD REPLY

Login before adding your answer.

Traffic: 1869 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6