R 系列

您所在的位置:网站首页 淘宝内下载的安装包 R 系列

R 系列

2024-04-12 05:01| 来源: 网络整理| 查看: 265

浏览 3320 扫码 分享 2022-11-07 18:45:36 biocLite 使用BiocManager 安装与使用1. 镜像,镜像,镜像!2. 安装 BiocManager 包3. 安装 Bioconductor 的 R 包4. 查看 Bioconductor 的版本5. 更新所有已经安装的 R 包6. 旧和意外版本的 R 包7. 适用的 R 包安装旧版本的 Bioconductor R 包R≥3.5,Bioconductor≥3.7R install.packages("BiocManager")Warning message:package ‘BiocManager’ is not available (for R version 3.4.3) >

这时候,Bioconductor 推荐使用以下命令安装相应的 R 包。

source("https://bioconductor.org/biocLite.R")BiocInstaller::biocLite(c("GenomicFeatures", "AnnotationDbi"))

安装新版本的 Bioconductor R 包

Bioconductor 是与特定版本的 R 绑定的,正常来说当 Bioconductor 的包都来自同一版本时,它们的效果最佳。

Bioconductor versions are associated with specific R versions, as summarized here. Attempting to install a version of Bioconductor that is not supported by the version of R in use leads to an error; using the most recent version of Bioconductor may require installing a new version of R.

From:https://cran.r-project.org/web/packages/BiocManager/vignettes/BiocManager.html

所以,当有些 R 包是基于高版本的 Bioconductor 开发的,在低版本的 Bioconductor/R 中直接执行 BiocManager::install("package"),安装得到的 package 版本默认是与当前版本 Bioconductor/R 相匹配的,而并非是最新的版本。以 DiffBind 包为例,DiffBind==3.4.0 是基于 Bioconductor==3.14(对应 R-4.1)开发的;我们在 Bioconductor==3.13(对应 R-4.0)中执行 BiocManager::install("DiffBind"),默认安装的是 DiffBind==3.0.15!

1. 源码方式安装

如果想要在 Bioconductor==3.13(对应 R-4.0)中安装 DiffBind==3.4.0,可以直接通过源码包的方式安装:

> packageurl install.packages(packageurl, repos=NULL, type="source")

2. BiocInstaller 安装

下面,我们以在 R-3.4(Bioconductor==3.6)中安装最新版本的 clusterProfiler 为例。

在 Aanconda2 环境 R==3.4.3 中安装 clusterProfiler,发现 package ‘clusterProfile’ is not available (for R version 3.4.3)。

> source("https://bioconductor.org/biocLite.R")Bioconductor version 3.6 (BiocInstaller 1.28.0), ?biocLite for helpA new version of Bioconductor is available after installing the most recent version of R; see http://bioconductor.org/install> biocLite("clusterProfile")BioC_mirror: https://bioconductor.orgUsing Bioconductor 3.6 (BiocInstaller 1.28.0), R 3.4.3 (2017-11-30).Installing package(s) ‘clusterProfile’Old packages: 'ade4', 'ape', 'backports', 'caret', ......Update all/some/none? [a/s/n]: nWarning message:package ‘clusterProfile’ is not available (for R version 3.4.3)

使用 BiocInstaller 安装 clusterProfiler:

> source("https://bioconductor.org/biocLite.R")Bioconductor version 3.6 (BiocInstaller 1.28.0), ?biocLite for helpA new version of Bioconductor is available after installing the most recent version of R; see http://bioconductor.org/install> BiocInstaller::biocLite("clusterProfiler")BioC_mirror: https://bioconductor.orgUsing Bioconductor 3.6 (BiocInstaller 1.28.0), R 3.4.3 (2017-11-30).Installing package(s) ‘clusterProfiler’trying URL 'https://bioconductor.org/packages/3.6/bioc/src/contrib/clusterProfiler_3.6.0.tar.gz'Content type 'application/x-gzip' length 4478098 bytes (4.3 MB)==================================================downloaded 4.3 MB* installing *source* package ‘clusterProfiler’ ...** R** data** 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* DONE (clusterProfiler)> packageVersion('clusterProfiler')[1] ‘3.6.0’

install.packages 一站式方案

用 install.packages 来安装 CRAN 和 Bioconductor 所有的包!这是来自于 Y 叔 2018-09-25 在公众号发表的《不用 biocLite 安装 Bioconductor 包》介绍的方法。这里截取部分内容介绍一下。

用 install.packages 来安装 CRAN 和 Bioconductor 所有的包,你要做的很简单,在 ~/.Rprofile 里加入以下两行内容。

options(BioC_mirror="https://mirrors.tuna.tsinghua.edu.cn/bioconductor")utils::setRepositories(ind=1:2)

第一行,使用国内的镜像,我这里用的是清华大学的,第二行,设定 install.packages 从 CRAN 和 Bioconductor 中搜索包,其实你还可以让它支持比如 R-Forge 以及各种第三方的仓库。

然后你就可以愉快地使用 install.packages 来安装 Bioconductor 包了。

安装体积比较大的 R 包

安装 CRAN 或者 Bioconductor 中一些体积比较大的 R 包,如果网络不太好,经常可能会出现包下载不完(Timeout of 60 seconds was reached),从而导致无法正常安装。参考 How do i set a timeout for utils::download.file() in R - Stack Overflow,增加 timeout 时长的同时使用国内的镜像进行加速:

getOption('timeout')# [1] 60options(timeout=100)

以上,就是 Bioconductor R 包安装和使用的全部内容,希望对大家有所帮助。

参考资料 omicsgene,《R 语言包安装方法,设置国内镜像加快安装速度》,OmicsClass 组学大讲堂问答社区Y 叔叔,《不用 biocLite 安装 Bioconductor 包》,”biobable”公众号

若有收获,就点个赞吧

0 人点赞

上一篇: 下一篇:


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3