Skip to content

Working with R packages

With the Research Environment, you can create and maintain your own R package libraries. There are also many commonly used R packages pre-installed in centralised locations on the RE.

Licensing considerations

Please note if you install libraries yourself, you will be solely and fully responsible for acquiring any licences required for the use of and access to the relevant software package. GEL expect all software to be correctly licensed by you where the self-installation route is employed. In no event shall GEL be liable to you or any third parties for any claim, damages or other liability, whether such liability arises in contract, tort (including negligence), breach of statutory duty, misrepresentation, restitution and on an indemnity basis or otherwise, arising from, out of or in connection with software self-installed by the researcher or the use or other dealings by the researcher in the software.

Any links to third party software available on this User Guide are provided “as is” without warranty of any kind, either expressed or implied, and such software is to be used at your own risk. No advice or information, whether oral or written, obtained by you from us or from this User Guide shall create any warranty in relation to the software.

Libraries available in R

You can query the R libraries available in the RE using a resource available at from:

  • locally: ~/gel_data_resources/software_catalogues/R_catalogue/
  • HPC: /gel_data_resources/software_catalogues/R_catalogue/

Take a look at the README.md in that folder for instructions. You will need to use different scripts depending on if you are on the HPC or not:

  • locally: VDI_query_catalogue.sh
  • HPC: /HPC_query_catalogue.sh

Using pre-installed packages

Pre-installed R packages can be found at:

  • /tools/aws-workspace-apps/ce/R/4.0.2
  • /tools/aws-workspace-apps/ce/R/4.2.1

The best practice for using "Community" packages is to add these folder locations to .libPaths in your R session. For example

Please note: it may take ~5 minutes before these packages become visible after the library paths have been mounted to .libPaths().

.libPaths(c( .libPaths(), "/tools/aws-workspace-apps/ce/R/4.0.2"))
library(tidyverse)

The following code may be run before and after the above commands to check this step has been successful:

table(as.data.frame(installed.packages())$LibPath)
print(table)

Installing R packages from CRAN

You can install R packages yourself within the Research Environment from CRAN as we have an internal mirror.

You can only install R packages from the Desktop environment. You cannot install R packages directly on the HPC. However, we do already have various packages pre-installed. Please see the "Loading R packages" section below.

  1. Make a folder where you want to store your R packages for example: ~/re_gecip/yourDomain/R_packages

  2. Install the package and specify the installation path with lib: install.packages("", lib="~/re_gecip/yourDomain/R_packages")

  3. Load libraries: library(, lib="~/re_gecip/yourDomain/R_packages")

All R packages that are located on GitHub require Genomics England admins to install them. Please submit a service desk ticket if you require this.

Installing and configuring packages from BioConductor

You can also install BioConductor packages from within the Research Environment after a once-off configuration as shown in Configuration of R. Follow the same setup as CRAN packages by installing them to a shared folder on the HPC (such as re_gecip).

Open R (or RStudio) and run the following:

1
2
3
library("BiocManager")
BiocManager::install("<package_name>")
library(<package_name>)

Open R (or RStudio) and run the following

1
2
3
source("https://bioconductor.org/biocLite.R")
biocLite("<package_name>")
library(<package_name>)

Loading packages from the HPC environment

To load a pre-installed R package from the HPC environment you can use the following command: library(, lib="/re_gecip/yourDomain/R_packages"). Notice the preceding / in the HPC environment compared to ~/ in the Desktop environment.

Creating your own libraries

We suggest creating an Rpackages folder within your working directory, either in your personal space or shared between you and your collaborators.

To do this, follow these steps:

  1. Set up a personal R package library location using bash (this step can be done using file explorer)

    cd /path/to/personal_folder
    mkdir Rpackages
    
  2. Install and load packages from CRAN, BioConductor, and GitHub in R

    #CRAN
    install.packages("ggplot2", lib="/path/to/personal_folder/Rpackages")
    library("ggplot2", lib.loc="/path/to/personal_folder/Rpackages")
    
    #BioConductor
    install.packages("BiocManager", lib="/path/to/personal_folder/Rpackages")
    library(BiocManager, lib.loc="/path/to/personal_folder/Rpackages")
    BiocManager::install("GenomicFeatures", lib="/path/to/personal_folder/Rpackages")
    library(GenomicFeatures, lib.loc="/path/to/personal_folder/Rpackages")
    
    #devtools
    install.packages("devtools", lib="/path/to/personal_folder/Rpackages")
    library(devtools, lib.loc="/path/to/personal_folder/Rpackages")
    devtools::install_github("Displayr/flipTransformations", lib="/path/to/personal_folder/Rpackages")
    library("flipTransformations", lib.loc="/path/to/personal_folder/Rpackages")
    
  3. Mount library locations to .libPaths() and load packages without specifying lib.loc

    Please note: it may take ~5 minutes before these packages become visible after the library paths have been mounted to .libPaths().

    .libPaths(c( .libPaths(), "/path/to/personal_folder/Rpackages"))
    library(tidyverse)
    

    The following code may be run before and after the above commands to check this step has been successful:

    table(as.data.frame(installed.packages())$LibPath)
    print(table)
    

Request packages

If you encounter an error when trying to install an R package, please feel free to raise a ticket through the Service Desk portal. In your ticket, please include the following:

  • Version of R being used
  • Name of the package causing the error
  • Command being used
  • Relevant error messages or a screenshot of the observed behaviour