1 ## Mirrors: uncomment the following and change to your favorite CRAN mirror
2 ## if you don't want to use the default (cran.fhcrc.org, Seattle, USA).
3 ## options("repos" = c(CRAN="http://cran.fhcrc.org"))
5 ## Mirrors: uncomment the following and change to your favorite Bioconductor
6 ## mirror, if you don't want to use the default (www.bioconductor.org,
8 ## options("BioC_mirror" = "http://www.bioconductor.org")
13 biocVers <- tryCatch({
14 BiocInstaller::biocVersion() # recent BiocInstaller
15 }, error=function(...) { # no / older BiocInstaller
16 BioC_version_associated_with_R_version <-
17 get(".BioC_version_associated_with_R_version",
18 envir=asNamespace("tools"), inherits=FALSE)
19 if (is.function(BioC_version_associated_with_R_version))
20 BioC_version_associated_with_R_version()
21 else # numeric_version
22 BioC_version_associated_with_R_version
26 ## legacy; no need to change "3.0" ever
27 ## coordinate this message with .onAttach
28 txt <- strwrap("A new version of Bioconductor is available
29 after installing the most recent version of R; see
30 http://bioconductor.org/install", exdent=2)
31 message(paste(txt, collapse="\n"))
32 } else if ("package:BiocInstaller" %in% search()) {
33 ## messages even if already attached
34 tryCatch(BiocInstaller:::.onAttach(), error=function(...) NULL)
37 if (vers > "2.13" && biocVers > "2.8") {
39 if (exists("biocLite", .GlobalEnv, inherits=FALSE)) {
40 txt <- strwrap("There is an outdated biocLite() function in the
41 global environment; run 'rm(biocLite)' and try again.")
42 stop("\n", paste(txt, collapse="\n"))
45 if (!suppressWarnings(require("BiocInstaller", quietly=TRUE))) {
47 p <- file.path(Sys.getenv("HOME"), ".R", "repositories")
49 a <- tools:::.read_repositories(p)
50 if (!"BioCsoft" %in% rownames(a))
54 p <- file.path(R.home("etc"), "repositories")
55 a <- tools:::.read_repositories(p)
57 if (!"package:utils" %in% search()) {
58 url <- "http://bioconductor.org/biocLite.R"
59 txt <- sprintf("use 'source(\"%s\")' to update 'BiocInstaller'
60 after 'utils' package is attached",
62 message(paste(strwrap(txt), collapse="\n "))
64 ## add a conditional for Bioc releases occuring WITHIN
65 ## a single R minor version. This is so that a user with a
66 ## version of R (whose etc/repositories file references the
67 ## no-longer-latest URL) and without BiocInstaller
68 ## will be pointed to the most recent repository suitable
69 ## for their version of R
70 if (vers == "3.2.0") {
71 a["BioCsoft", "URL"] <- sub(as.character(biocVers), "3.1",
73 } else if (vers == "3.1.1") {
74 ## R-3.1.1's etc/repositories file at the time of the release
75 ## of Bioc 3.0 pointed to the 2.14 repository, but we want
76 ## new installations to access the 3.0 repository
77 a["BioCsoft", "URL"] <- sub(as.character(biocVers), "3.0",
79 } else if (vers == "3.1.0") {
80 ## R-devel points to 2.14 repository
81 a["BioCsoft", "URL"] <- sub(as.character(biocVers), "2.14",
83 } else if (vers >= "2.15" && vers < "2.16") {
84 a["BioCsoft", "URL"] <- sub(as.character(biocVers), "2.11",
86 biocVers <- numeric_version("2.11")
88 install.packages("BiocInstaller", repos=a["BioCsoft", "URL"])
89 if (!suppressWarnings(require("BiocInstaller",
91 url0 <- "http://www.bioconductor.org/packages"
92 url <- sprintf("%s/%s/bioc",
93 url0, as.character(biocVers))
94 txt0 <- "'biocLite.R' failed to install 'BiocInstaller',
95 use 'install.packages(\"%s\", repos=\"%s\")'"
96 txt <- sprintf(txt0, "BiocInstaller", url)
97 message(paste(strwrap(txt), collapse="\n "))
101 ## BiocInstaller version 1.16.0-1.18.1 do not
102 ## automatically update when type=="source"; notify users
103 ## when they have updated R over their old libraries
104 installerVersion <- utils::packageVersion("BiocInstaller")
105 test0 <- (vers > "3.1.2") &&
106 !identical(getOption("pkgType"), "source") &&
107 (installerVersion >= "1.16.0") &&
108 (installerVersion <= "1.16.4")
110 if (installerVersion < "1.16.4") {
111 txt <- "Update BiocInstaller with
112 oldPkgType=options(pkgType=\"source\");
113 biocLite(\"BiocInstaller\"); options(oldPkgType)"
114 message(paste(strwrap(txt, exdent=2), collapse="\n"))
117 txt <- sprintf("BiocInstaller version %s is too old for
118 R version %s; remove.packages(\"BiocInstaller\"),
120 source(\"http://bioconductor.org/biocLite.R\")",
122 warning(paste(strwrap(txt, exdent=2), collapse="\n"))
127 source("http://bioconductor.org/getBioC.R")
129 function(pkgs, groupName="lite", ...)
132 biocinstall(groupName=groupName, ...)
134 biocinstall(pkgs=pkgs, groupName=groupName, ...)