-
Notifications
You must be signed in to change notification settings - Fork 6
/
packageInstaller.R
61 lines (55 loc) · 2.8 KB
/
packageInstaller.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
InstalledPackage <- function(package)
{
available <- suppressMessages(suppressWarnings(sapply(package, require, quietly = TRUE, character.only = TRUE, warn.conflicts = FALSE)))
missing <- package[!available]
if (length(missing) > 0) return(FALSE)
return(TRUE)
}
CRANChoosen <- function()
{
return(getOption("repos")["CRAN"] != "@CRAN@")
}
UsePackage <- function(package, defaultCRANmirror = "http://cran.us.r-project.org")
{
if(!InstalledPackage(package))
{
if(!CRANChoosen())
{
#chooseCRANmirror()
options(repos = c(CRAN = defaultCRANmirror))
}
suppressMessages(suppressWarnings(install.packages(package, repos = defaultCRANmirror)))
if(!InstalledPackage(package)) return(FALSE)
}
return(TRUE)
}
libraries = c("rgl","rglwidget","DT","getopt",
"calibrate","shinyRGL","htmltools",
"viridis","dendsort","shiny","shinyjs","gplots","knitr",
"reshape","RColorBrewer","rmarkdown","ggplot2","ggfortify",
"heatmaply","plotly","pheatmap")
for(library in libraries)
{
if(!UsePackage(library))
{
stop("Error!", library)
}
}
listOfBiocPackages = c("GEOquery","mixOmics","pd.clariom.s.rat","pd.mouse430.2","clariomsrattranscriptcluster.db",
"pd.mogene.2.0.st","mogene20sttranscriptcluster.db","pd.hg.u133.plus.2", "mouse4302.db",
"hgu133plus2.db","pd.hugene.2.0.st","hugene20sttranscriptcluster.db", "pd.hg.u133a",
"pd.clariom.s.human.ht","clariomshumanhttranscriptcluster.db","hgu133a.db",
"pd.clariom.s.human","clariomshumantranscriptcluster.db","pd.clariom.s.mouse.ht",
"clariomsmousehttranscriptcluster.db","pd.clariom.s.mouse","clariomsmousetranscriptcluster.db",
"hugene10sttranscriptcluster.db","pd.mogene.1.0.st.v1","mogene10sttranscriptcluster.db",
"pd.hg.u133a.2","hgu133a2.db","pd.huex.1.0.st.v2","huex10sttranscriptcluster.db",
"pd.hg.u219","hgu219.db","pd.mg.u74av2","mgu74av2.db","pd.mouse430a.2", "pd.hugene.1.0.st.v1",
"mouse430a2.db","pd.moe430a","moe430a.db","pd.hg.u95av2","hgu95av2.db","pd.hta.2.0",
"hta20transcriptcluster.db","pd.moex.1.0.st.v1","moex10sttranscriptcluster.db","pd.hg.u133b",
"hgu133b.db","pd.hugene.1.1.st.v1","hugene11sttranscriptcluster.db","pd.mogene.1.1.st.v1",
"mogene11sttranscriptcluster.db","pd.hugene.2.1.st","hugene21sttranscriptcluster.db","oligo","geneplotter","multtest","Biobase",
"GSVA","GSEABase","annotate","limma")
notInstalled = setdiff(listOfBiocPackages, rownames(installed.packages()))
if( length(notInstalled) ) {
BiocManager::install(notInstalled, update = FALSE, version = "3.8")
}