Ubuntu16.04-R3.4.2下安装clusterProf
最近在学习聚类分析,看了Y叔的一系列帖子,觉得clusterProfiler就是传说中一包走天下的神包
在windows和mac都安装成功,这是背景。
在Ubuntu16.04,R3.4.2(2017-09-28)下运行一下命令,发生错误
source("https://bioconductor.org/biocLite.R")
biocLite('clusterProfiler')
** preparing package for lazy loading
Creating a new generic function for ‘append’ in package ‘BiocGenerics’
Creating a new generic function for ‘as.data.frame’ in package ‘BiocGenerics’
Creating a new generic function for ‘cbind’ in package ‘BiocGenerics’
Error : identical(as.call(parse(text = old_code)[[1L]]), body[[7L]][[3L]]) is not TRUE
Error in apply_hotfix73465(getGeneric("cbind")) :
hotfix failed for generic function cbind()
Error : unable to load R code in package ‘BiocGenerics’
ERROR: lazy loading failed for package ‘BiocGenerics’
- removing ‘/home/shipeng/opt/biosoft/R/bioconductor/BiocGenerics’
ERROR: dependency ‘BiocGenerics’ is not available for package ‘S4Vectors’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/S4Vectors’
ERROR: dependencies ‘BiocGenerics’, ‘S4Vectors’ are not available for package ‘IRanges’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/IRanges’
ERROR: dependencies ‘BiocGenerics’, ‘IRanges’, ‘S4Vectors’ are not available for package ‘AnnotationDbi’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/AnnotationDbi’
ERROR: dependency ‘AnnotationDbi’ is not available for package ‘DO.db’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/DO.db’
ERROR: dependency ‘AnnotationDbi’ is not available for package ‘GO.db’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/GO.db’
ERROR: dependencies ‘AnnotationDbi’, ‘GO.db’ are not available for package ‘GOSemSim’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/GOSemSim’
ERROR: dependencies ‘AnnotationDbi’, ‘DO.db’, ‘GOSemSim’, ‘igraph’, ‘S4Vectors’ are not available for package ‘DOSE’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/DOSE’
ERROR: dependencies ‘DOSE’, ‘AnnotationDbi’, ‘GO.db’, ‘GOSemSim’ are not available for package ‘clusterProfiler’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/clusterProfiler’
如果仅仅运行这个代码
source("https://bioconductor.org/biocLite.R")
biocLite()
Error : unable to load R code in package ‘BiocGenerics’
ERROR: lazy loading failed for package ‘BiocGenerics’
- removing ‘/home/shipeng/opt/biosoft/R/bioconductor/BiocGenerics’
ERROR: dependency ‘BiocGenerics’ is not available for package ‘S4Vectors’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/S4Vectors’
ERROR: dependencies ‘BiocGenerics’, ‘S4Vectors’ are not available for package ‘IRanges’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/IRanges’
ERROR: dependencies ‘BiocGenerics’, ‘IRanges’, ‘S4Vectors’ are not available for package ‘AnnotationDbi’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/AnnotationDbi’
追根溯源就是第一个‘BiocGenerics’没有安装成功
那我就来单独安装
source("https://bioconductor.org/biocLite.R")
biocLite('BiocGenerics')
报错信息如下:
** preparing package for lazy loading
Creating a new generic function for ‘append’ in package ‘BiocGenerics’
Creating a new generic function for ‘as.data.frame’ in package ‘BiocGenerics’
Creating a new generic function for ‘cbind’ in package ‘BiocGenerics’
Error : identical(as.call(parse(text = old_code)[[1L]]), body[[7L]][[3L]]) is not TRUE
Error in apply_hotfix73465(getGeneric("cbind")) :
hotfix failed for generic function cbind()
Error : unable to load R code in package ‘BiocGenerics’
ERROR: lazy loading failed for package ‘BiocGenerics’
- removing ‘/home/shipeng/opt/biosoft/R/bioconductor/BiocGenerics’
实际上如果biocLite('BiocGenerics')装不上,那么内部缺少的依赖包不能通过biocLite('xxx')这种形式安装
在R语言中执行
sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] BiocInstaller_1.28.0 ggpubr_0.1.5 magrittr_1.5 ggplot2_2.2.1
[5] survival_2.41-3 dplyr_0.7.4 bindrcpp_0.2
loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 compiler_3.4.2 plyr_1.8.4 bindr_0.1 tools_3.4.2
[6] tibble_1.3.4 gtable_0.2.0 nlme_3.1-131 lattice_0.20-35 pkgconfig_2.0.1
[11] rlang_0.1.2 Matrix_1.2-11 psych_1.7.8 yaml_2.1.14 knitr_1.17
[16] grid_3.4.2 glue_1.2.0 R6_2.2.2 foreign_0.8-69 scales_0.5.0
[21] splines_3.4.2 assertthat_0.2.0 mnormt_1.5-5 colorspace_1.3-2 lazyeval_0.2.1
[26] munsell_0.4.3
也看不出什么名堂
google发现有人在bioconduct社区提问了相同的问题:
https://support.bioconductor.org/p/101833/
给出来三种解决方法:
第一,说尝试打开一个新的R session可以解决问题
R --vanilla
照做后发现不能解决问题
有人在评论里面说
Glad that installing R 3.4.2 Patched solved the problem
但是这个版本我下载configure会报错(实际上是我不会编译R)就放弃了
我还看到有人说,
sudo apt-get install r-bioc-biocgenerics
这个命令可以解决问题
照做后显示我安装成功
(Reading database ... 185900 files and directories currently installed.)
Preparing to unpack .../r-bioc-biocgenerics_0.22.1-1ubuntu1_all.deb ...
Unpacking r-bioc-biocgenerics (0.22.1-1ubuntu1) ...
Setting up r-bioc-biocgenerics (0.22.1-1ubuntu1) ...
这时候我感到很高兴再来安装Y叔的包
source("https://bioconductor.org/biocLite.R")
biocLite('clusterProfiler')
又报错:
installing to /home/shipeng/opt/biosoft/R/bioconductor/S4Vectors/libs
** R
** inst
** preparing package for lazy loading
Error : package ‘BiocGenerics’ 0.22.1 was found, but >= 0.23.3 is required by ‘S4Vectors’
ERROR: lazy loading failed for package ‘S4Vectors’
- removing ‘/home/shipeng/opt/biosoft/R/bioconductor/S4Vectors’
提示我安装的版本不够高
好的,现在我的问题可能就是
安装版本高一点的R包,但是默认的biocLIte()是不行的
我查到可以通过github来安装,并且有两种方式
第一种方式需要知道包在github的名字,不是很方便
install.packages("devtools")
library(devtools)
install_github("xxx")
第二种方式方便一点
install.packages("githubinstall")
报错
ERROR: configuration failed for package ‘curl’
- removing ‘/home/shipeng/opt/biosoft/R/bioconductor/curl’
Warning in install.packages :
installation of package ‘curl’ had non-zero exit status
ERROR: dependency ‘curl’ is not available for package ‘githubinstall’ - removing ‘/home/shipeng/opt/biosoft/R/bioconductor/githubinstall’
提示我缺少curl,那我就装一个
install.packages("curl")
报错
ERROR: configuration failed for package ‘curl’
- removing ‘/home/shipeng/opt/biosoft/R/bioconductor/curl’
Warning in install.packages :
installation of package ‘curl’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp0YZPFO/downloaded_packages’
还是没能解决,所以安装包的时候出现的问题,不能用R本身来解决!需要走其他的途径
网上说这个可以解决问题
sudo apt-get install libcurl4-openssl-dev
安装完事后我又试了一下
install.packages("githubinstall")
安装成功,那我就安装BiocGenerics试试
library(githubinstall)
githubinstall('BiocGenerics')
Select a number or, hit 0 to cancel.
1: Bioconductor/BiocGenerics S4 generic functions for Bioconductor
2: lshep/BiocGenerics alpha testing github
3: nturaga/BiocGenerics test
4: schifferl/BiocGenerics
试了第1个,第二个都失败
选择第三个后
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
- DONE (BiocGenerics)
成功!!!,我有开始安装Y叔的包
source("https://bioconductor.org/biocLite.R")
biocLite('clusterProfiler')
installing to /home/shipeng/opt/biosoft/R/bioconductor/S4Vectors/libs
** R
** inst
** preparing package for lazy loading
Error : package ‘BiocGenerics’ 0.23.0 was found, but >= 0.23.3 is required by ‘S4Vectors’
版本还是不够,这回真的没辙了
而使用biocLite()安装的报错信息我看不懂
Error : identical(as.call(parse(text = old_code)[[1L]]), body[[7L]][[3L]]) is not TRUE
Error in apply_hotfix73465(getGeneric("cbind")) :
hotfix failed for generic function cbind()
问了Y叔,给了我一个帖子无痛更新R包
rvcheck::update_all()
最后发现没有用
所以我来尝试一下帖子里说的安装R version 3.4.2 Patched
下载地址:
https://stat.ethz.ch/R/daily/
./configure
报错
error: --with-readline=yes (default) and headers/libs are not available
上网查找
https://stackoverflow.com/questions/20752307/error-in-install-previous-versions-of-r-on-ubuntu
这里提供解决方案
sudo apt-get install xorg-dev
https://cran.r-project.org/doc/manuals/R-admin.html#Essential-programs-and-libraries
这个文档给出详细的解释
Unless you do not want to view graphs on-screen (or use macOS) you need ‘X11’ installed, including its headers and client libraries. For recent Fedora/RedHat distributions it means (at least) RPMs ‘libX11’, ‘libX11-devel’, ‘libXt’ and ‘libXt-devel’. On Debian/Ubuntu we recommend the meta-package ‘xorg-dev’. If you really do not want these you will need to explicitly configure R without X11, using --with-x=no.
运行后提示:
R is now configured for x86_64-pc-linux-gnu
configure: WARNING: you cannot build info or HTML versions of the R manuals
configure: WARNING: you cannot build PDF versions of the R manuals
configure: WARNING: you cannot build PDF versions of vignettes and help pages
启动R
sudo R
R version 3.4.2 Patched (2017-11-05 r73673) -- "Short Summer"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
好了应该是按照成功了
尝试安装BiocGenerics
source("https://bioconductor.org/biocLite.R")
biocLite('BiocGenerics')
最终安装成功
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
- DONE (BiocGenerics)
可是我现在启动不了Rstudio
ERROR Unable to find libR.so in expected locations within R Home direc
把libR.so找到,复制指定目录下,最后发现rstudio成功,但是在rstudio所有R还是以前的版本
更改各种设置都不行,系统里面有两个R,删除掉其中一个
重新安装r
tar -xf R-patched_2017-11-05.tar.gz
sudo apt-get build-dep r-base-dev
./configure --enable-R-shlib=yes
make
make check
sudo make install
没有任何报错!!!
https://bookdown.org/yihui/r-ninja/setup.html#r
谢益辉说的这个无敌命令一次性解决依赖问题
sudo apt-get build-dep r-base-dev
在终端启动R
source("https://bioconductor.org/biocLite.R")
options(BioC_mirror="http://mirrors.ustc.edu.cn/bioc/")
biocLite('clusterProfiler')
报错
说没有装上igraph
apt-get install -y r-cran-igraph
报错
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
加上root权限:
sudo apt-get install -y r-cran-igraph
安装完了之后,在r里面无法library
ibrary(igragh)
使用
install.packages("igraph")
安装成功
再来安装Y叔的包
DOSE包安装失败
安装DOSE包
devtools::install_github("GuangchuangYu/DOSE")
报错
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/shipeng/opt/biosoft/R/bioconductor/stringi/libs/stringi.so':
libicui18n.so.57: cannot open shared object file: No such file or directory
安装
install.packages("stringi")
安装
biocLite('DOSE')
成功
biocLite('clusterProfiler')
成功!!!
测试数据:
biocLite("ggridges")
require(clusterProfiler)
data(geneList)
x <- gseKEGG(geneList)
ridgeplot(x,showCategory = 60)
出图如下:这图出的不容易!!!!!
mark