network visualization R with partially fixed layout matrix
1
0
Entering edit mode
7.5 years ago
Ted • 0

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!

R network adjacency matrix • 2.4k views
ADD COMMENT
1
Entering edit mode
7.5 years ago

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 COMMENT
0
Entering edit mode

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 REPLY
1
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1687 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