R, RStudio, and Release and Dev Bioconductor

I have one Bioconductor package that I am currently responsible for. Each bi-annual release of Bioconductor requires testing and squashing errors, warnings and bugs in a given package. Doing this means being able to work with multiple versions of R and multiple versions of Bioconductor libraries on a single system (assuming that you do production work and development on the same machine, right?).

I really, really like RStudio as my working R environment, as some of you have read before. So how do we get RStudio on our Linux system to respect which version of R and libraries we want to use?

Setup

This assumes that you have your R installs set somewhere properly, and a normal library for production level packages. You should install whichever Bioconductor packages you want into the normal library, and then make a copy of that. This copy will be your development library.

cp -R productionLibrary developmentLibrary

I also assume that you are using a local (i.e. sits in your home directory) .Renviron file to control where R installs the packages.

Changing Versions

RStudio really needs the environment variable RSTUDIO_WHICH_R set to know where R is, and R looks at R_LIBS in the .Renviron file. So I simply create two shell scripts that get sourced.

useRDev.sh

#!/bin/sh
export RSTUDIO_WHICH_R=/pathToDevR/bin/R
echo "R_LIBS=pathtoDevLibs" > .Renviron

Then I can simply do source useRDev.sh when I need to use the development R and library. Note that you will need to start RStudio from the shell for it to respect this environment variable. RStudio generally seems to install to /usr/lib/rstudio/bin/rstudio.

resetR.sh

#!/bin/sh
export RSTUDIO_WHICH_R=/pathtoReleaseR/bin/R
echo "R_LIBS=pathtoReleaseLibs" > .Renviron

This resets my variables by doint source resetR.sh.

Bioconductor Dev Version

To setup Bioconductor to use the develoment version, simply:

source useRDev.sh
rstudio

# once in RStudio
library(BiocInstaller)
useDev()
biocLite(ask=F) # this will update all the installed bioconductor packages

I know this is not the most ideal situation, because I am rewriting over files, but it is working for me, and I thought it might help somone else.

Related