安装BiocManager::install(“MungeSumstats”)报错
抑郁年年有,今年特别多。
安个包,处处是坎儿啊。
安装BiocManager::install(“MungeSumstats”)报错
cram/cram_io.c:53:10: fatal error: bzlib.h: No such file or directory
从这个报错开始,后边跟着一串串报错。就不一一展示了。排雷当从第一个起。
解决办法:
在终端输入:
sudo apt install libboost-all-dev
sudo apt-get install libbz2-dev
2023-4-19
从来没想过,犯错还能在同一个坑的
此次是因为ubuntu重装了,所以R要重新配置。又不能安装了,出现如下报错:
hfile_libcurl.c:47:10: fatal error: curl/curl.h: No such file or directory
47 | #include <curl/curl.h>
| ^~~~~~~~~~~~~
compilation terminated.
make[1]: Leaving directory ‘/tmp/RtmpPIQj04/R.INSTALL36cf3efb3877/Rhtslib/src/htslib-1.15.1’
make[1]: *** [Makefile.Rhtslib:135: hfile_libcurl.o] Error 1
make: *** [Makevars.common:22: htslib] Error 2
ERROR: compilation failed for package ‘Rhtslib’
- removing ‘/home/he/R/x86_64-pc-linux-gnu-library/4.2/Rhtslib’
这个错误是因为缺少libcurl库。可以按照以下步骤解决:
1.在终端输入:
sudo apt-get install libcurl4-openssl-dev
2.重新安装MungeSumstats R包:
又出现新的报错:
ERROR: configuration failed for package ‘XML’
- removing ‘/home/he/R/x86_64-pc-linux-gnu-library/4.2/XML’
installing source package ‘RCurl’ …
package ‘RCurl’ successfully unpacked and MD5 sums checked
using staged installation
该错误通常是由于缺少系统库或无法连接到所需的依赖项而引起的。在解决问题之前,需要确认您的系统中是否已安装所有必需的依赖项。
在Linux系统中,您可以尝试以下命令在终端来安装可能缺失的依赖项:
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev libssl-dev libxml2-dev
这将安装一些常见的依赖项,包括用于XML解析的libxml2-dev和用于加密连接的libssl-dev和libcurl4-openssl-dev。
如果以上步骤无效,您可以尝试手动安装XML包,然后再次尝试安装MungeSumstats包。您可以使用以下命令在R中手动安装XML包:
install.packages("XML", dependencies=TRUE)
重新安装,报错倒是越来越少了,还有如下报错:
ERROR: dependency ‘biomaRt’ is not available for package ‘GenomicFeatures’
*removing ‘/home/he/R/x86_64-pc-linux-gnu-library/4.2/GenomicFeatures’
- installing source package ‘BSgenome’ …
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices- building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path- DONE (BSgenome)
ERROR: dependency ‘GenomicFeatures’ is not available for package ‘VariantAnnotation’- removing ‘/home/he/R/x86_64-pc-linux-gnu-library/4.2/VariantAnnotation’
ERROR: dependency ‘VariantAnnotation’ is not available for package ‘MungeSumstats’- removing ‘/home/he/R/x86_64-pc-linux-gnu-library/4.2/MungeSumstats’
这个报错提示是因为您尝试安装的包之间存在依赖关系,但是其中某些依赖包在当前环境下不可用或者无法安装。具体来说,GenomicFeatures包依赖于biomaRt包,VariantAnnotation包依赖于GenomicFeatures包,而MungeSumstats包依赖于VariantAnnotation包。因此,在安装MungeSumstats包之前,您需要先安装其它依赖包。
可以尝试以下几个步骤来解决问题:
检查您的R和Bioconductor版本是否与要求匹配。有些包需要特定版本的R和Bioconductor才能正常安装。可以使用sessionInfo()函数查看当前R和Bioconductor的版本信息,确保它们符合要求。
如果依赖包不可用,可以尝试重新安装这些依赖包。例如,如果 biomaRt 包无法安装,您可以尝试手动安装该包,或者使用以下命令重新安装所有依赖包:
BiocManager::install(c("biomaRt", "GenomicFeatures", "restfulr", "BSgenome", "VariantAnnotation", "rtracklayer", "MungeSumstats"))
如果依赖包已安装但仍然出现问题,您可以尝试使用install.packages()命令从CRAN安装这些依赖包,例如:
install.packages("biomaRt", "GenomicFeatures", "restfulr", "BSgenome", "VariantAnnotation", "rtracklayer", "MungeSumstats")
继续安装,出现如下warning
Installation paths not writeable, unable to update packages path:
/usr/lib/R/library packages:
boot, class, cluster, codetools, foreign, lattice, MASS, Matrix, mgcv, nlme, nnet, rpart, spatial, survival path:
/usr/lib/R/site-library packages:
bit, bslib, digest, gargle, ggplot2, highr, isoband, jsonlite, loo, matrixStats, processx, ps, ragg, rmarkdown, stringr, tinytex
Warning message: package(s) not installed when version(s) same as or
greater than current; useforce = TRUE
to re-install: ‘restfulr’
‘BSgenome’ ‘rtracklayer’
这个错误表明您没有写入R包的安装路径的权限。在Linux系统上,R包通常被安装在/usr/lib/R/library或/usr/lib/R/site-library路径下。
要解决这个问题,您可以使用sudo命令作为超级用户运行R,或者使用具有写入权限的用户帐户。您可以使用以下命令更改R包安装路径的所有者和组:
sudo chown -R username:groupname /usr/lib/R/library
sudo chown -R username:groupname /usr/lib/R/site-library
出现如下报错
‘getOption(“repos”)’ replaces Bioconductor standard repositories, see
‘help(“repositories”, package = “BiocManager”)’ for details.
Replacement repositories:
CRAN: https://cloud.r-project.org Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.3 (2023-03-15) Installation paths not
writeable, unable to update packages path: /usr/lib/R/library
packages:
boot, class, cluster, codetools, foreign, lattice, MASS, Matrix, mgcv, nlme, nnet, rpart, spatial, survival path:
/usr/lib/R/site-library packages:
bit, bslib, digest, gargle, ggplot2, highr, isoband, jsonlite, loo, matrixStats, processx, ps, ragg, rmarkdown, stringr, tinytex
Warning message: package(s) not installed when version(s) same as or
greater than current; useforce = TRUE
to re-install:
‘MungeSumstats’
检查权限问题:报错信息提示需要sudo权限来安装,因此可以尝试在终端中使用sudo命令进行安装,即在终端中输入以下命令:
在终端进入R
sudo R
然后输入密码。进入R控制台后再安装:
然后终端又出现如下报错:
Error in loadNamespace(x) : there is no package called ‘BiocManager
这个错误提示表明 R 环境缺少 BiocManager 包,需要先安装 BiocManager 包才能继续安装其他依赖于它的包。
在 R 终端中输入以下命令来安装 BiocManager 包:
install.packages("BiocManager")
加载包
library(BiocManager)
一旦 BiocManager 包成功加载,就可以尝试重新安装
BiocManager::install("MungeSumstats")
这回终于成功了
反复在R和terminal之间来回捯饬,都晕头转向了。真是又意外又疲劳啊。反正是没啥惊喜
2023-6-25
另外,还有一个靠谱的安装方式:
remotes::install_github("MRCIEU/MRInstruments")