Question: network visualization R with partially fixed layout matrix
gravatar for Ted
22 months ago by
United States
Ted0 wrote:

Hi All,

I'm using R package 'igraph' and 'qgraph' to draw the metabolite compound network graph. The network basically depends on adjacency matrix and layout matrix. I'm wondering is that possible that, for example, I first draw 10 compounds with fixed position (fixed x,y coordinates), then draw the remaining compound dynamically (let the algorithm to decide where to put them)?

Thank you all!

adjacency matrix network R • 930 views
ADD COMMENTlink modified 22 months ago by Jean-Karim Heriche18k • written 22 months ago by Ted0
gravatar for Jean-Karim Heriche
22 months ago by
EMBL Heidelberg, Germany
Jean-Karim Heriche18k wrote:

I don't think you can provide an incomplete layout matrix. You can try selecting a layout algorithm and at the same time giving x,y attributes to some nodes but my guess is that the x,y attributes will be recalculated by the layout function. The way I would do it is to generate the layout matrix with the algorithm of choice e.g. coords <- igraph_layout_fruchterman_reingold(...) then change the coordinates of the nodes of interest.
There's also a GUI way:

coords <- layout_(G, with_fr())  # generate node coordinates with FR algorithm
tkid <- tkplot(G, layout = coords) # manually adjust nodes in new window
coords <- tkplot.getcoords(tkid) # get new node coordinates
plot.igraph(G, layout = coords)
ADD COMMENTlink modified 22 months ago • written 22 months ago by Jean-Karim Heriche18k

Thank you. However, in my situation, we have 2,000 compounds in total. We have 100 compounds that belong to different KEGG pathway modules (we want compounds that belong to the same pathway module to be closer together). The remaining 1,900 compounds has a "quadruple tree" structure connected with these 100 compound. As a result, it would be hard to adjust the position of these 100 compounds after plotting all these 2,000 compounds.

I will at least try to plot based on the partial layout matrix to see whether it works.

ADD REPLYlink written 22 months ago by Ted0

If there are too many nodes to be able to adjust them manually, I would question the usefulness of this visual representation, i.e. I am not sure you'll get anything that can be visually interpreted with such a graph. You might want to consider a graph with fewer nodes, for example nodes could represent clusters of compounds.
Anyways, you don't have to use the GUI. Once you've generated the layout matrix, you can programmatically modify it or you can write your own layout function which you can also use with the layout_() function:

coords <- layout_(G, my.own.layout.function()))

If you want nodes to cluster by pathway, you could also adjust the edge weights so that layout algorithms such as Fruchterman-Reingold would group pathway members together.

ADD REPLYlink written 22 months ago by Jean-Karim Heriche18k

Thank you Jean and that's exactly what I want! After adjusting the adj matrix to connect each compound node to representative pathway nodes, the compound nodes belong to the same pathway will cluster together by FR algorithm. The whole graph now looks much better since each clustered area represents a functional pathway/module.

ADD REPLYlink written 21 months ago by Ted0

Perhaps you should print your 2000 metabolite network on a very large poster board, like one of those classic metabolite / enzyme network posters.

ADD REPLYlink written 22 months ago by theobroma221.1k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 915 users visited in the last hour