[Share Experiences] Linux 下非 root 用户 Conda 安装生物信息 R 软件包 MetaboAnalystR 演示
Tofloor
poster avatar
littlebat
deepin
2022-07-06 16:35
Author

一、安装方法概览 二、安装步骤
1、Conda 和 R 环境安装
在上一篇安装 CellMix 的日记中已经详细介绍,这里不再赘述。参见: https://www.learndiary.com/2022/05/linux-conda-cellmix/ ,这篇日记中还有一些 R 包安装的知识点小结和一些有用的参考网址。

2、在 Conda 中安装依赖包

conda install -c conda-forge r-stringi r-curl r-cairo libnetcdf  # r-stringi 是因为网络原因可能在 R 环境下无法安装成功 stringi,r-curl 是 R 中安装 curl 包缺少 libcurl,r-cario 是 R 中安装 Cario 包缺少头部文件,libnetcdf 安装 R 包 ncdf4 需要的依赖

3、安装专门的生物信息软件管理器及依赖包

R # 进入 R 环境

在 R 环境下执行下列命令:

setRepositories() # 设置 R 包仓库,把1~8个仓库全选上
install.packages("BiocManager") #安装生物信息包管理器

这时会让选择CRAN镜像,我这里选“20: China (Guangzhou) [https]”,即输入20回车即可。

BiocManager::install("remotes") # github 在线安装需要

这时会询问是否更新旧的 'Cario'、'stringi'包,这时选不更新 n,后面有这样的询问同样选 n
Update all/some/none? [a/s/n]: n

这时会询问是否更新软件包,这里直接回车略过不更新。
然后,会提示安装147个软件包,后面还会警告包"locfit"找不到,如下:

Installing 147 packages: lattice, Matrix, MASS, survival, Biobase, BiocGenerics, rlang, Rcpp, codetools, ProtGenerics, iterators, foreach, doParallel, plyr, XML, zlibbioc, preprocessCore, affyio, utf8, crayon, cli, colorspace, vctrs, pkgconfig, pillar, magrittr, fansi, ellipsis, viridisLite, RColorBrewer, R6, munsell, lifecycle, labeling, farver, nlme, withr, tibble, scales, mgcv, isoband, gtable, glue, digest, ggplot2, limma, affy, S4Vectors, Rhdf5lib, ncdf4, later, fastmap, base64enc, lazyeval, jsonlite, htmltools, purrr, tidyselect, generics, cpp11, dplyr, yaml, sys, askpass, openssl, mime, bitops, formatR, futile.options, lambda.r, BH, snow, futile.logger, stringr, parallelly, listenv, globals, future, SQUAREM, numDeriv, progressr, future.apply, lava, KernSmooth, prodlim, class, nnet, rpart, timeDate, tidyr, lubridate, ipred, hardhat, gower, data.table, proxy, RcppParallel, cachem, bit, scrime, multtest, mzID, MALDIquant, pcaMethods, impute, vsn, IRanges, BiocParallel, mzR, promises, crosstalk, htmlwidgets, httr, caTools, gtools, fastmatch, gridExtra, reshape2, recipes, pROC, ModelMetrics, e1071, stringfish, RApiSerialize, prettyunits, hms, plogr, memoise, DBI, blob, bit64, graph, siggenes, MSnbase, plotly, igraph, gplots, glasso, fgsea, edgeR, crmn, caret, qs, Rserve, progress, RSQLite, RBGL
Warning: dependency ‘locfit’ is not available

这里我们不干预,让它自动完成安装。
上述命令长时间运行完成后,会报告依赖“edgeR”找不到。如下:

这里先安装上 locfit,命令如下:

这里会询问是否更新软件包,这里直接回车略过不更新。
然后会自动开始安装缺失的依赖包,信息如下:
Installing 1 packages: edgeR

显示如下:5、设置环境变量

内容如下:

如果没有设置环境变量,在 R 环境下执行下列命令会出现错误:

> mSet 

6、sessionInfo

在不同的系统环境下,以下的输出结果或有少许差异。

> sessionInfo()

R version 4.0.2 (2020-06-22)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Deepin 20.6

