WGCNA functions not found - r

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?

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

Related

Installing package in R: there is no package called ‘gsl’

I tried to install package copula but incurred error.
I first installed package copula, then tried:
library(copula)
and get:
Show in New WindowClear OutputExpand/Collapse Output
Error: package or namespace load failed for ‘copula’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘gsl’
Then I installed package gsl, restarted R, and tried, following this similar issue:
if(!require(pacman)) install.packages("pacman")
pacman::p_load(copula)
which didn't seem to work. I'm using macOS Big Sur OS.
Edit:
install.packages("gsl")
returned:
There is a binary version available but the source version is later:
Warning in install.packages :
cannot open compressed file '/Users/xxx/.rstudio-desktop/notebooks/3D993D5E-filename/1/8FD36A93A05DA0F7/c6uz0e7whq1or_t/_rs_rdf_111422764b18d.rdf', probable reason 'No such file or directory'
Error in install.packages : cannot open the connection
Update:
On 18/05/21, tried
install.packages("copula")
library(copula)
and caught error below:
> install.packages("copula")
also installing the dependency ‘gsl’
There is a binary version available but the source version is later:
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Y
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/copula_1.0-1.tgz'
Content type 'application/x-gzip' length 7335219 bytes (7.0 MB)
==================================================
downloaded 7.0 MB
The downloaded binary packages are in
/var/folders/ll/dvpphrys0pddnjffq7zbl7vm0000gn/T//RtmpRUGsKi/downloaded_packages
installing the source package ‘gsl’
trying URL 'https://cran.rstudio.com/src/contrib/gsl_2.1-6.tar.gz'
Content type 'application/x-gzip' length 189794 bytes (185 KB)
==================================================
downloaded 185 KB
* installing *source* package ‘gsl’ ...
** package ‘gsl’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gsl-config... no
configure: error: gsl-config not found, is GSL installed?
ERROR: configuration failed for package ‘gsl’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/gsl’
Warning in install.packages :
installation of package ‘gsl’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/ll/dvpphrys0pddnjffq7zbl7vm0000gn/T/RtmpRUGsKi/downloaded_packages’
> library(copula)
Error: package or namespace load failed for ‘copula’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘gsl’
Download Homebrew then run
if(!require(pacman)) install.packages("pacman")
pacman::p_load(copula)
seems working for me :)

Error: package or namespace load failed for ‘intsvy’

