Change network layout

I have created a network using the following code:

network(MyResult.diablo_comp1,blocks=c(1,2),,color.node=c('lightblue','yellow2'),breaks=NULL,  cutoff=0.4, lwd.edge=2,show.edge.labels=F, = layout.sphere, color.edge=  color.jet(100))

However, my nodes are huge for the taxonomic dataset and thus overlap. It is impossible to see most of the edges. How can I either:
A) Decrease the nodes size (and let the label run across) I already have rather short names that I cannot shorten further withour losing important information
B) increase the edge length or
C) change the layout?
For A and B I don’t find any instructions in the network function help. For C, I have tried numerous different layouts but non solved the problem.
Please, advice! I have very interesting correlations in my circos plot but I think a network would make the interactions more comprehensible.
Thank you for your great work and support!

G’day @stepra

The simple (and inelegant) fix to your problem is to set the shape.node parameter to "none". This will remove the presence of any nodes while retaining the names. This may be sufficient for you. However, if you cannot identify the block by the feature name, it compounds your issue rather than solves it.

I’m currently working on an adjustment to the network() which should give you control of the size of each node as well as influence over the distance between them. I’ll update you once this is fully implemented

Thank you @MaxBladen for the suggestion. I tried it, but it does not look very nice. I think I need to be able to both change node size and length on edges. Is the length of the edges a measure of something? Some of my edges are pretty long and others are just as short as a dot almost. If the length does not contain any important information, I would like to be able to set at least a minimum length. That might also help prevent overlapping nodes.
Do you have a rough time estimate for your implementation?
Kind regards,

The edge lengths are not a measure of anything. Nor can they be influenced with a high degree of control. igraph (the package used to generate the network plots) does not have the greatest degree of user control unfortunately. I’ll see if I can determine a way to set a minimum - otherwise my current implementation just forces them closer or further apart. I should have it ready for you by the end of the day hopefully.


Afternoon @stepra,

I have just pushed a build to our GitHub repo which should help you! If you’d like an overview of the changes and how to use them, read here. Essentially, you can now control the total scale of the plot, increasing the distance between nodes. Also, you can directly control the size of the nodes themselves.

To install this version, follow these steps:

  1. Load the devtools package (ensure you have it installed):
  1. Download the package on the issue-233 branch:
               ref = github_pull("234"))
  1. Load the mixOmics library, and voilà!

Thank you so much @MaxBladen ! I was very eager to try it out but ran into some problems:

> install_github("mixOmicsTeam/mixOmics",ref = github_pull("issue-233"))
Error in github_resolve_ref.github_pull(meta$ref %||% ref, meta, host = host,  : 
  Cannot find GitHub pull request mixOmicsTeam/mixOmics#issue-233
HTTP error 404.
  Not Found

  Did you spell the repo owner (`mixOmicsTeam`) and repo name (`mixOmics`) correctly?
  - If spelling is correct, check that you have the required permissions to access the repo.
> install_github("mixOmicsTeam/mixOmics",ref = github_pull("234"))
Downloading GitHub repo mixOmicsTeam/mixOmics@issue-233

So issue 234 seems to work, however, after installing and running the following commad I get the error below:

pdf(file="220830network_comp1_cutoff40.pdf", width = 12, height = 8)
> network(MyResult.diablo_comp1,blocks=c(1,2),,color.node=c('lightblue','yellow2'),breaks=NULL,  cutoff=0.4, lwd.edge=2,show.edge.labels=F, graph.scale=1,size.node=0.2, color.edge=  color.jet(100))
Error in network(MyResult.diablo_comp1, blocks = c(1, 2), = 0.8,  : 
  unused arguments (graph.scale = 1, size.node = 0.2)

this makes me uncertain whether #234 was the correct one to install after all. Any advice is highly appreciated.
Best wishes,

Ah yes, apologies. The "233" was a typo - you can either use:

               branch = "issue-233")


               ref = github_pull("234"))

I’ve encountered your issue before. I am not aware of the root cause - but here is a work around that’s worked for me and plenty others:

  1. Navigate to the R directory on your computer. Ensure the folder is titled like “R-X.X.X” (in my case, R-4.2.1).This can be found using the following command in RStudio:
> file.path(R.home())
[1] "D:/Programs/Work Programs/R-4.2.1"
  1. Go into this folder, then to library and look for mixOmics. Select the mixOmics folder and delete it.

  2. Run the three steps from above.

In my experience, this should work but please let me know if it doesn’t!

Thanks a lot @MaxBladen! It works now :slight_smile: I just wonder whether it is possible to visualise edges between nodes from the same dataset, just like the showIntraLinks in the circosPlot? I prefer plotting a network as I think the centrality is emphasised better but I hate to lose these associations.

I’ve thought about this too. A few other things have become pressing matters, but once I’ve resolved them I’ll look into this functionality of network()

That would be great! Could you post here when you have had the time to implement this?
Again, thank you for all you help!

Dear @MaxBladen,
I wonder whether you or anyone else in the team has had time to implement the intralinks for the networks yet, i.e., to visualise edges between nodes from the same dataset, as discussed above.
Best wishes,

Unfortunately not, I’m essentially the only developer and I’ve had a number of more pressing matter to attend to. I’ll notify you once I’ve had a chance to work on it

1 Like