Question: Error in (function...) thrown by WGCNA tutorial (R)
1
gravatar for Kristin Muench
13 months ago by
United States
Kristin Muench410 wrote:

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 .
    TOM calculation: adjacency..
    ..will not use multithreading.
     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 .
    TOM calculation: adjacency..
    ..will not use multithreading.
     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!

R rna-seq wgcna • 1.6k views
ADD COMMENTlink modified 10 months ago by wonderfulzhu198560 • written 13 months ago by Kristin Muench410
4

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.

ADD REPLYlink written 10 months ago by wonderfulzhu198560

You're welcome, wonderfulzhu1985

ADD REPLYlink written 10 months ago by Kevin Blighe41k
2

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.

Rather than loading and unloading modules or restarting R one might as well temporarily re-assign the function:


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
ADD REPLYlink modified 5 weeks ago • written 5 weeks ago by schmidemanuel30

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.

ADD REPLYlink modified 10 months ago by zx87547.1k • written 10 months ago by wonderfulzhu198560

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?

ADD REPLYlink written 10 months ago by Kevin Blighe41k
2
gravatar for Kevin Blighe
12 months ago by
Kevin Blighe41k
London, England
Kevin Blighe41k wrote:

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.

ADD COMMENTlink written 12 months ago by Kevin Blighe41k
1

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...

ADD REPLYlink written 12 months ago by Kristin Muench410
1

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.

ADD REPLYlink written 12 months ago by Kevin Blighe41k
Please log in to add an answer.

Help
Access

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