Converting network into correlation dataframe takes too long or crashes

I am trying to obtain correlation networks as a dataframe from my data so that I can manually later create networks on the top 25 highest correlated variables.

Here is my code:

> MyResult.spls <- spls(gene, taxa, 
>                       #keepX=keepX,  # I want all genes (5341 genes)
>                       #keepY=keepY, # I want all taxa (842 genera)
>                       scale=TRUE,
>                       ncomp=2,
>                       mode="regression",
>                       near.zero.var=FALSE)
> 
> network_dataframe <- as.data.frame(network(MyResult.spls,comp = 1:2)$M)
> 
> write.csv(network_dataframe,"stage1.csv"))

When trying to run network_dataframe, it takes FOREVER because R is also trying to create the graphic for this, is there a way to do this so that it just makes the table without trying to plot the network graphic? Sometimes it takes so long R just crashes saying there are errors but I know there are no errors, because I can run this code no problem with two other similar datasets that just happen to be smaller (same number of taxa, but about 4500 genes, so not a huge difference).

Any ideas on how to obtain the full correlation matrix without running into this time issue?

Actually I think I have found a way by using the cutoff variable within network - only issue is I cannot tell how high my correlation values go so it is a bit of a hit and miss but it definitely cuts down the time. This works since I only need the top % and bottom % of correlations.

If you downlaod the build of mixOmics which is found on our Github, I’ve added a parameter to the network() function named plot.graph. If you set this to FALSE, you will receive all the numerical output but the function won’t attempt to plot anything.

To install this:

  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. Load the devtools package (ensure you have it installed):

install.packages("devtools")
library(devtools)
  1. Download the package from the github repo:
install_github("mixOmicsTeam/mixOmics")
  1. Load the mixOmics library, and voilà!
library(mixOmics)