最近写了个内部用R包,里面有不少依赖包,一部分是CRAN的,一部分是Bioconductor上面的R包,于是把这些包分类后,按照生信技能树培训班时的代码写到了文档里面。主要涉及先检查R包是否安装,然后就是按照CRAN和Bioconductor各自R包安装方法进行安装。
options("repos"="https://mirrors.ustc.edu.cn/CRAN/")
if(!require("BiocManager")) install.packages("BiocManager",update = F,ask = F)
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
cran_packages=c("magrittr",
"dplyr",
"tibble",
"ggpubr",
"stringr",
"reshape2",
"psych",
"limma",
"circlize",
"grid",
"fmsb",
"survival",
"survminer",
"forestplot",
"pROC")
Bioconductor_packages=c("edgeR",
"org.Hs.eg.db",
"clusterProfiler",
"enrichplot",
"ComplexHeatmap")
# install packages in CRAN
for (pkg in cran_packages){
if (!require(pkg,character.only=T)){
install.packages(pkg,ask = F,update = F)
require(pkg,character.only=T)
}
}
# install packages in Bioconductor
for (pkg in Bioconductor_packages){
if (!require(pkg,character.only=T)) {
BiocManager::install(pkg,ask = F,update = F)
require(pkg,character.only=T)
}
}
# ignore all warnings, check if the packages could be libraried correctly.
for (pkg in c(Biocductor_packages,cran_packages)){
require(pkg,character.only=T)
}
# ReactomePA is too large
# if (!require(ReactomePA,character.only=T)) {BiocManager::install("ReactomePA",ask = F,update = F)
# require(ReactomePA,character.only=T)