'WGCNA functions not found

I'm applying WGCNA to RNASeq data following this tutorial. For several functions it give me an error that the package functions are not found.

> sft <- pickSoftThreshold(normalized_counts,
+                          dataIsExpr = TRUE,
+                          corFnc = cor,
+                          networkType = "signed"
+ )
Error in pickSoftThreshold(normalized_counts, dataIsExpr = TRUE, corFnc = cor,  : 
  could not find function "pickSoftThreshold"

I tried to make sure that the package was called correctly, but when I called it the following error emerged:

> library(WGCNA)
Error: package or namespace load failed for ‘WGCNA’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 there is no package called ‘xfun’
In addition: Warning message:
package ‘WGCNA’ was built under R version 4.1.3

So I tried installing the package "xfun":

> install.packages("xfun")
Installing package into ‘C:/Users/me/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/xfun_0.31.zip'
Content type 'application/zip' length 401092 bytes (391 KB)
downloaded 391 KB

package ‘xfun’ successfully unpacked and MD5 sums checked
Error in install.packages : ERROR: failed to lock directory ‘C:\Users\me\Documents\R\win-library\4.1’ for modifying
Try removing ‘C:\Users\me\Documents\R\win-library\4.1/00LOCK’

I followed some threads that suggested trying the following code for the error:

> install.packages("xfun", dependencies = TRUE, INSTALL_opts = '--no-lock')
package ‘pkgbuild’ successfully unpacked and MD5 sums checked
Error in install.packages : ERROR: failed to lock directory ‘C:\Users\parnian\Documents\R\win-library\4.1’ for modifying
Try removing ‘C:\Users\me\Documents\R\win-library\4.1/00LOCK’

I don't know how to overcome these errors to be able to use WGCNA functions such as pickSoftThreshold(). Can you help me?

r


Solution 1:[1]

Go to your library folder: C:\Users\me\Documents\R\win-library\4.1/ and remove all folders beginning with 00LOCK

Restart R and then try to reinstall xfun and WGCNA

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 abichat