├── R ├── biocVersion.R ├── biocUpdatePackages.R ├── getUpdateablePackages.R ├── utilities.R ├── package_groups.R ├── zzz.R ├── biocValid.R ├── useDevel.R ├── updateBiocInstallerPackage.R └── biocLite.R ├── tests └── BiocInstaller_unit_tests.R ├── NAMESPACE ├── DESCRIPTION ├── man ├── biocVersion.Rd ├── BiocUpgrade.Rd ├── biocinstallRepos.Rd ├── packageGroups.Rd ├── biocUpdatePackages.Rd ├── biocValid.Rd ├── biocLite.Rd └── useDevel.Rd ├── NEWS └── inst ├── unitTests ├── test_biocinstallRepos.R └── test_BiocUpgrade.R └── scripts └── biocLite.R /R/biocVersion.R: -------------------------------------------------------------------------------- 1 | biocVersion <- function() BIOC_VERSION 2 | -------------------------------------------------------------------------------- /tests/BiocInstaller_unit_tests.R: -------------------------------------------------------------------------------- 1 | BiocGenerics:::testPackage("BiocInstaller") -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | import("utils") 2 | 3 | export(biocLite, biocVersion, biocUpdatePackages, biocinstallRepos, 4 | useDevel, biocValid, monograph_group, RBioinf_group, 5 | biocases_group, all_group) 6 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: BiocInstaller 2 | Title: Install/Update Bioconductor and CRAN Packages 3 | Description: Installs/updates Bioconductor and CRAN packages 4 | Version: 1.14.3 5 | Author: Dan Tenenbaum and Biocore Team 6 | Maintainer: Bioconductor Package Maintainer 7 | biocViews: Software 8 | Depends: R (>= 3.1.0) 9 | Suggests: RUnit, BiocGenerics 10 | License: Artistic-2.0 11 | -------------------------------------------------------------------------------- /R/biocUpdatePackages.R: -------------------------------------------------------------------------------- 1 | biocUpdatePackages <- 2 | function(pkgs, dependencies = NA, repos = biocinstallRepos(), ...) 3 | { 4 | if (identical(dependencies, NA)) 5 | dependencies <- c("Depends", "Imports", "LinkingTo") 6 | avail <- available.packages(contriburl=contrib.url(repos)) 7 | deps <- avail[pkgs, dependencies, drop=FALSE] 8 | deps <- unlist(apply(deps, 1, utils:::.clean_up_dependencies)) 9 | deps <- unique(c(pkgs, deps)) 10 | deps <- deps[deps %in% rownames(avail)] 11 | update.packages(oldPkgs=deps, repos=repos, ...) 12 | } 13 | -------------------------------------------------------------------------------- /man/biocVersion.Rd: -------------------------------------------------------------------------------- 1 | \name{biocVersion} 2 | \alias{biocVersion} 3 | \title{Bioconductor version} 4 | \description{ 5 | 6 | This function reports the Bioconductor version in use, as determined 7 | by the BiocInstaller package. 8 | 9 | } 10 | \usage{ 11 | biocVersion() 12 | } 13 | 14 | \value{ 15 | \code{package_version} representing the Bioconductor version in use. 16 | } 17 | \seealso{ 18 | 19 | \code{\link{biocLite}} Installs/updates Bioconductor/CRAN packages. 20 | 21 | \code{\link{BiocUpgrade}} Upgrading to new versions. 22 | } 23 | \examples{ 24 | biocVersion() 25 | } 26 | \keyword{environment} 27 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | CHANGES IN VERSION 1.14.0 2 | ------------------------- 3 | 4 | NEW FEATURES 5 | 6 | o biocUpdatePackages updates installed packages and their 7 | dependencies. 8 | 9 | CHANGES IN VERSION 1.10.0 10 | ------------------------- 11 | 12 | NEW FEATURES 13 | 14 | o biocValid() checks that installed packages are consistent with 15 | those available via biocLite(). 16 | 17 | o biocVersion() returns the version of Bioconductor expected with 18 | this version of the BiocInstaller package. 19 | 20 | USER-VISIBLE CHANGES 21 | 22 | o biocLite() invoked with no arguments updates currently installed 23 | packages to their most-recent version. 24 | 25 | -------------------------------------------------------------------------------- /R/getUpdateablePackages.R: -------------------------------------------------------------------------------- 1 | filterPackagesToUpdate <- 2 | function(regexes, pkgs) 3 | { 4 | regex = paste(regexes, collapse="|") 5 | hits <- grep(regex, pkgs[,"Package"], invert=TRUE) 6 | pkgs[hits, , drop=FALSE] 7 | } 8 | 9 | getUpdatablePackages <- 10 | function(pkgs) 11 | { 12 | all <- file.access(pkgs[,"LibPath"], 2) 13 | nonUpdateable <- pkgs[all == -1, "Package"] 14 | updateable <- pkgs[all == 0, , drop=FALSE] 15 | if (length(nonUpdateable)) 16 | { 17 | pkgList <- paste(nonUpdateable, collapse="', '") 18 | fmt <- "installed directory not writable, cannot update packages '%s'" 19 | .warning(fmt, pkgList, call.=FALSE) 20 | } 21 | updateable 22 | } 23 | -------------------------------------------------------------------------------- /inst/unitTests/test_biocinstallRepos.R: -------------------------------------------------------------------------------- 1 | repos <- biocinstallRepos() 2 | 3 | test_biocinstallRepos_named_repositories <- function() 4 | { 5 | 6 | allOS <- c("BioCsoft", "CRAN", "BioCann", "BioCexp", "BioCextra") 7 | windowsOnly <- "CRANextra" 8 | 9 | checkTrue(all(allOS %in% names(repos))) 10 | if (.Platform$OS.type == "windows") 11 | { 12 | checkTrue(windowsOnly %in% names(repos)) 13 | } else { 14 | checkTrue(!windowsOnly %in% names(repos)) 15 | } 16 | 17 | } 18 | 19 | test_biocinstallRepos_noNA_repositories <- function() 20 | { 21 | checkTrue(!any(is.na(repos))) 22 | } 23 | 24 | test_biocinstallRepos_order <- function() 25 | { 26 | checkIdentical("BioCsoft", names(repos)[[1]]) 27 | } 28 | -------------------------------------------------------------------------------- /inst/unitTests/test_BiocUpgrade.R: -------------------------------------------------------------------------------- 1 | test_useDevel <- function() 2 | { 3 | if (!BiocInstaller:::IS_DOWNGRADEABLE) 4 | checkException(useDevel(FALSE), silent=TRUE) 5 | if (!BiocInstaller:::IS_UPGRADEABLE) { 6 | checkException(useDevel(), silent=TRUE) 7 | opts <- options(warn=2); on.exit(options(opts)) 8 | checkException(biocLite("BiocUpgrade")) 9 | } 10 | } 11 | 12 | test_getContribUrl_exist <- function() 13 | { 14 | fun <- BiocInstaller:::.getContribUrl 15 | 16 | vers <- BiocInstaller:::BIOC_VERSION 17 | checkTrue(grepl(vers, fun(vers))) 18 | if (BiocInstaller:::IS_UPGRADEABLE) { 19 | vers <- BiocInstaller:::UPGRADE_VERSION 20 | checkTrue(grepl(vers, fun(vers))) 21 | } 22 | if (BiocInstaller:::IS_DOWNGRADEABLE) { 23 | vers <- BiocInstaller:::DOWNGRADE_VERSION 24 | checkTrue(grepl(vers, fun(vers))) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /man/BiocUpgrade.Rd: -------------------------------------------------------------------------------- 1 | \name{BiocUpgrade} 2 | \alias{BiocUpgrade} 3 | \title{ 4 | 5 | Upgrade Bioconductor to the latest version available for this version 6 | of R 7 | 8 | } 9 | \description{ 10 | 11 | Downloads the latest version of the BiocInstaller package, 12 | and upgrades all currently installed packages to the latest 13 | repositories \strong{for this version of R}. 14 | 15 | To upgrade, use: \preformatted{ 16 | source("http://bioconductor.org/biocLite.R") 17 | biocLite("BiocUpgrade") 18 | } 19 | 20 | } 21 | 22 | \seealso{ 23 | \code{\link{biocLite}} Installs/updates Bioconductor/CRAN packages. 24 | 25 | \code{\link{chooseBioCmirror}} lets you choose from a list of all 26 | public Bioconductor mirror URLs. 27 | 28 | \code{\link{chooseCRANmirror}} lets you choose from a list of all 29 | public CRAN mirror URLs. 30 | 31 | \code{\link{biocinstallRepos}} returns the Bioconductor and CRAN 32 | repositories used by \code{biocLite}. 33 | 34 | \code{\link{install.packages}} installs the packages themselves. 35 | } 36 | \examples{ 37 | \dontrun{ 38 | source("http://bioconductor.org/biocLite.R") 39 | biocLite("BiocUpgrade") 40 | } 41 | } 42 | \keyword{environment} 43 | -------------------------------------------------------------------------------- /man/biocinstallRepos.Rd: -------------------------------------------------------------------------------- 1 | \name{biocinstallRepos} 2 | \alias{biocinstallRepos} 3 | \title{ 4 | 5 | Display current Bioconductor and CRAN repositories. 6 | 7 | } 8 | \description{ 9 | 10 | Displays the URLs of the repositories used by \code{\link{biocLite}} 11 | to install Bioconductor and CRAN packages. 12 | 13 | } 14 | \usage{ 15 | biocinstallRepos(siteRepos=character()) 16 | } 17 | \arguments{ 18 | \item{siteRepos}{\code{character()} representing an additional 19 | repository in which to look for packages to install. This 20 | repository will be prepended to the default repositories 21 | returned by the function.} 22 | 23 | } 24 | \value{ 25 | Named \code{character()} of repositories. 26 | } 27 | \seealso{ 28 | \code{\link{biocLite}} Installs/updates Bioconductor/CRAN packages. 29 | 30 | \code{\link{install.packages}} installs the packages themselves. 31 | 32 | \code{\link{chooseBioCmirror}} lets you choose from a list of all 33 | public Bioconductor mirror URLs. 34 | 35 | \code{\link{chooseCRANmirror}} lets you choose from a list of all 36 | public CRAN mirror URLs. 37 | } 38 | \examples{ 39 | biocinstallRepos() 40 | 41 | ## Choose mirrors 42 | \dontrun{ 43 | chooseCRANmirror() 44 | chooseBioCmirror() 45 | } 46 | } 47 | \keyword{environment} 48 | -------------------------------------------------------------------------------- /man/packageGroups.Rd: -------------------------------------------------------------------------------- 1 | \name{Package Groups} 2 | \alias{biocases_group} 3 | \alias{RBioinf_group} 4 | \alias{monograph_group} 5 | \alias{all_group} 6 | \title{ 7 | 8 | Convenience functions to return package names associated with Bioconductor publications. 9 | 10 | } 11 | \description{ 12 | 13 | Returns character vectors of packages associated with Bioconductor publications, 14 | which can then be passed to \code{\link{biocLite}()} 15 | 16 | } 17 | \usage{ 18 | monograph_group() 19 | RBioinf_group() 20 | biocases_group() 21 | all_group() 22 | } 23 | \value{ 24 | \code{character()} of package names. 25 | } 26 | \seealso{ 27 | \code{\link{biocLite}} Installs/updates Bioconductor/CRAN packages. 28 | 29 | \code{\link{biocinstallRepos}} returns the Bioconductor and CRAN 30 | repositories used by \code{biocLite}. 31 | 32 | \code{\link{install.packages}} installs the packages themselves. 33 | 34 | \code{\link{chooseBioCmirror}} lets you choose from a list of all 35 | public Bioconductor mirror URLs. 36 | 37 | \code{\link{chooseCRANmirror}} lets you choose from a list of all 38 | public CRAN mirror URLs. 39 | } 40 | \examples{ 41 | 42 | ## Get the names of packages used in the book 43 | ## "Bioconductor Case Studies": 44 | biocases_group() 45 | 46 | ## Get the names of packages used in the book 47 | ## "R Programming for Bioinformatics": 48 | RBioinf_group() 49 | 50 | ## Get the names of packages used in the monograph 51 | ## "Bioinformatics and Computational Biology Solutions 52 | ## Using R and Bioconductor": 53 | monograph_group() 54 | 55 | ## Get the names of all Bioconductor software packages 56 | all_group() 57 | } 58 | \keyword{environment} 59 | -------------------------------------------------------------------------------- /man/biocUpdatePackages.Rd: -------------------------------------------------------------------------------- 1 | \name{biocUpdatePackages} 2 | \alias{biocUpdatePackages} 3 | 4 | \title{ 5 | 6 | Update previously installed Bioconductor or CRAN packages and their 7 | dependencies. 8 | 9 | } 10 | \description{ 11 | 12 | Update previously installed Bioconductor and CRAN packages and their 13 | dependencies. Use \code{\link{biocLite}} to install new packages or to 14 | update all out-of-date packages. Upgrading to a new Bioconductor 15 | release requires additional steps; see 16 | \url{http://bioconductor.org/install}. 17 | 18 | } 19 | \usage{ 20 | biocUpdatePackages(pkgs, dependencies = NA, repos=biocinstallRepos(), ...) 21 | } 22 | %- maybe also 'usage' for other objects documented here. 23 | \arguments{ 24 | 25 | \item{pkgs}{\code{character()} of package names to install or update.} 26 | 27 | \item{dependencies}{\code{character()} describing out-of-date 28 | dependencies that are also updated. Defaults to \code{c("Depends", 29 | "Imports", "LinkingTo")} but can be a subset of \code{c("Depends", 30 | "Imports", "LinkingTo", "Suggests", "Enhances")}.} 31 | 32 | \item{repos}{\code{character()} of named repositories in which to look 33 | for package updates, in the style of \code{biocinstallRepos()}.} 34 | 35 | \item{\dots}{Additional arguments, passed to 36 | \code{\link{update.packages}}. For example, \code{ask=FALSE} to 37 | avoid prompts to update individual packages.} 38 | 39 | } 40 | 41 | \value{\sQuote{NULL}, invisibly.} 42 | 43 | \author{Martin Morgan \url{mtmorgan@fhcrc.org}} 44 | 45 | \seealso{\code{\link{biocLite}}} 46 | 47 | \examples{ 48 | \dontrun{ 49 | biocUpdatePackages("GenomicRanges", ask=FALSE) 50 | } 51 | } 52 | 53 | \keyword{environment} 54 | -------------------------------------------------------------------------------- /R/utilities.R: -------------------------------------------------------------------------------- 1 | .dQuote <- function(x) 2 | sprintf('"%s"', as.character(x)) 3 | 4 | .sQuote <- function(x) 5 | sprintf("'%s'", as.character(x)) 6 | 7 | .msg <- 8 | function(fmt, ..., width=getOption("width") * .9) 9 | ## Use this helper to format all error / warning / message text 10 | { 11 | txt <- strwrap(sprintf(fmt, ...), width=width, exdent=2) 12 | paste(txt, collapse="\n") 13 | } 14 | 15 | # use as BiocInstaller:::.opts$get() BiocInstaller:::.opts$set(TRUE) 16 | .opts = local({ 17 | debug <- FALSE 18 | list(get=function() debug, set=function(x) { 19 | old <- debug 20 | debug <<- x 21 | old 22 | }) 23 | }) 24 | 25 | .dbg <- 26 | function(...) 27 | { 28 | if (.opts$get()) { 29 | .msg(...) 30 | } 31 | } 32 | 33 | .message <- 34 | function(..., appendLF=TRUE) 35 | { 36 | message(.msg(...), appendLF=appendLF) 37 | } 38 | 39 | .stop <- 40 | function(..., call.=FALSE) 41 | { 42 | stop(.msg(...), call.=call.) 43 | } 44 | 45 | .warning <- 46 | function(..., call.=FALSE, immediate.=FALSE) 47 | { 48 | warning(.msg(...), call.=call., immediate.=immediate.) 49 | } 50 | 51 | .lowerRVersionString <- 52 | function(version=getRversion()) 53 | { 54 | if (0L == version$minor) { 55 | major <- version$major - 1L 56 | minor <- version$minor 57 | } else { 58 | major <- version$major 59 | minor <- version$minor - 1L 60 | } 61 | paste(major, minor, sep=".") 62 | } 63 | 64 | # bootstrap() should take care of unloading BiocInstaller 65 | # and reloading it. 66 | 67 | .stepAside <- 68 | function(biocBootstrapEnv, bootstrap) 69 | { 70 | environment(bootstrap) <- biocBootstrapEnv 71 | biocBootstrapEnv[["bootstrap"]] <- bootstrap 72 | attach(biocBootstrapEnv) 73 | on.exit(eval(bootstrap(), biocBootstrapEnv)) 74 | } 75 | -------------------------------------------------------------------------------- /R/package_groups.R: -------------------------------------------------------------------------------- 1 | monograph_group <- function() 2 | { 3 | warning("'arrayMagic' package is no longer available") 4 | c("affycomp", "affydata", "affypdnn", "affyPLM", "ALL", "ALLMLL", 5 | "AmpAffyExample", "annaffy", "AnnBuilder", "annotate", 6 | "arrayQuality", "beta7", "Biobase", "bioDist", "Biostrings", 7 | "cMAP", "CoCiteStats", "convert", "e1071", "edd", "estrogen", 8 | "exactRankTests", "facsDorit", "factDesign", "gbm", "gcrma", 9 | "geneplotter", "golubEsets", "GOstats", "gpls", "graph", 10 | "hexbin", "hgu133a", "hgu133atagcdf", "hgu133acdf", 11 | "hgu133bcdf", "hgu2beta7", "hgu95av2", "hgu95av2cdf", 12 | "hgu95av2probe", "hopach", "hsahomology", "hu6800cdf", 13 | "hu6800probe", "humanLLMappings", "ipred", "KEGG", "KEGGSOAP", 14 | "kidpack", "limma", "locfit", "LogitBoost", "matchprobes", 15 | "mclust", "mlbench", "MLInterfaces", "multtest", "pamr", 16 | "prada", "PROcess", "ProData", "randomForest", "rat2302", 17 | "RbcBook1", "RBGL", "RColorBrewer", "RCurl", "Rgraphviz", 18 | "rrcov", "simpleaffy", "sma", "SpikeInSubset", "SSOAP", 19 | "statmod", "vsn", "XML", "xtable", "YEAST", "yeastExpData") 20 | } 21 | 22 | lite_group <- function() 23 | { 24 | c("affy", "affydata", "affyPLM", "annaffy", "annotate", "Biobase", 25 | "biomaRt", "Biostrings", "DynDoc", "gcrma", "genefilter", 26 | "geneplotter", "hgu95av2.db", "limma", "marray", "multtest", 27 | "vsn", "xtable", "affyQCReport") 28 | } 29 | 30 | graph_group <- function() 31 | { 32 | c("graph", "Rgraphviz", "RBGL") 33 | } 34 | 35 | all_group <- function() 36 | { 37 | contribUrl <- paste(biocinstallRepos()['BioCsoft'], "src/contrib", 38 | sep="/") 39 | pkglist = available.packages(contribUrl) 40 | pkgs = rownames(pkglist) 41 | } 42 | 43 | RBioinf_group <- function() 44 | { 45 | c(lite_group(), graph_group(), "RBioinf", "BiocCaseStudies", 46 | "XML", "RCurl", "biomaRt", "GEOquery", "KEGG", "KEGGSOAP", 47 | "hgu95av2", "hgu95av2probe", "hgu95av2cdf", "human.db0", 48 | "BSgenome.Hsapiens.UCSC.hg18") 49 | } 50 | 51 | biocases_group <- function() 52 | { 53 | c(lite_group(), graph_group(), "ALL", "apComplex", "bioDist", 54 | "BiocCaseStudies", "biocGraph", "biomaRt", "CCl4", "CLL", 55 | "Category", "class", "convert", "GO.db", "GOstats", "GSEABase", 56 | "hgu133a.db", "hgu95av2cdf", "hgu95av2probe", "hopach", 57 | "KEGG.db", "kohonen", "lattice", "latticeExtra", "MASS", 58 | "matchprobes", "MLInterfaces", "org.Hs.eg.db", "ppiStats", 59 | "randomForest", "RColorBrewer", "Rintact", "sma", "weaver", 60 | "yeastExpData") 61 | } 62 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | ## The following values are updated with each Bioc release; see .onLoad 2 | BIOC_VERSION <- package_version("2.14") # Bioc version for this package 3 | R_VERSION <- package_version("3.1.0") # R version for this package 4 | IS_USER <- FALSE # TRUE if this version of 5 | # Bioconductor is the 6 | # current release version 7 | IS_END_OF_LIFE <- TRUE # TRUE if this version of 8 | # Bioconductor is no longer 9 | # the release version 10 | 11 | IS_UPGRADEABLE <- TRUE # TRUE if a more recent 12 | # version (release or 13 | # devel) of Bioconductor is 14 | # available for this 15 | # version of R 16 | UPGRADE_IS_DEVEL <- FALSE # TRUE if UPGRADE_VERSION 17 | # is for devel use only 18 | IS_DOWNGRADEABLE <- FALSE # TRUE if an older version 19 | # (release or devel) of 20 | # Bioconductor is available 21 | # for this version of R 22 | UPGRADE_VERSION <- package_version("3.0") # Bioconductor version for 23 | # upgrade, if 24 | # IS_UPGRADEABLE == TRUE 25 | DOWNGRADE_VERSION <- package_version("2.14") # Bioconductor version for 26 | # downgrade, if 27 | # IS_DOWNGRADEABLE == # TRUE 28 | 29 | NEXT_R_DEVEL_VERSION <- "3.2.0" # next (not-yet-supported) version of R 30 | 31 | ## Change when the status of MBNI changes. 32 | ## Make sure this change is propagated to users, even 33 | ## if builds have stopped for a particular version of BioC. 34 | ## See biocLite.R:.biocinstallRepos to include / exclude package types 35 | includeMBNI <- FALSE 36 | mbniUrl <- "http://brainarray.mbni.med.umich.edu/bioc" 37 | 38 | globalVariables("contribUrl") # used in 'bootstrap' functions 39 | 40 | .onAttach <- 41 | function(libname, pkgname) 42 | { 43 | .message("Bioconductor version %s (BiocInstaller %s), ?biocLite for help", 44 | biocVersion(), packageVersion("BiocInstaller")) 45 | if (IS_END_OF_LIFE) { 46 | if (IS_UPGRADEABLE) 47 | .message("A newer version of Bioconductor is available for 48 | this version of R, ?BiocUpgrade for help") 49 | else 50 | .message("A new version of Bioconductor is available after 51 | installing the most recent version of R; see 52 | http://bioconductor.org/install") 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /man/biocValid.Rd: -------------------------------------------------------------------------------- 1 | \name{biocValid} 2 | 3 | \alias{biocValid} 4 | 5 | \title{Validate installed package versions against biocLite versions.} 6 | 7 | \description{ 8 | 9 | Check that installed packages are consistent (neither out-of-date nor 10 | too new) with the version of R and Bioconductor in use, using 11 | \code{biocLite} for validation. 12 | 13 | } 14 | 15 | \usage{ 16 | biocValid(pkgs = installed.packages(lib.loc, priority = priority), 17 | lib.loc = NULL, priority = "NA", type = getOption("pkgType"), 18 | filters = NULL, silent = FALSE, ..., fix=FALSE) 19 | } 20 | 21 | \arguments{ 22 | \item{pkgs}{A character list of package names for checking, or a 23 | matrix as returned by \code{\link{installed.packages}}.} 24 | 25 | \item{lib.loc}{The library location(s) of packages to be validated; 26 | see \code{\link{installed.packages}}.} 27 | 28 | \item{priority}{check validity of all, \dQuote{base}, or 29 | \dQuote{recommended} packages; see 30 | \code{\link{installed.packages}}.} 31 | 32 | \item{type}{The type of available package (e.g., binary, source) to 33 | check validity against; see \code{\link{available.packages}}.} 34 | 35 | \item{filters}{Filter available packages to check validity against; see 36 | \code{\link{available.packages}}.} 37 | 38 | \item{silent}{Report how packages are invalid (\code{silent=FALSE}, 39 | default) and abort execution, or return a logical(1) 40 | (\code{silent=TRUE}) indicating the overall validity of installed 41 | packages.} 42 | 43 | \item{\dots}{Additional arguments, passed to \code{\link{biocLite}} 44 | when \code{fix=TRUE}.} 45 | 46 | \item{fix}{When \code{TRUE}, invoke \code{biocLite} to reinstall 47 | (update or downgrade, as appropriate) invalid packages.} 48 | 49 | } 50 | 51 | \details{ 52 | 53 | This function compares the version of installed packages to the 54 | version of packages associated with the version of R and Bioconductor 55 | appropriate for the BiocInstaller package currently in use. 56 | 57 | Packages are reported as \sQuote{out-of-date} if a more recent version 58 | is available at the repositories specified by 59 | \code{biocinstallRepos()}. Usually, \code{biocLite()} is sufficient to 60 | update packages to their most recent version. 61 | 62 | Packages are reported as \sQuote{too new} if the installed version is 63 | more recent than the most recent available in the 64 | \code{biocinstallRepos()} repositories. It is possible to down-grade 65 | by re-installing a too new package \dQuote{PkgA} with 66 | \code{biocLite("PkgA")}. It is important for the user to understand 67 | how their installation became too new, and to avoid this in the 68 | future. 69 | 70 | } 71 | 72 | \value{ 73 | \code{logical(1)} indicating overall validity of installed packages. 74 | } 75 | 76 | \author{Martin Morgan \url{mtmorgan@fhcrc.org}} 77 | 78 | \seealso{\code{\link{biocLite}} to update installed packages.} 79 | 80 | \examples{try(biocValid())} 81 | 82 | \keyword{ environment } 83 | -------------------------------------------------------------------------------- /R/biocValid.R: -------------------------------------------------------------------------------- 1 | .tooNewPkgs <- 2 | function(instPkgs, availPkgs) 3 | { 4 | idx <- rownames(availPkgs) %in% rownames(instPkgs) 5 | vers <- availPkgs[idx, "Version"] 6 | idx <- package_version(vers) < 7 | package_version(instPkgs[names(vers), "Version"]) 8 | tooNew <- names(vers)[idx] 9 | instPkgs[tooNew, c("Version", "LibPath"), drop=FALSE] 10 | } 11 | 12 | biocValid <- 13 | function(pkgs = installed.packages(lib.loc, priority=priority), 14 | lib.loc=NULL, priority="NA", type=getOption("pkgType"), 15 | filters=NULL, silent=FALSE, ..., fix=FALSE) 16 | { 17 | if (!is.matrix(pkgs)) { 18 | if (is.character(pkgs)) 19 | pkgs <- installed.packages(pkgs, lib.loc=lib.loc) 20 | else 21 | .stop("'pkgs' must be a character vector of package names, 22 | or a matrix like that returned by 'installed.packages()'") 23 | } 24 | repos <- biocinstallRepos() 25 | contribUrl <- contrib.url(repos, type=type) 26 | 27 | availPkgs <- available.packages(contribUrl, type=type, filters=filters) 28 | oldPkgs <- old.packages(lib.loc, repos=biocinstallRepos(), 29 | instPkgs=pkgs, available=availPkgs, checkBuilt=TRUE, 30 | type=type) 31 | tooNewPkgs <- .tooNewPkgs(pkgs, availPkgs) 32 | 33 | valid <- (NROW(oldPkgs) == 0) && (NROW(tooNewPkgs) == 0) 34 | if (valid) 35 | return(valid) 36 | 37 | if (!silent) { 38 | result <- structure(list(oldPkgs=oldPkgs, tooNewPkgs = tooNewPkgs), 39 | class="biocValid") 40 | print(result) 41 | } 42 | if (fix) { 43 | pkgs <- c(rownames(oldPkgs), rownames(tooNewPkgs)) 44 | biocLite(pkgs, lib.loc=lib.loc, ...) 45 | .warning("updated or downgraded package(s) %s", 46 | paste(.sQuote(pkgs), collapse=" ")) 47 | } else { 48 | msg <- character() 49 | if (NROW(oldPkgs)) 50 | msg <- 51 | c(msg, sprintf("%d package(s) out of date", NROW(oldPkgs))) 52 | if (NROW(tooNewPkgs)) 53 | msg <- 54 | c(msg, sprintf("%d package(s) too new", NROW(tooNewPkgs))) 55 | .stop(paste(msg, collapse="; ")) 56 | } 57 | 58 | invisible(valid) 59 | } 60 | 61 | print.biocValid <- 62 | function(x, ...) 63 | { 64 | cat("\n* sessionInfo()\n\n") 65 | print(sessionInfo()) 66 | cat("\n") 67 | if (NROW(x$oldPkgs)) { 68 | cat("* Out-of-date packages\n") 69 | print(x$oldPkgs) 70 | cat("\nupdate with biocLite()\n\n") 71 | } 72 | 73 | if (NROW(x$tooNewPkgs)) { 74 | cat("* Packages too new for Bioconductor version ", 75 | .sQuote(as.character(biocVersion())), "\n\n", sep="") 76 | print(x$tooNewPkgs) 77 | pkgs <- paste(.dQuote(rownames(x$tooNewPkgs)), collapse=", ") 78 | msg <- .msg(ifelse(NROW(x$tooNewPkgs) == 1L, "biocLite(%s)", 79 | "biocLite(c(%s))"), pkgs) 80 | cat("\ndowngrade with ", msg, "\n\n", sep="") 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /R/useDevel.R: -------------------------------------------------------------------------------- 1 | .biocUpgrade <- 2 | function() 3 | { 4 | if (!IS_UPGRADEABLE) { 5 | .stop("Bioconductor version %s cannot be upgraded with 6 | R version %s", biocVersion(), R_VERSION) 7 | } 8 | if (IS_UPGRADEABLE && UPGRADE_IS_DEVEL) 9 | .stop("Bioconductor version %s can be upgraded, but only to 'devel'; 10 | see ?useDevel. Use biocLite() without any arguments to update 11 | installed packages", biocVersion()) 12 | 13 | txt <- sprintf("Upgrade all packages to Bioconductor version %s? [y/n]: ", 14 | UPGRADE_VERSION) 15 | answer <- .getAnswer(txt, allowed = c("y", "Y", "n", "N")) 16 | if ("y" == answer) 17 | .update(UPGRADE_VERSION, TRUE) 18 | } 19 | 20 | useDevel <- 21 | function(devel=TRUE) 22 | { 23 | if (devel) { 24 | if (!IS_USER) 25 | .stop("'devel' version already in use") 26 | if (IS_END_OF_LIFE) 27 | .stop("'devel' version not available") 28 | if (!IS_UPGRADEABLE) 29 | .stop("'devel' version requires a more recent R") 30 | biocVers <- UPGRADE_VERSION 31 | } else { 32 | if (IS_USER) 33 | .stop("'devel' version not in use") 34 | if (!IS_DOWNGRADEABLE) 35 | .stop("'devel' version cannot be down-graded with this version of R") 36 | biocVers <- DOWNGRADE_VERSION 37 | } 38 | .update(biocVers, FALSE) 39 | } 40 | 41 | .update <- 42 | function(biocVersion, biocLiteAfterUpdate = FALSE) 43 | { 44 | .dbg("before, version is %s", packageVersion("BiocInstaller")) 45 | bootstrap <- 46 | function() 47 | { 48 | if (nchar(Sys.getenv("BIOCINSTALLER_TEST_REPOS"))) 49 | contribUrl = Sys.getenv("BIOCINSTALLER_TEST_REPOS") 50 | 51 | if ("package:BiocInstaller" %in% search()) 52 | detach("package:BiocInstaller", unload=TRUE, force=TRUE) 53 | ## contribUrl will be in bootstrap's environment 54 | suppressWarnings(tryCatch({ 55 | install.packages("BiocInstaller", contriburl=contribUrl) 56 | }, error=function(err) { 57 | assign("failed", TRUE, "biocBootstrapEnv") 58 | NULL 59 | })) 60 | library(BiocInstaller) 61 | BiocInstaller:::.updateFinish() 62 | } 63 | biocBootstrapEnv <- new.env() 64 | biocBootstrapEnv[["contribUrl"]] <- .getContribUrl(biocVersion) 65 | biocBootstrapEnv[["biocLiteAfterUpdate"]] <- biocLiteAfterUpdate 66 | .stepAside(biocBootstrapEnv, bootstrap) 67 | } 68 | 69 | .updateFinish <- 70 | function() 71 | { 72 | failed <- exists("failed", "biocBootstrapEnv") 73 | biocLiteAfterUpdate <- get("biocLiteAfterUpdate", "biocBootstrapEnv") 74 | detach("biocBootstrapEnv") 75 | .dbg("after, version is %s", packageVersion("BiocInstaller")) 76 | vers <- packageVersion("BiocInstaller") 77 | if (!failed) { 78 | .message("'BiocInstaller' changed to version %s", vers) 79 | if (biocLiteAfterUpdate) 80 | biocLite(character(), ask=FALSE) 81 | } else 82 | .warning("update failed, using BiocInstaller version %s", 83 | vers, call.=FALSE) 84 | } 85 | -------------------------------------------------------------------------------- /R/updateBiocInstallerPackage.R: -------------------------------------------------------------------------------- 1 | .getContribUrl <- 2 | function(biocVersion) 3 | { 4 | .contribUrl <- 5 | function(repos) 6 | { 7 | contribUrl <- contrib.url(repos) 8 | pkgs <- available.packages(contribUrl) 9 | if (nrow(pkgs) == 0L) 10 | .stop("no packages in repository (no internet connection?)", 11 | call.=FALSE) 12 | else if (!"BiocInstaller" %in% rownames(pkgs)) 13 | .stop("'BiocInstaller' package not in repository", 14 | call.=FALSE) 15 | contribUrl 16 | } 17 | repos <- .biocinstallRepos(biocVersion=biocVersion)["BioCsoft"] 18 | suppressWarnings(tryCatch({ 19 | .contribUrl(repos) 20 | }, error=function(err) { 21 | version <- getRversion() 22 | currentVersion <- sprintf("%d.%d", version$major, version$minor) 23 | lowerVersion <- .lowerRVersionString(version) 24 | oldRepos <- sub(currentVersion, lowerVersion, repos) 25 | if (oldRepos == repos) 26 | .stop("'%s' while trying %s", conditionMessage(err), 27 | repos, call.=FALSE) 28 | .message("'%s' while trying %s, trying %s", conditionMessage(err), 29 | repos, oldRepos) 30 | .contribUrl(oldRepos) 31 | })) 32 | } 33 | 34 | bioconductorPackageIsCurrent <- 35 | function() 36 | { 37 | installedSentinel <- availableSentinel <- package_version("0.0.0") 38 | installedVersion <- 39 | tryCatch(packageVersion("BiocInstaller"), 40 | error = function(err) installedSentinel) 41 | contribUrl <- .getContribUrl(biocVersion()) 42 | ap <- available.packages(contribUrl) 43 | availableVersion <- 44 | if ("BiocInstaller" %in% rownames(ap)) 45 | package_version(ap["BiocInstaller", "Version"]) 46 | else 47 | availableSentinel 48 | if ((installedVersion == availableVersion) && 49 | (installedVersion == installedSentinel)) 50 | .stop("'BiocInstaller' package not installed, and not available") 51 | availableVersion <= installedVersion 52 | } 53 | 54 | updateBioconductorPackage <- 55 | function(pkgs, ask, suppressUpdates, ...) 56 | { 57 | .dbg("before, version is %s", packageVersion("BiocInstaller")) 58 | bootstrap <- 59 | function() 60 | { 61 | if ("package:BiocInstaller" %in% search()) 62 | detach("package:BiocInstaller", unload=TRUE, force=TRUE) 63 | ## contribUrl will be in bootstrap's environment 64 | suppressWarnings(tryCatch({ 65 | update.packages(contriburl=contribUrl, ask=FALSE, 66 | checkBuilt=TRUE, oldPkgs="BiocInstaller") 67 | }, error=function(err) { 68 | assign("failed", TRUE, "biocBootstrapEnv") 69 | NULL 70 | })) 71 | library(BiocInstaller) 72 | BiocInstaller:::.updateBioconductorPackageFinish() 73 | } 74 | biocBootstrapEnv <- new.env() 75 | biocBootstrapEnv[["pkgs"]] <- pkgs[pkgs != "BiocInstaller"] 76 | biocBootstrapEnv[["ask"]] <- ask 77 | biocBootstrapEnv[["suppressUpdates"]] <- suppressUpdates 78 | biocBootstrapEnv[["contribUrl"]] <- .getContribUrl(biocVersion()) 79 | biocBootstrapEnv[["dotArgs"]] <- list(...) 80 | 81 | .stepAside(biocBootstrapEnv, bootstrap) 82 | } 83 | 84 | .updateBioconductorPackageFinish <- 85 | function() 86 | { 87 | args <- c(list(pkgs=get("pkgs", "biocBootstrapEnv"), 88 | ask=get("ask", "biocBootstrapEnv"), 89 | suppressUpdates=get("suppressUpdates", "biocBootstrapEnv")), 90 | get("dotArgs", "biocBootstrapEnv")) 91 | failed <- exists("failed", "biocBootstrapEnv") 92 | detach("biocBootstrapEnv") 93 | .dbg("after, version is %s", packageVersion("BiocInstaller")) 94 | vers <- packageVersion("BiocInstaller") 95 | if (!failed) 96 | .message("'BiocInstaller' updated to version %s", vers) 97 | else 98 | .warning("'BiocInstaller' update failed, using version %s", 99 | vers, call.=FALSE) 100 | if ("BiocUpgrade" %in% args$pkgs) { 101 | .biocUpgrade() 102 | } else { 103 | do.call(biocLiteInstall, args) 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /inst/scripts/biocLite.R: -------------------------------------------------------------------------------- 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")) 4 | 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, 7 | ## Seattle, USA) 8 | ## options("BioC_mirror" = "http://www.bioconductor.org") 9 | 10 | local({ 11 | vers <- getRversion() 12 | biocVers <- tryCatch({ 13 | BiocInstaller::biocVersion() # recent BiocInstaller 14 | }, error=function(...) { # no / older BiocInstaller 15 | tools:::.BioC_version_associated_with_R_version 16 | }) 17 | 18 | if (vers < "3.0") { 19 | ## legacy; no need to change "3.0" ever 20 | ## coordinate this message with .onAttach 21 | txt <- strwrap("A new version of Bioconductor is available 22 | after installing the most recent version of R; see 23 | http://bioconductor.org/install", exdent=2) 24 | message(paste(txt, collapse="\n")) 25 | } else if ("package:BiocInstaller" %in% search()) { 26 | ## messages even if already attached 27 | tryCatch(BiocInstaller:::.onAttach(), error=function(...) NULL) 28 | } 29 | 30 | if (vers > "2.13" && biocVers > "2.8") { 31 | 32 | if (exists("biocLite", .GlobalEnv, inherits=FALSE)) { 33 | txt <- strwrap("There is an outdated biocLite() function in the 34 | global environment; run 'rm(biocLite)' and try again.") 35 | stop("\n", paste(txt, collapse="\n")) 36 | } 37 | 38 | if (!suppressWarnings(require("BiocInstaller", quietly=TRUE))) { 39 | a <- NULL 40 | p <- file.path(Sys.getenv("HOME"), ".R", "repositories") 41 | if (file.exists(p)) { 42 | a <- tools:::.read_repositories(p) 43 | if (!"BioCsoft" %in% rownames(a)) 44 | a <- NULL 45 | } 46 | if (is.null(a)) { 47 | p <- file.path(R.home("etc"), "repositories") 48 | a <- tools:::.read_repositories(p) 49 | } 50 | if (!"package:utils" %in% search()) { 51 | url <- "http://bioconductor.org/biocLite.R" 52 | txt <- sprintf("use 'source(\"%s\")' to update 'BiocInstaller' 53 | after 'utils' package is attached", 54 | url) 55 | message(paste(strwrap(txt), collapse="\n ")) 56 | } else { 57 | ## add a conditional for Bioc releases occuring WITHIN 58 | ## a single R minor version 59 | if (vers == "3.1.0") 60 | ## R-devel points to 2.13 repository 61 | a["BioCsoft", "URL"] <- sub(as.character(biocVers), "2.14", 62 | a["BioCsoft", "URL"]) 63 | else if (vers >= "2.15" && vers < "2.16") { 64 | a["BioCsoft", "URL"] <- sub(as.character(biocVers), "2.11", 65 | a["BioCsoft", "URL"]) 66 | biocVers <- numeric_version("2.11") 67 | } 68 | install.packages("BiocInstaller", repos=a["BioCsoft", "URL"]) 69 | if (!suppressWarnings(require("BiocInstaller", 70 | quietly=TRUE))) { 71 | url0 <- "http://www.bioconductor.org/packages" 72 | url <- sprintf("%s/%s/bioc", 73 | url0, as.character(biocVers)) 74 | txt0 <- "'biocLite.R' failed to install 'BiocInstaller', 75 | use 'install.packages(\"%s\", repos=\"%s\")'" 76 | txt <- sprintf(txt0, "BiocInstaller", url) 77 | message(paste(strwrap(txt), collapse="\n ")) 78 | } 79 | } 80 | } 81 | } else { 82 | source("http://bioconductor.org/getBioC.R") 83 | biocLite <<- 84 | function(pkgs, groupName="lite", ...) 85 | { 86 | if (missing(pkgs)) 87 | biocinstall(groupName=groupName, ...) 88 | else 89 | biocinstall(pkgs=pkgs, groupName=groupName, ...) 90 | } 91 | } 92 | }) 93 | -------------------------------------------------------------------------------- /man/biocLite.Rd: -------------------------------------------------------------------------------- 1 | \name{biocLite} 2 | \alias{biocLite} 3 | \title{ 4 | 5 | Install or update Bioconductor and CRAN packages 6 | 7 | } 8 | \description{ 9 | 10 | \code{biocLite} installs or updates Bioconductor and CRAN packages in 11 | a Bioconductor release. Upgrading to a new Bioconductor release 12 | requires additional steps; see \url{http://bioconductor.org/install}. 13 | 14 | } 15 | \usage{ 16 | biocLite(pkgs=c("Biobase", "IRanges", "AnnotationDbi"), 17 | suppressUpdates=FALSE, 18 | suppressAutoUpdate=FALSE, 19 | siteRepos=character(), 20 | ask=TRUE, ...) 21 | } 22 | \arguments{ 23 | 24 | \item{pkgs}{\code{character()} of package names to install or update. 25 | A missing value and \code{suppressUpdates=FALSE} updates installed 26 | packages, perhaps also installing \code{Biobase}, \code{IRanges}, 27 | and \code{AnnotationDbi} if they are not already installed.} 28 | 29 | \item{suppressUpdates}{\code{logical(1)} indicating whether to 30 | suppress automatic updating of all installed packages, or 31 | \code{character()} of regular expressions specifying which packages 32 | to NOT automatically update.} 33 | 34 | \item{suppressAutoUpdate}{\code{logical(1)} indicating whether the 35 | \code{BiocInstaller} package updates itself.} 36 | 37 | \item{siteRepos}{\code{character()} representing an additional 38 | repository in which to look for packages to install. This 39 | repository will be prepended to the default repositories 40 | (which you can see with \code{\link{biocinstallRepos}}).} 41 | 42 | \item{ask}{\code{logical(1)} indicating whether to prompt user before 43 | installed packages are updated, or the character string 'graphics', 44 | which brings up a widget for choosing which packages to update. 45 | If TRUE, user can choose whether to update all outdated packages 46 | without further prompting, to pick and choose packages to update, 47 | or to cancel updating (in a non-interactive session, no packages 48 | will be updated). Otherwise, the value is passed to 49 | \code{\link{update.packages}}.} 50 | 51 | \item{...}{Additional arguments. \code{lib.loc} is passed to 52 | \code{\link{old.packages}} (used to determine the library location 53 | of installed packages to be updated). \code{lib} is passed to 54 | \code{\link{install.packages}} (used to determine the library 55 | location where \code{pkgs} are to be installed).} 56 | 57 | } 58 | 59 | \value{ 60 | \code{biocLite()} returns the \code{pkgs} argument, invisibly. 61 | } 62 | \seealso{ 63 | 64 | \code{\link{biocinstallRepos}} returns the Bioconductor and CRAN 65 | repositories used by \code{biocLite}. 66 | 67 | \code{\link{install.packages}} installs the packages themselves. 68 | 69 | \code{\link{update.packages}} updates all installed packages. 70 | 71 | \code{\link{chooseBioCmirror}} lets you choose from a list of all 72 | public Bioconductor mirror URLs. 73 | 74 | \code{\link{chooseCRANmirror}} lets you choose from a list of all 75 | public CRAN mirror URLs. 76 | 77 | \code{\link{monograph_group}}, \code{\link{RBioinf_group}} and 78 | \code{\link{biocases_group}} return package names associated 79 | with Bioconductor publications. 80 | 81 | \code{\link{all_group}} returns the names of all Bioconductor 82 | software packages. 83 | 84 | } 85 | 86 | \examples{ 87 | \dontrun{ 88 | ## Change default Bioconductor and CRAN mirrors 89 | chooseBioCmirror() 90 | chooseCRANmirror() 91 | 92 | 93 | ## If you don't have the BiocInstaller package installed, you can 94 | ## quickly install and load it as follows: 95 | source("http://bioconductor.org/biocLite.R") 96 | 97 | 98 | ## The most recent version of the BiocInstaller package is now loaded. 99 | ## No need to load it with library(). 100 | 101 | # installs default packages (if not already installed) and updates 102 | # previously installed packages 103 | biocLite() 104 | 105 | 106 | ## Now install a CRAN package: 107 | biocLite("survival") 108 | 109 | ## install a Bioconductor package, but don't update all installed 110 | ## packages as well: 111 | biocLite("GenomicRanges", suppressUpdates=TRUE) 112 | 113 | ## Install default packages, but do not update any package whose name 114 | ## starts with "org." or "BSgenome." 115 | biocLite(suppressUpdates=c("^org\\.", "^BSgenome\\.")) 116 | 117 | ## install a package from source: 118 | biocLite("IRanges", type="source") 119 | 120 | ## install all Bioconductor software packages 121 | biocLite(all_group()) 122 | 123 | } 124 | ## Show the Bioconductor and CRAN repositories that will be used to 125 | ## install/update packages. 126 | biocinstallRepos() 127 | } 128 | \keyword{environment} 129 | -------------------------------------------------------------------------------- /man/useDevel.Rd: -------------------------------------------------------------------------------- 1 | \name{useDevel} 2 | \alias{useDevel} 3 | \title{ 4 | 5 | Get the 'devel' version of the BiocInstaller package. 6 | 7 | } 8 | \description{ 9 | 10 | Downloads the 'devel' version of the BiocInstaller package 11 | so that all subsequent invocations of \code{\link{biocLite}} 12 | and \code{\link{biocinstallRepos}} use the devel repositories. 13 | 14 | Displays the URLs of the repositories used by \code{\link{biocLite}} 15 | to install Bioconductor and CRAN packages. 16 | 17 | Should only be used with a release (or patched) version of R, 18 | freshly installed. 19 | 20 | } 21 | \usage{ 22 | useDevel(devel=TRUE) 23 | } 24 | \arguments{ 25 | \item{devel}{Whether to look in the devel (TRUE) or release 26 | (FALSE) repositories in subsequent invocations of 27 | \code{\link{biocLite}} and \code{\link{biocinstallRepos}}.} 28 | } 29 | \details{ 30 | 31 | With R going to a yearly release schedule and Bioconductor keeping its 32 | twice-yearly release schedule, the same version of R (3.0) can be used 33 | with two different versions of Bioconductor (2.11, release, and 2.12, devel). 34 | The version number of the BiocInstaller package is what is used to determine 35 | whether to download packages from the BioC 2.11 or 2.12 repositories. 36 | In keeping with Bioconductor versioning conventions, if the middle number 37 | (y in x.y.z) is even, the package is part of a release version; if odd, it's 38 | part of a devel version. 39 | 40 | By default, when BiocInstaller is first installed on R-3.0, it will be 41 | set up to download BioC 2.11 packages. 42 | 43 | If you want to change this, you can run the \code{\link{useDevel}} 44 | function. With argument \code{TRUE} (the default), it will download 45 | the devel version of BiocInstaller and subsequently all packages 46 | downloaded with \code{\link{biocLite}} will be from the BioC 2.12 47 | (devel) repository. You should run \code{\link{useDevel}} only once. 48 | 49 | It is possible to keep BioC 2.11 and 2.12 libraries separate, within 50 | the same installation of R. 51 | 52 | The trick is to use the \code{R_LIBS_USER} environment variable. 53 | First, create two separate directories for your BioC release 54 | and devel packages. Suggested directory names are as follows: 55 | 56 | Linux: 57 | 58 | ~/R/x86_64-unknown-linux-gnu-library/3.0-bioc-release 59 | 60 | ~/R/x86_64-unknown-linux-gnu-library/3.0-bioc-devel 61 | 62 | Mac OS: 63 | 64 | ~/Library/R/3.0-bioc-release/library 65 | 66 | ~/Library/R/3.0-bioc-devel/library 67 | 68 | Windows: 69 | 70 | C:\\Users\\YOUR_USER_NAME\\Documents\\R\\win-library\\3.0-bioc-release 71 | 72 | C:\\Users\\YOUR_USER_NAME\\Documents\\R\\win-library\\3.0-bioc-devel 73 | 74 | (change YOUR_USER_NAME to your user name) 75 | 76 | 77 | You can then invoke "R for bioc-devel" or "R for bioc-release" from 78 | the command line as follows: 79 | 80 | Linux: 81 | 82 | R_LIBS_USER=~/R/x86_64-unknown-linux-gnu-library/3.0-bioc-release R 83 | 84 | R_LIBS_USER=~/R/x86_64-unknown-linux-gnu-library/3.0-bioc-devel R 85 | 86 | 87 | Mac OS X: 88 | 89 | R_LIBS_USER=~~/Library/R/3.0-bioc-release/library R 90 | R_LIBS_USER=~~/Library/R/3.0-bioc-devel/library R 91 | 92 | Windows: 93 | 94 | cmd /C "set R_LIBS_USER=C:\\Users\\YOUR_USER_NAME\\Documents\\R\\win-library\\3.0-bioc-release && R" 95 | 96 | cmd /C "set R_LIBS_USER=C:\\Users\\YOUR_USER_NAME\\Documents\\R\\win-library\\3.0-bioc-devel && R" 97 | 98 | (Note: this assumes that R.exe is in your PATH.) 99 | 100 | 101 | If you launch R in this way and then invoke \code{\link{.libPaths}}, 102 | you'll see that the first item is your special release or 103 | devel directory. Packages will be installed to that directory and that 104 | is the first place that \code{\link{library}} will look for them. 105 | \code{\link{biocLite}}, \code{\link{install.packages}}, 106 | \code{\link{update.packages}} and friends all respect this 107 | setting. 108 | 109 | 110 | On Linux and Mac OS X, you can create a bash alias to save typing. Add the 111 | following to your ~/bash_profile: 112 | 113 | 114 | Linux 115 | 116 | alias Rdevel='R_LIBS_USER=~/R/x86_64-unknown-linux-gnu-library/3.0-bioc-devel R' 117 | 118 | alias Rrelease='R_LIBS_USER=~/R/x86_64-unknown-linux-gnu-library/3.0-bioc-release R' 119 | 120 | Mac OS X 121 | 122 | alias Rdevel='R_LIBS_USER=~/Library/R/3.0-bioc-devel/library R' 123 | alias Rrelease='R_LIBS_USER=~/Library/R/3.0-bioc-release/library R' 124 | 125 | 126 | You can then invoke these from the command line as 127 | 128 | Rdevel 129 | 130 | ...and... 131 | 132 | Rrelease 133 | 134 | 135 | On Windows, you can create two shortcuts, one for devel and one for 136 | release. Go to My Computer and navigate to a directory that is in your 137 | PATH. Then right-click and choose New->Shortcut. 138 | 139 | in the "type the location of the item" box, put: 140 | 141 | cmd /C "set R_LIBS_USER=C:\\Users\\YOUR_USER_NAME\\Documents\\R\\win-library\\3.0-bioc-release && R" 142 | 143 | ...for release and 144 | 145 | cmd /C "set R_LIBS_USER=C:\\Users\\YOUR_USER_NAME\\Documents\R\\win-library\\3.0-bioc-devel && R" 146 | 147 | ...for devel. 148 | 149 | (again, it's assumed R.exe is in your PATH) 150 | 151 | Click "Next". 152 | 153 | In the "Type a name for this shortcut" box, type 154 | 155 | Rdevel 156 | 157 | or 158 | 159 | Rrelease 160 | 161 | You can invoke these from the command line as 162 | 163 | Rdevel.lnk 164 | 165 | ...and... 166 | 167 | Rrelease.lnk 168 | 169 | (You must type in the .lnk extension.) 170 | 171 | Because \code{R_LIBS_USER} is an environment variable, its value should be 172 | inherited by any subprocesses started by R, so they should do the 173 | right thing as well. 174 | 175 | 176 | 177 | } 178 | 179 | \value{ 180 | Invisible NULL. 181 | } 182 | \seealso{ 183 | \code{\link{biocinstallRepos}} returns the Bioconductor and CRAN 184 | repositories used by \code{biocLite}. 185 | 186 | \code{\link{biocLite}} Installs/updates Bioconductor/CRAN packages. 187 | 188 | \code{\link{install.packages}} installs the packages themselves. 189 | 190 | \code{\link{chooseBioCmirror}} lets you choose from a list of all 191 | public Bioconductor mirror URLs. 192 | 193 | \code{\link{chooseCRANmirror}} lets you choose from a list of all 194 | public CRAN mirror URLs. 195 | } 196 | \examples{ 197 | \dontrun{ 198 | useDevel() 199 | } 200 | } 201 | \keyword{environment} 202 | -------------------------------------------------------------------------------- /R/biocLite.R: -------------------------------------------------------------------------------- 1 | ## TODO: should probably print out a message about how to use mirrors, 2 | ## the way sourcing biocLite.R does now. 3 | 4 | biocinstallRepos <- 5 | function(siteRepos=character()) 6 | { 7 | ## siteRepos argument is public, but need biocVersion internally 8 | .biocinstallRepos(siteRepos=siteRepos, biocVersion()) 9 | } 10 | 11 | .biocinstallRepos <- 12 | function(siteRepos=character(), biocVersion) 13 | { 14 | old.opts <- options("repos") 15 | on.exit(options(old.opts)) 16 | 17 | ## Starting at some point in R-2.14, Omegahat is included in 18 | ## the list of available repositories, on windows only, it seems. 19 | 20 | ## on mac and linux: 21 | 22 | ## 1: + CRAN 23 | ## 2: + CRAN (extras) 24 | ## 3: + BioC software 25 | ## 4: + BioC annotation 26 | ## 5: + BioC experiment 27 | ## 6: + BioC extra 28 | ## 7: R-Forge 29 | ## 8: rforge.net 30 | 31 | ## on windows: 32 | 33 | ## 1: + CRAN 34 | ## 2: + CRAN (extras) 35 | ## 3: Omegahat 36 | ## 4: BioC software 37 | ## 5: BioC annotation 38 | ## 6: BioC experiment 39 | ## 7: BioC extra 40 | ## 8: R-Forge 41 | ## 9: rforge.net 42 | 43 | ## So it's probably better not to rely on the numbers. 44 | 45 | setRepositories(ind=1:20) # in case more repos are added 46 | repos <- getOption("repos") 47 | 48 | biocMirror <- getOption("BioC_mirror", "http://bioconductor.org") 49 | biocPaths <- c(BioCsoft="bioc", BioCann="data/annotation", 50 | BioCexp="data/experiment", BioCextra="extra") 51 | biocRepos <- paste(biocMirror, "packages", biocVersion, 52 | biocPaths, sep="/") 53 | repos[names(biocPaths)] <- biocRepos 54 | 55 | keepRepos <- if (.Platform$OS.type %in% "windows") { 56 | c(names(biocPaths), "CRAN", "CRANextra") 57 | } else { 58 | c(names(biocPaths), "CRAN") 59 | } 60 | repos <- repos[keepRepos] 61 | 62 | ## This needs to be commented out a few months (3? 4?) after the 63 | ## next development cycle has started, when we are confident that 64 | ## no developper is still using an early R devel with a 65 | ## tools:::.BioC_version_associated_with_R_version still pointing 66 | ## to the release repository. 67 | if (!IS_USER) 68 | { 69 | ## comment repos here as they become available. 70 | inactive <- c( 71 | ## "BioCsoft" 72 | ## , "BioCextra" 73 | ## , "BioCann" 74 | ## , "BioCexp" 75 | ) 76 | 77 | ## No need to touch below. 78 | tmpRepos <- paste(biocMirror, "packages", DOWNGRADE_VERSION, 79 | biocPaths[inactive], sep="/") 80 | repos[inactive] <- tmpRepos 81 | } 82 | 83 | repos <- subset(repos, !is.na(repos)) 84 | 85 | if ("@CRAN@" %in% repos) 86 | repos["CRAN"] <- "http://cran.fhcrc.org" 87 | if (includeMBNI && 88 | (getOption("pkgType") %in% c("source", "win.binary"))) 89 | repos[["MBNI"]] <- mbniUrl 90 | 91 | c(siteRepos=siteRepos, repos) 92 | } 93 | 94 | biocLiteInstall <- 95 | function(pkgs, repos, ask, suppressUpdates, siteRepos=character(), 96 | lib.loc=.libPaths(), lib=.libPaths()[1], ...) 97 | { 98 | if (!missing(repos)) 99 | .stop("'repos' argument to 'biocLite' not allowed") 100 | 101 | if (!(is.character(suppressUpdates) || is.logical(suppressUpdates)) || 102 | (is.logical(suppressUpdates) && 1L != length(suppressUpdates))) 103 | .stop("'suppressUpdates' must be character() or logical(1)") 104 | 105 | type <- list(...)[["type"]] 106 | if (is.null(type)) 107 | type <- getOption("pkgType") 108 | 109 | biocMirror <- getOption("BioC_mirror", "http://bioconductor.org") 110 | .message("BioC_mirror: %s", biocMirror) 111 | 112 | version <- getRversion() 113 | thisRVer <- sprintf("%d.%d", version$major, version$minor) 114 | .message("Using Bioconductor version %s (BiocInstaller %s), R version %s.", 115 | biocVersion(), packageVersion("BiocInstaller"), version) 116 | 117 | if (!suppressPackageStartupMessages(require("utils", quietly=TRUE))) 118 | .stop("failed to load package 'utils'") 119 | if (compareVersion(thisRVer, NEXT_R_DEVEL_VERSION) >= 0) 120 | .message("Temporarily using Bioconductor version %s", 121 | biocVersion()) 122 | 123 | repos <- biocinstallRepos(siteRepos) 124 | 125 | if (length(pkgs)) { 126 | if ((type %in% c("mac.binary", "mac.binary.leopard")) && 127 | ("MBNI" %in% names(repos))) 128 | { 129 | url <- contrib.url(repos[["MBNI"]]) 130 | mbniPkgs <- intersect(pkgs, 131 | row.names(available.packages(url))) 132 | if (length(mbniPkgs) > 0) 133 | .message("MBNI Brain Array packages '%s' are not 134 | available as Mac binaries, use biocLite with 135 | type='source'", 136 | paste(mbniPkgs, collapse="' '")) 137 | } 138 | 139 | .message("Installing package(s) '%s'", 140 | paste(pkgs, collapse="' '")) 141 | install.packages(pkgs=pkgs, lib=lib, repos=repos, ...) 142 | } 143 | 144 | ## early exit if suppressUpdates 145 | if (is.logical(suppressUpdates) && suppressUpdates) 146 | return(invisible(pkgs)) 147 | pkgsToUpdate <- old.packages(repos=repos, lib.loc=lib.loc) 148 | if (is.null(pkgsToUpdate)) 149 | return(invisible(pkgs)) 150 | 151 | if (!is.logical(suppressUpdates)) { 152 | pkgsToUpdate <- 153 | filterPackagesToUpdate(suppressUpdates, pkgsToUpdate) 154 | suppressUpdates <- FALSE 155 | } 156 | 157 | oldPkgs <- getUpdatablePackages(pkgsToUpdate) 158 | if (nrow(oldPkgs)) { 159 | pkgList <- paste(oldPkgs[,"Package"], collapse="', '") 160 | if (ask==TRUE) { 161 | .message("Old packages: '%s'", pkgList) 162 | 163 | answer <- 164 | .getAnswer("Update all/some/none? [a/s/n]: ", 165 | allowed = c("a", "A", "s", "S", "n", "N")) 166 | 167 | switch(answer, 168 | a = update.packages(repos=repos, oldPkgs=oldPkgs, ask=FALSE), 169 | s = update.packages(repos=repos, oldPkgs=oldPkgs, ask=TRUE), 170 | n = invisible(pkgs)) 171 | } else { 172 | .message("Updating packages '%s'", pkgList) 173 | update.packages(repos=repos, oldPkgs=oldPkgs, ask=ask) 174 | } 175 | } 176 | 177 | invisible(pkgs) 178 | } 179 | 180 | .getAnswer <- function(msg, allowed) 181 | { 182 | if (interactive()) { 183 | repeat { 184 | cat(msg) 185 | answer <- readLines(n = 1) 186 | if (answer %in% allowed) 187 | break 188 | } 189 | tolower(answer) 190 | } else { 191 | "n" 192 | } 193 | } 194 | 195 | biocLite <- 196 | function(pkgs=c("Biobase","IRanges","AnnotationDbi"), 197 | suppressUpdates=FALSE, 198 | suppressAutoUpdate=FALSE, 199 | siteRepos=character(), ask=TRUE, ...) 200 | { 201 | if (missing(pkgs)) # biocLite() update w/out installing defaults 202 | pkgs <- pkgs[!pkgs %in% rownames(installed.packages())] 203 | if (!suppressAutoUpdate && !bioconductorPackageIsCurrent()) { 204 | on.exit(updateBioconductorPackage(pkgs, ask=ask, 205 | suppressUpdates=suppressUpdates, 206 | siteRepos=siteRepos, ...)) 207 | } else if ("BiocUpgrade" %in% pkgs) { 208 | .biocUpgrade() 209 | } else { 210 | biocLiteInstall(pkgs, ask=ask, siteRepos=siteRepos, 211 | suppressUpdates=suppressUpdates, ...) 212 | } 213 | } 214 | --------------------------------------------------------------------------------