Rstudio

Rstudio

Compute Resources

storageN

  • The use of storageN within these documents indicates that any storage platform can be used.

  • Current available storage platforms:

    • storage1

    • storage2

    • storage3

Image Details

Initial Setup for Package Installation

You $HOME directory is limited to a 10GB of space. This can cause space issue if Rstudio package directory is not configured. This is a highly recommended step.

You can do so by first creating a file in your home directory called .Rprofile, if it doesn’t already exist. This file will be loaded automatically when RStudio starts.

Step 1.
Login to Compute1 via terminal and then backup .Rprofile file (if already exist)

mv ~/.Rprofile ~/.Rprofile.bak

Step 2.

Create a new.Rprofilefile

> touch ~/.Rprofile

Step 3.

Next, create a folder in your storage allocation for R packages.

mkdir /storageN/fs1/${STORAGE_ALLOCATION}/Active/R_libraries/

Storage Allocation Name:

Make sure to use correct path in the examples above, replace storageN and ${STORAGE_ALLOCATION} with the same name as the name of your storage allocation.

Step 4.
Use any command line based text edit such as vim or nano to edit the .Rprofile file and add below contents. You can also use Files Browser in On-Demand portal to edit this file.

vals <- paste('/storageN/fs1/${STORAGE_ALLOCATION}/Active/R_libraries/',paste(R.version$major,R.version$minor,sep="."),sep="") for (devlib in vals) { if (!file.exists(devlib)) dir.create(devlib) x <- .libPaths() x <- .libPaths(c(devlib,x)) } rm(x,vals)


Example of .Rprofile in $HOME directory:

Now that the .Rprofile file is created, you can install additional R packages using install.packages(). Please see https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/install.packages  for more information.

Please note, R installs a default set of packages during installation. The list of installed packages can be viewed in the lower right pane of RStudio, with currently active packages indicated with a checkmark.

image-20250313-192005.png

Interactive GUI Session

Environment Variables

  • This information should be space separated in the field.

PASSWORD=password
  • Optional variables

    • GUI display size. This can be changed with the following variables.

      • Width default: 1024

      • Height default: 768

    DISPLAY_WIDTH=<width> DISPLAY_HEIGHT=<height>

Docker Image

ghcr.io/washu-it-ris/rstudio:<tag>

RStudio Docker Tag:

The <tag> will refer to the version of RStudio in the Docker container. Please click here to see a current list of available RStudio versions and their corresponding Docker images.

  • Fill out the rest of the fields with the appropriate information (explained in the quick start).

  • Launch the job through the methods described in the quick start.

  • Once in an interactive RStudio session using the following command:

> rstudio

You should now see the RStudio GUI

image-20250313-192033.png

You can safely ignore XDG_RUNTIME_DIR and Session version X does not match server version X warning that may appear when starting Rstudio.

Interactive Command-Line Session

  • If you wish to use R in an interactive command-line session, you can do so with the following commands.

export LSF_DOCKER_VOLUMES="/storage1/fs1/${STORAGE_ALLOCATION}/Active:/storage1/fs1/${STORAGE_ALLOCATION}/Active" bsub -Is -q general-interactive -a 'docker(ghcr.io/washu-it-ris/rstudio:<tag>)' /bin/bash

Availability Through Open On Demand (OOD)

Interactive Application: RStudio

  • Start an instance of RStudio (interactive application: RStudio) in OOD.

  • RStudio will start at time of launch.

Interactive Application: Custom noVNC Image

  • Start an instance of Custom noVNC Image in OOD denoting the preferred RStudio image and tag.

  • Launch the session and enter rstudio in the terminal.

 

Accessing Data from Storage in OOD RStudio App

Make sure you have provided your storage allocation path in the MOUNTS field of the open-ondemand portal (in the correct format), one example would be:

/storageN/fs1/${STORAGE_ALLOCATION}/Active:/storageN/fs1/${STORAGE_ALLOCATION}/Active

Once an Rstudio session start, change the current working directory, run the below command on the left hand side command pane:

setcwd('/storageN/fs1/${STORAGE_ALLOCATION}/Active')

Then, on the right hand side, under files tab → Click Gear icon 'More' → Click 'Go To Working Directory'

Do not forget to replace the actual path in above command/places

Rstudio Session
RStudio OOD Session

RStudio using THPC

  • Start an instance of THPC (interactive application: Compute RIS Desktop) in OOD.

  • Load and launch RStudio-server through the terminal.

module load RStudio-Server rstudio-server start
  • After launching RStudio, you need to open a new shell.

    • Right click in the noVNC window.

    • Select “Application” > “Shell” > “Bash”

image-20250313-192048.png
  • Finally, you need to load and launch Firefox, connecting to RStudio, in the new shell.

module load Firefox firefox http://localhost:8787

Extending the RStudio Docker Image

The steps in the initial setup will work for some but not all R packages. For example, devtools requires the following dependencies to be installed to the Docker image: build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev.

This will require extending the existing Docker image to include these dependencies. Below is a sample Dockerfile that includes these dependencies. Please see this section for more information on setting the Docker tag in the Dockerfile.

Dockerfile Best Practices:

It is recommended to set the Docker tag to a specific R version. This will prevent using an updated version of the RIS RStudio image, which may have compatibility issues with R packages previously installed. As an example, in the Dockerfile below, the tag is set to 3.6.3.

FROM gcr.io/ris-registry-shared/rstudio:3.6.3 # install packages using apt-get ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update --fix-missing && \ apt-get install -y build-essential \ libcurl4-gnutls-dev libxml2-dev \ libssl-dev && \ apt-get clean # extend image to include tidyverse and devtools R packages RUN R -e "install.packages(c('devtools','tidyverse'), dependencies=TRUE)"

Please see our Docker Tutorial for more information on building and pushing a Docker image. You can also open a ticket at our Service Desk for further help.

Available RStudio Versions

Current Version:

  • Stand Alone Docker Image Version

    • ghcr.io/washu-it-ris/rstudio

      • 4.4.0

  • THPC Version

    • 4.2.1