查看原文
其他

生信平台搭建(八):R包的安装

王通 基因学苑 2023-08-18

安装完R和Rstudio之后,接下来很重要的工作就是安装R包以及bioconductor的包,由于Rstudio不能采用root账户登录,因此,需要在Linux的R中进行安装,这样R包会安装在根目录下,这样所有服务器里的用户都可以访问,也就是只需要安装一次,所有用户,均可使用。

设置镜像

由于R和bioconductor的主服务器都在国外,因此,设置镜像非常重要,这样安装包将从国内下载,尤其是bioconductor包,速度会有非常明显的差别。一些包安装不成功,就是因为镜像太慢,导致中途一些包无法下载完成。

#命令行直接敲R
$ R
> options(repos="https://mirror.lzu.edu.cn/CRAN/")
> options(BioC_mirror="http://mirrors.ustc.edu.cn/bioc/")

安装R包

镜像设置好了就可以开始安装了。需要的R包很多,不过R包之间有很强的依赖关系,所以,只需要安装一些大的流程包,就会一下在安装很多,例如bioconductor的27个workflow。

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
> BiocManager::install("rnaseqGene")

批量安装

当然如果你需要安装很多R包,一个个安装实在太麻烦了。这个时候可以将R代码写到一个文件中,例如命名为installR.R文件。

options(repos="https://mirror.lzu.edu.cn/CRAN/")
options(BioC_mirror="http://mirrors.ustc.edu.cn/bioc/")
library(BiocManager)
install.packages(c("ggplot2","WGCNA","vcd","cars"))
 BiocManager::install("RNAseq123")
 BiocManager::install("rnaseqGene")
 BiocManager::install("RnaSeqGeneEdgeRQL")
 BiocManager::install("EGSEA123")
 BiocManager::install("ExpressionNormalizationWorkflow")
 BiocManager::install("cytofWorkflow")
 BiocManager::install("simpleSingleCell")
 BiocManager::install("annotation")
 BiocManager::install("variants")
 BiocManager::install("TCGAWorkflow")
 BiocManager::install("recountWorkflow")
 BiocManager::install("highthroughputassays")
 BiocManager::install("proteomics")
 BiocManager::install("eQTL")
 BiocManager::install("chipseqDB")
 BiocManager::install("generegulation")
 BiocManager::install("methylationArrayAnalysis")
 BiocManager::install("arrays")
 BiocManager::install("BiocMetaWorkflow")
 BiocManager::install("liftOver")
 BiocManager::install("sequencing")

运行脚本,这其中可能有一些包无法安装成功,后续还需要自己重新安装。

R -f installR.R


---------- END ----------

(添加作者微信,请注明单位姓名)



您可能还会感兴趣的

R语言与生物信息(深圳站)开课了
上传数据,直接分析,1T内存服务器来了
手把手教你生信分析平台搭建专栏合集
生物信息重要资源站点合集
不会编程,如何进行批量操作
一个人全基因组完整数据分析脚本
一个细菌基因组完整分析脚本
如何在Linux下优雅的装X


您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存