Matrix products: defaultlocale:
[1] LC_CTYPE=zh_CN.UTF-8 LC_NUMERIC=C
[3] LC_TIME=zh_CN.UTF-8 LC_COLLATE=zh_CN.UTF-8
[5] LC_MONETARY=zh_CN.UTF-8 LC_MESSAGES=zh_CN.UTF-8
[7] LC_PAPER=zh_CN.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=zh_CN.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:loaded via a namespace (and not attached):
[1] nlme_3.1-158 bitops_1.0-7 lubridate_1.8.0
[4] bit64_4.0.5 httr_1.4.3 RColorBrewer_1.1-3
[7] tools_4.0.2 utf8_1.2.2 R6_2.5.1
[10] rpart_4.1.16 KernSmooth_2.23-20 lazyeval_0.2.2
[13] DBI_1.1.3 BiocGenerics_0.36.1 colorspace_2.1-0
[16] nnet_7.3-17 withr_2.5.0 tidyselect_1.1.2
[19] gridExtra_2.3 bit_4.0.4 compiler_4.0.2
[22] cli_3.3.0 Biobase_2.50.0 Cairo_1.5-15
[25] plotly_4.10.0 stringfish_0.15.7 caTools_1.18.2
[28] scales_1.2.0 stringr_1.4.0 digest_0.6.29
[31] siggenes_1.64.0 htmltools_0.5.2 pkgconfig_2.0.3
[34] parallelly_1.32.0 scrime_1.3.5 fastmap_1.1.0
[37] limma_3.46.0 htmlwidgets_1.5.4 rlang_1.0.3
[40] RSQLite_2.2.14 impute_1.64.0 generics_0.1.2
[43] RApiSerialize_0.1.0 jsonlite_1.8.0 crmn_0.0.21
[46] BiocParallel_1.24.1 gtools_3.9.2.2 ModelMetrics_1.2.2.2
[49] dplyr_1.0.9 magrittr_2.0.3 Matrix_1.4-2
[52] Rcpp_1.0.8.3 munsell_0.5.0 fansi_1.0.3
[55] lifecycle_1.0.1 pROC_1.18.0 stringi_1.5.3
[58] edgeR_3.32.1 MASS_7.3-57 gplots_3.1.3
[61] plyr_1.8.7 recipes_0.2.0 grid_4.0.2
[64] blob_1.2.3 parallel_4.0.2 listenv_0.8.0
[67] crayon_1.5.1 lattice_0.20-45 splines_4.0.2
[70] multtest_2.46.0 locfit_1.5-9.4 pillar_1.7.0
[73] fgsea_1.16.0 igraph_1.3.2 reshape2_1.4.4
[76] future.apply_1.9.0 codetools_0.2-18 stats4_4.0.2
[79] fastmatch_1.1-3 glue_1.6.2 pcaMethods_1.82.0
[82] data.table_1.14.2 RcppParallel_5.1.5 vctrs_0.4.1
[85] foreach_1.5.2 tidyr_1.2.0 gtable_0.3.0
[88] purrr_0.3.4 qs_0.25.3 future_1.26.1
[91] cachem_1.0.6 ggplot2_3.3.6 gower_1.0.0
[94] prodlim_2019.11.13 viridisLite_0.4.0 class_7.3-20
[97] survival_3.3-1 glasso_1.11 timeDate_3043.103
[100] tibble_3.1.7 iterators_1.0.14 memoise_2.0.1
[103] hardhat_1.1.0 lava_1.6.10 globals_0.15.1
[106] ellipsis_0.3.2 caret_6.0-92 ipred_0.9-13

三、注意事项

1、各个系统的环境不同,可能需要安装的软件包也会有所差异,对于缺失的依赖包,如果 BiocManager::install() 安装不上,多半是某软件的版本不适合于此 R 版本,可以搜索一下符合要求的版本。然后,可以尝试以 install.packages(pkgs = "http://web.cbio.uct.ac.za/renaud/CRAN/src/contrib/CellMix_1.6.2.tar.gz", type = "source") 或 install.packages("/tmp/CellMix_1.6.2.tar.gz", repos=NULL, type="source") 的方法安装。

2、因为此文使用的安装方法不是官方网站使用的方法,如果哪位朋友运用此方法安装,在使用过程中碰到任何问题可以反馈给我。

四、参考网址

3、Linux系统conda虚拟环境添加环境变量 https://blog.csdn.net/u014611178/article/details/107833929
4、Install R https://docs.rstudio.com/resources/install-r/

Reply Favorite View the author
All Replies
jjcui8595
deepin
2022-07-06 16:47
#1

感谢分享

Reply View the author
sukanka
deepin
2022-07-07 03:43
#2

支持,已经为 arch 打包了

Reply View the author
sukanka
deepin
2022-07-07 09:05
#3

我为 CellMix 写了个 patch, 让他可以在 R4.2.1 上面使用了。

= 1.20.0), biomaRt, knitr
diff --git a/NAMESPACE b/NAMESPACE
index 20fff59..10f0d8b 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -261,7 +261,7 @@ exportMethods(subset)
 exportMethods(summary)
 import(AnnotationDbi)
 import(Biobase)