I am using RStudio Version 1.0.136 – © 2009-2016 RStudio, Inc. I checked for a new update and I received a massege that saying "You're using the newest version of RStudio".
Here I am trying to use R ‘intsvy’ package.
I started by setting up the directory.
Then, first I installed the package by using the following code:
install.packages("intsvy", lib="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
Below is the Console results
There is a binary version available but the source version is later:
binary source needs_compilation
intsvy 2.1 2.4 FALSE
installing the source package ‘intsvy’
trying URL 'https://cran.rstudio.com/src/contrib/intsvy_2.4.tar.gz'
Content type 'application/x-gzip' length 56777 bytes (55 KB)
==================================================
downloaded 55 KB
starting R..
* installing *source* package ‘intsvy’ ...
** package ‘intsvy’ successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘repr’
ERROR: lazy loading failed for package ‘intsvy’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/intsvy’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/intsvy’
Warning in install.packages :
installation of package ‘intsvy’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/jj/3brk8hp91ps2mdv6gzlynh6r0000gn/T/RtmppVfRws/downloaded_packages’
Second, I installed the package by using the following code after receiving the above long massage:
install.packages("intsvy")
Below is the Console results
Installing package into ‘/Users/HU-Hisham/Library/R/3.3/library’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
intsvy 2.1 2.4 FALSE
installing the source package ‘intsvy’
trying URL 'https://cran.rstudio.com/src/contrib/intsvy_2.4.tar.gz'
Content type 'application/x-gzip' length 56777 bytes (55 KB)
==================================================
downloaded 55 KB
starting R..
* installing *source* package ‘intsvy’ ...
** package ‘intsvy’ successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘repr’
ERROR: lazy loading failed for package ‘intsvy’
* removing ‘/Users/HU-Hisham/Library/R/3.3/library/intsvy’
Warning in install.packages :
installation of package ‘intsvy’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/jj/3brk8hp91ps2mdv6gzlynh6r0000gn/T/RtmppVfRws/downloaded_packages’
Next #load backage
library("intsvy")
Below are the massages I received in the Console
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘repr’
In addition: Warning message:
package ‘intsvy’ was built under R version 3.3.2
Error: package or namespace load failed for ‘intsvy’
After installations, I tried to run the following command
pirls.var.label(folder = getwd("~/Desktop/Dr. Kato/Data/PISA/CY07_MSU_STU_QQQ.sav"),
+ name = "Variable labels", output = getwd())
Here is the massage
Error: could not find function "pirls.var.label"
Function pirls.var.label is one of the functions in the 'intsvy' package.
Why am I receiving this error? Is it because the package not successfully installed? How can I take care or this matter and start using the package and data? Please advice.
I updated my R version from R3.3.1 (2016-06-21) to R3.6.2 (2019-12-12)as some experts recommended.
Then I run the commands again after restarting R:
1 installing repr package
> install.packages("repr")
Warning in install.packages :
cannot open URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/PACKAGES.rds': HTTP status was '404 Not Found'
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/repr_1.0.2.tgz'
Content type 'application/x-gzip' length 118906 bytes (116 KB)
==================================================
downloaded 116 KB
The downloaded binary packages are in
/var/folders/jj/3brk8hp91ps2mdv6gzlynh6r0000gn/T//Rtmpt0mup2/downloaded_packages
Warning message:
R graphics engine version 12 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.
2 installing intsvy package
> install.packages("intsvy", dependencies = T)
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/intsvy_2.4.tgz'
Content type 'application/x-gzip' length 336356 bytes (328 KB)
==================================================
downloaded 328 KB
The downloaded binary packages are in
/var/folders/jj/3brk8hp91ps2mdv6gzlynh6r0000gn/T//Rtmpt0mup2/downloaded_packages
load backage
> library("intsvy")
Error: package or namespace load failed for ‘intsvy’:
.onLoad failed in loadNamespace() for 'pillar', details:
call: utils::packageVersion("vctrs")
error: there is no package called ‘vctrs’
> library(intsvy)
Error: package or namespace load failed for ‘intsvy’:
.onLoad failed in loadNamespace() for 'pillar', details:
call: utils::packageVersion("vctrs")
error: there is no package called ‘vctrs’
Still same errors when I try to run the package commands
> pisa.var.lable(folder="~/Desktop/Dr. Kato/Data/PISA/CY07_MSU_STU_QQQ.sav")
Error in pisa.var.lable(folder = "~/Desktop/Dr. Kato/Data/PISA/CY07_MSU_STU_QQQ.sav") :
could not find function "pisa.var.lable"
> pirls.var.label(folder = getwd("~/Desktop/Dr. Kato/Data/PISA/CY07_MSU_STU_QQQ.sav"),
+ name = "Variable labels", output = getwd())
Error in pirls.var.label(folder = getwd("~/Desktop/Dr. Kato/Data/PISA/CY07_MSU_STU_QQQ.sav"), :
could not find function "pirls.var.label"
If you have an idea, please share it here so I can try it to solve this issue and start using the package and PISA data.
Thank you

Space in path name causing "Warning: invalid package" on install. R

When running R-3.4.4 (on Windows 7, RStudio):
install.packages("ggplot2", destdir = "C:/Program Files/R/R-3.4.4/library/temp")
I get the following warning (presumably from the space in the path):
installing the source package ‘ggplot2’
trying URL 'https://cran.rstudio.com/src/contrib/ggplot2_3.2.1.tar.gz'
Content type 'application/x-gzip' length 3204655 bytes (3.1 MB)
downloaded 3.1 MB
Warning: invalid package 'C:/Program'
Warning: invalid package 'Files/R/R-3.4.4/library/temp/ggplot2_3.2.1.tar.gz'
Error: ERROR: no packages specified
In R CMD INSTALL
Warning in install.packages :
running command '"C:/Program Files/R/R-3.4.4/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.4.4\library" C:/Program Files/R/R-3.4.4/library/temp/ggplot2_3.2.1.tar.gz' had status 1
Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status
Although, trying to circumvent it using:
install.packages("ggplot2", destdir = "C:/Temp")
leads to:
* installing *source* package 'ggplot2' ...
** package 'ggplot2' successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called 'pillar'
where
.libPaths()
[1] "C:/Program Files/R/R-3.4.4/library"
Again, trying to solve that warning with:
install.packages("pillar", destdir = "C:/Temp")
leads to
** testing if installed package can be loaded
Fatal error: cannot open file 'C:\Users\Mary': No such file or directory
The full path is C:\Users\Mary Surname\etc\etc... Which brings it back to the first problem where there is a space between "FirstName" and "Surname" in the path.
Any way to correct the incorrect interpretation of the space. Note, the download is fine but it falls over trying to find the zip file it had only just downloaded.

R install package caret [duplicate]

I am trying to load ggplot2. I am using Windows 7. R tells me that ggplot2 has loaded successfully but when I try to use the library function it says it cannot find ggplot2. Here is what it says.
install.packages("ggplot2")
Installing package into ‘C:/Users/Owner/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/ggplot2_1.0.0.zip'
Content type 'application/zip' length 2675581 bytes (2.6 Mb)
opened URL
downloaded 2.6 Mb
package ‘ggplot2’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Owner\AppData\Local\Temp\RtmpyesS1j\downloaded_packages
I then tried to use the library function and got this message:
library("ggplot2")
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called ‘munsell’
Error: package or namespace load failed for ‘ggplot2’
> head(diamonds)
Error in head(diamonds) : object 'diamonds' not found
I hope someone has an idea about what I have done wrong.
You should have executed this:
install.packages("ggplot2", dependencies=TRUE)

Loading ggplot2 package, missing 'munsell' package

I am trying to load ggplot2. I am using Windows 7. R tells me that ggplot2 has loaded successfully but when I try to use the library function it says it cannot find ggplot2. Here is what it says.
install.packages("ggplot2")
Installing package into ‘C:/Users/Owner/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/ggplot2_1.0.0.zip'
Content type 'application/zip' length 2675581 bytes (2.6 Mb)
opened URL
downloaded 2.6 Mb
package ‘ggplot2’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Owner\AppData\Local\Temp\RtmpyesS1j\downloaded_packages
I then tried to use the library function and got this message:
library("ggplot2")
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called ‘munsell’
Error: package or namespace load failed for ‘ggplot2’
> head(diamonds)
Error in head(diamonds) : object 'diamonds' not found
I hope someone has an idea about what I have done wrong.
You should have executed this:
install.packages("ggplot2", dependencies=TRUE)

Resources