bioclite lib.loc and R_LIBS_USER
5
0
Entering edit mode
Janet Young ▴ 740
@janet-young-2360
Last seen 5.1 years ago
Fred Hutchinson Cancer Research Center,…

Hi there,

I've just started using a system-wide installation of R, instead of installing R myself. This is on a system where I don't have root privileges. I am specifying R_LIBS_USER so I can install/update packages for myself without bothering our sysadmin person too often. This seems to work OK so far.  I'm a bit confused about updating packages, though. I'll explain my confusion below:

The usual command 

source('http://bioconductor.org/biocLite.R')
biocLite()

puts updated versions of all packages into the place I specify using R_LIBS_USER, so that's great.  My packages are in /fh/fast/malik_h/grp/malik_lab_shared/linux_gizmo/R_packages   and the packages our sysadmin guy installs are in /app/R/3.2.1/lib/R/library. .libPaths() output looks like this:

[1] "/fh/fast/malik_h/grp/malik_lab_shared/linux_gizmo/R_packages"

[2] "/app/R/3.2.1/lib/R/library"                                  

When I load a package, I get the newer version that's in .libPaths()[1] over the older version that's in .libPaths()[2]. So far so good.

My only issue is that when I next run biocLite() it tries to update packages for that I just updated a minute ago - these are packages for which a current version exists in .libPaths()[1] but an old version exists in .libPaths()[2].  This is not so useful and is a little time-consuming.

I've got a partial answer - I figured out that I can do this:   biocLite(lib.loc=.libPaths()[1])  

and now I only update packages that are out-of-date in .libPaths()[1].  That's OK, but let's say in a month's time I want to make sure all packages I'm loading are current.  So, what I'd like to do is this:  rather than listing any package found in any element of .libPaths() that's out-of-date, and getting the new version, I'd like to list any package for which the version that will actually be loaded is out-of-date, and only update those.  I.e. for packages that are present in both .libPaths()[1] and .libPaths()[2], only check the one in  .libPaths()[1] against the repository version, but for packages that are present only in .libPaths()[2], also check that one. 

Does that question make sense? Is there any way to do what I want to do?

thanks very much,

Janet

biocinstaller • 3.0k views
ADD COMMENT
1
Entering edit mode
Janet Young ▴ 740
@janet-young-2360
Last seen 5.1 years ago
Fred Hutchinson Cancer Research Center,…

this updated function better mimics the native biocLite:


myBiocLite <- function(requestedPackages=NULL, test=FALSE) {

    if (!is.null(requestedPackages)) {
        cat("\nFirst install requested packages:",requestedPackages,"\n")
        if (!test) {
            source('http://bioconductor.org/biocLite.R')
            biocLite(requestedPackages, suppressUpdates=TRUE, suppressAutoUpdate=TRUE)
        }
    }
    
    ### any other old versions to update?
    cat("\nCheck for out-of-date packages...\n")
    suggestedUpdates <- old.packages()
    installedVersions <- installed.packages()[ rownames(suggestedUpdates),"Version" ]
    suggestedUpdatesVersions <- suggestedUpdates[,"ReposVer"]
    needToUpdate <- suggestedUpdatesVersions!=installedVersions
    if (sum(needToUpdate) > 0) {
        installThese <- names(suggestedUpdatesVersions)[which(needToUpdate)]
        cat("    ...calling biocLite with this list of packages:\n        ",installThese,"\n")
        if (!test) {
            source('http://bioconductor.org/biocLite.R')
            biocLite(installThese, suppressUpdates=TRUE, suppressAutoUpdate=TRUE)
        }
    } else {
        cat("    ...there are no new packages to install\n")
    }
    cat("\ndone\n\n")
}

 

ADD COMMENT
0
Entering edit mode
Dan Tenenbaum ★ 8.2k
@dan-tenenbaum-4256
Last seen 6 months ago
United States

It's a bit confusing because update.packages() uses a different argument, instlib. This argument tells it where to install packages. So you could say:

So you can update ALL your outdated packages with:

 

biocLite(instlib=.libPaths()[x]) 

 

where x is the location that you have permission to install things to. This may result in having the same package installed in more than one place, but R will figure out which installation has the most recent version of the package.

ADD COMMENT
0
Entering edit mode
Janet Young ▴ 740
@janet-young-2360
Last seen 5.1 years ago
Fred Hutchinson Cancer Research Center,…

Thanks for looking at this, Dan.  That's not quite working for me - here's what happens:

In my case, x=1 (.libPaths()[1] is the location that I have permission to install things to). So I do this: 

biocLite(instlib=.libPaths()[1])

and it still goes ahead and installs quite a few packages for which two versions exist - a current version in libPaths()[1] and an older version in libPaths()[2]. Example - I already have a current version of the "checkmate" package, in libPaths()[1], and it seems to load fine. There's an older version of checkmate in libPaths()[2], which seems to be triggering biocLite to try to update it (and the update simply overwrites what I already have in  libPaths()[1]).

I'd like to suppress biocLite's attempt to update those sorts of packages without having to do it manually. It's not such a big deal to reinstall small packages, but for some of the genome/organism packages I'd rather not do that. 

Does that make sense?  thanks very much,

Janet

 

 

ADD COMMENT
0
Entering edit mode
Dan Tenenbaum ★ 8.2k
@dan-tenenbaum-4256
Last seen 6 months ago
United States

You can always add the suppressUpdates=TRUE argument to biocLite(), then it will never ask you to update anything.

You could add this to your .Rprofile to turn this on permanently:

biocLite <- function(...) BiocInstaller::biocLite(..., suppressUpdates=TRUE)

When you want the old behavior, either start R with the --vanilla flag or explicitly call BiocInstaller::biocLite().

Using old.packages() and new.packages() (see ?update.packages) you can roll your own code for periodically checking which packages in a given library location are out of date. You should pass biocinstallRepos() (a function from BiocInstaller) as the 'repos' argument to these functions.

I agree that perhaps biocLite() doesn't handle this so well. R knows that if the same package exists in two places and one is newer than the other, it will use the new package, but biocLite() does not seem to know this. We'll look into possibly improving this.

ADD COMMENT
0
Entering edit mode
Janet Young ▴ 740
@janet-young-2360
Last seen 5.1 years ago
Fred Hutchinson Cancer Research Center,…

Thanks once again - that was a useful suggestion to try using old.packages, etc. (I'd rather not suppress all updates - I want to keep current, it's just that I don't want to spend time updating things I already have a current version of).

Here's a pretty simple function that I think will do what I want to do - I'll test it more, but as far as I can tell it's working, and will update packages that really do need updating. 

myBioCLite <- function() {
    suggestedVersions <- old.packages()
    installedVersions <- installed.packages()[ rownames(suggestedVersions),"Version" ]
    suggestedVersions <- suggestedVersions[,"ReposVer"]
    needToInstall <- suggestedVersions!=installedVersions
    if (sum(needToInstall) > 0) {
        installThese <- names(suggestedVersions)[which(needToInstall)]
        cat("\ncalling biocLite with this list of packages\n",installThese,"\n")
        biocLite(installThese, suppressUpdates=TRUE, suppressAutoUpdate=TRUE)
    } else {
        cat("\nThere are no new packages to install\n")
    }
    cat("\ndone\n\n")
}

myBioCLite()

 

ADD COMMENT

Login before adding your answer.

Traffic: 546 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6