-import(BiocInstaller)
+import(BiocManager)
 import(DBI)
 import(GSEABase)
 import(NMF)
diff --git a/R/utils.R b/R/utils.R
index eb78f62..1a2ee1c 100644
--- a/R/utils.R
+++ b/R/utils.R
@@ -389,7 +389,7 @@ askUser <- function (msg, allowed = c("y", "n"), idefault = "n", default = "n",
 #' @return \code{TRUE} if the package was successfully loaded/found (installed),
 #' \code{FALSE} otherwise.
 #'
-#' @import BiocInstaller
+#' @import BiocManager
 #' @keywords internal
 uq_requirePackage <- function(package, lib=NULL, ..., load=TRUE, msg=NULL, quiet=TRUE, prependLF=FALSE
         , ptype=c('CRAN-like', 'BioC', 'BioCSoft', 'BioCann')){
@@ -443,7 +443,7 @@ uq_requirePackage <- function(package, lib=NULL, ..., load=TRUE, msg=NULL, quiet
     if( install_type == 'CRAN' ){
         pkginstall <- install.packages
     }else{ # Bioconductor
-        if( !reqpkg('BiocInstaller') ){ # get biocLite from bioconductor.org
+        if( !reqpkg('BiocManager') ){ # get biocLite from bioconductor.org
             # use internal sourceURL to avoid issues with proxies
             sourceURL("http://www.bioconductor.org/biocLite.R")
         }
diff --git a/README.md b/README.md
index 3ea6948..9258045 100755
--- a/README.md
+++ b/README.md
@@ -13,13 +13,13 @@ See Algorithms for a list of all available d
 ## Installation
 ```R
 # install biocLite if not already there
-if( !require(BiocInstaller) ){
+if( !require(BiocManager) ){
 	# enable Bioconductor repositories
 	# -> add Bioc-software
 	setRepositories()

-	install.packages('BiocInstaller')
-	library(BiocInstaller)
+	install.packages('BiocManager')
+	library(BiocManager)
 }
 # or alternatively do:
 # source('http://www.bioconductor.org/biocLite.R')
diff --git a/vignettes/CellMix-unitTests.Rnw b/vignettes/CellMix-unitTests.Rnw
index 441e244..7855e76 100644
--- a/vignettes/CellMix-unitTests.Rnw
+++ b/vignettes/CellMix-unitTests.Rnw
@@ -109,7 +109,7 @@ Total execution time
     stringr~0.6.2, synchronicity~1.1.0
   \item Loaded via a namespace (and not attached):
     AnnotationForge~1.2.1, beeswarm~0.1.5, bibtex~0.3-5,
-    BiocInstaller~1.10.1, codetools~0.2-8, colorspace~1.2-2,
+    BiocManager~1.10.1, codetools~0.2-8, colorspace~1.2-2,
     dichromat~2.0-0, doParallel~1.0.1, foreach~1.4.0,
     genefilter~1.42.0, ggplot2~0.9.3.1, gridBase~0.4-6, gtable~0.1.2,
     gtools~2.7.1, IRanges~1.18.1, iterators~1.0.6, labeling~0.1,
diff --git a/vignettes/Introduction.Rnw b/vignettes/Introduction.Rnw
index d75caed..69e9c7d 100644
--- a/vignettes/Introduction.Rnw
+++ b/vignettes/Introduction.Rnw
@@ -130,12 +130,12 @@ after the user gives permission to do so.}:

 <>=
 # install biocLite
-install.packages('BiocInstaller')
+install.packages('BiocManager')
 # or alternatively do:
 # source('http://www.bioconductor.org/biocLite.R')

 # install GEOquery (NB: might ask you to update some of your packages)
-library(BiocInstaller)
+library(BiocManager)
 biocLite('GEOquery')
 @

diff --git a/vignettes/SampleAnalysis.Rnw b/vignettes/SampleAnalysis.Rnw
index f18a351..4d31d6a 100644
--- a/vignettes/SampleAnalysis.Rnw
+++ b/vignettes/SampleAnalysis.Rnw
@@ -121,13 +121,13 @@ repository, using standard package installation commands:
 <>=

 # install biocLite if not already there
-if( !require(BiocInstaller) ){
+if( !require(BiocManager) ){
 	# enable Bioconductor repositories
 	# -> add Bioc-software
 	setRepositories()

-	install.packages('BiocInstaller')
-	library(BiocInstaller)
+	install.packages('BiocManager')
+	library(BiocManager)
 }
 # or alternatively do:
 # source('http://www.bioconductor.org/biocLite.R')

Reply View the author