Error in (function...) thrown by WGCNA tutorial (R)
1
1
Entering edit mode
3.1 years ago

Hello,

I am trying to follow along with the network generation/cluster generation part of the WGCNA tutorial: https://labs.genetics.ucla.edu/horvath/CoexpressionNetwork/Rpackages/WGCNA/Tutorials/FemaleLiver-02-networkConstr-blockwise.pdf

I am getting the same error regardless of whether I use data for the tutorial or my own RNA-Seq data (both are data frames).

The command that throws the error is (this is the version using tutorial data):

bwnet = blockwiseModules(datExpr, power = 6,
+                        TOMType = "unsigned", minModuleSize = 30,
+                        reassignThreshold = 0, mergeCutHeight = 0.25,
+                        numericLabels = TRUE,
+                        maxBlockSize = 2000,
+                        saveTOMs = TRUE,
+                        saveTOMFileBase = "tstTOM",
+                        verbose = 3)


The output I get is:

Calculating module eigengenes block-wise from all genes
Flagging genes and samples with too many missing values...
..step 1
Cluster size 3600 broken into 2133 1467
Cluster size 2133 broken into 1221 912
Done cluster 1221
Done cluster 912
Done cluster 2133
Done cluster 1467
....pre-clustering genes to determine blocks..
Projective K-means:
projectiveKMeans: imputing missing data in 'datExpr'.
To reproduce older results, use 'imputeMissing = FALSE'.
Cluster size 3600 broken into 2133 1467
Cluster size 2133 broken into 1221 912
Done cluster 1221
Done cluster 912
Done cluster 2133
Done cluster 1467
..k-means clustering..
..merging smaller clusters...
Block sizes:
gBlocks
1    2
1973 1627
..Working on block 1 .
Fraction of slow calculations: 0.426707
..connectivity..
..matrix multiplication (system BLAS)..
..normalization..
..done.
..saving TOM for block 1 into file cnv16pTOM-block.1.RData
....clustering..
....detecting modules..
....calculating module eigengenes..
....checking kME in modules..
..removing 6 genes from module 1 because their KME is too low.
..Working on block 2 .
Fraction of slow calculations: 0.358721
..connectivity..
..matrix multiplication (system BLAS)..
..normalization..
..done.
..saving TOM for block 2 into file cnv16pTOM-block.2.RData
....clustering..
....detecting modules..
....calculating module eigengenes..
....checking kME in modules..
..removing 1 genes from module 1 because their KME is too low.

Error in (function (x, y = NULL, use = "everything", method = c("pearson",  :
unused arguments (weights.x = NULL, weights.y = NULL, cosine = FALSE)


As far as I can tell, the WGCNA library is installed correctly. Can anyone identify what might be causing this "Error in (function..." error? Any ideas as to how to start fixing it?

Thank you!

WGCNA RNA-Seq R • 4.1k views
4
Entering edit mode

I think I tackle the problem. There is a conflict between the WGCNA and the other packages. the other package have a function the same as the other in WGCNA in the run r studio. when I library no packages other than WGCNA, the program runs well and get the module. Thanks for professor Kevin Blighe's advice.

0
Entering edit mode

You're welcome, wonderfulzhu1985

2
Entering edit mode

As correctly answered by multiple people here, the problem is that WGCNA has its own function "cor" and this correlates in the namespace with "cor" from the package stats.


cor <- WGCNA::cor

bwnet = blockwiseModules(datExpr, maxBlockSize = 2000,
power = 17, TOMType = "unsigned", minModuleSize = 30,
reassignThreshold = 0, mergeCutHeight = 0.25,
numericLabels = TRUE,
saveTOMs = TRUE,
saveTOMFileBase = "TOM-blockwise",
verbose = 3)

cor<-stats::cor

0
Entering edit mode

I am a new in learning the WGCNA, and I also encounter the same problem detailed in your question. Please see: Error in (function...) thrown by WGCNA

I have do many tries to tackle the problem by adjust the parameters. I also try many methods as the other author do in some literature. while they cannot get rid of the warning and acquire the module. So I deeply appreciate the help from you to tackle it. Thanks very much.

0
Entering edit mode

Did you try to restart your computer, reload R, and then install / load the WGCNA package as the very first thing that you do in the new R session?

2
Entering edit mode
3.1 years ago

It looks like some namespace issue. If you close R Studio, restart your computer, and then reinstall WGCNA as the first thing that you do when you re-open R Studio, then I think that that may resolve it.

1
Entering edit mode

How odd! Thanks for the feedback. Indeed - if I'm in RStudio and it stops working, doing install.packages('WGCNA') and then library(WGCNA) usually helps. Wonder if restarting the R environment has something to do with it? Hm...

1
Entering edit mode

Yes, my logic was that you may have had other packages loaded in RStudio that were using functions of the same name (as those used by WGCNA). Given the number of R packages out there, namespace issues are obviously bound to happen.

I think that you can explicitly specify a function by referncing first the package, as follows: For example

WGCNA::cor
stats::cor


Same function name (cor) but in different packages.