FAQs
Why can't my R package be installed?
Luria has multiple versions of R available through the environment modules system. Sometimes, R packages install normally. However, other times there may be incompatibilities between the versions of R installed on Luria and the R package you're trying to install or a dependency that an R package needs is not installed on Luria.
In cases like this, you'll likely to need to use R from a Singularity image.
Using R from Singularity
The Rocker project creates OCI images that come pre-installed with R. Each image is geared toward a specific use-case. The r-ver images can be used for when you only need the R command line. The rest of the images come pre-installed with RStudio.
To use one of these images, follow these instructions on Luria:
module load singularity/3.10.4
# Replace 4.2.0 with the version of R you need.
# The first time this runs, Singularity will pull
# the image, which may take around 5 - 10 minutes.
# Subsequent times will be immediate. `-B /net:/net`
# is used to make sure your entire home directory is
# available inside of the container.
singularity exec -B /net:/net docker://rocker/r-ver:4.2.0 R
# You will now have an R 4.2.0 session running. Run
# install.packages("YOUR PACKAGE") and type "y" if
# R prompts you to create a user library
R>If you want to use R in a script, such as when writing a script to submit to Slurm, you'll need to first load Singularity, then replace any calls to Rscript with the full container invocation. For example:
#!/bin/bash
#SBATCH -n 4
#SBATCH --email-type=END
#SBATCH [email protected]
# Load in Singularity
module load singularity/3.10.4
# Replace `Rscript` with the full call to the
# Rscript inside of the Singularity container.
singularity exec -B /net:/net docker://rocker/r-ver:4.2.0 Rscript /path/to/your.RscriptThe BioMicro Center has an image that contains R, RStudio, and the suite of Seurat tools preinstalled (asoberan/abrfseurat:20250910). To use this image, you can replace docker://rocker/r-ver:4.2.0 with docker://asoberan/abrfseurat:20250910 in the examples above.
Using RStudio from Singularity
You can take advantage of Singularity images that come with RStudio preinstalled to use RStudio on the cluster.
To use RStudio on the cluster, simply copy the following text into a file on the cluster. Name the file something relevant, such as rstudio.sh . Then, submit this file to Slurm using sbatch.
sbatch rstudio.shWhen running this file for the first time, give it about 7-10 minutes to download the Singularity image. After those 7-10 minutes, Slurm will create an output file that contains instructions at the top on how to access the RStudio server on your workstation's web browser.
#!/bin/bash
#SBATCH --job-name=Rstudio # Assign an short name to your job
#SBATCH --output=slurm.%N.%j.out # STDOUT output file
module load singularity/3.10.4
workdir=$(python -c 'import tempfile; print(tempfile.mkdtemp())')
mkdir -p -m 700 ${workdir}/run ${workdir}/tmp ${workdir}/var/lib/rstudio-server
cat > ${workdir}/database.conf <<END
provider=sqlite
directory=/var/lib/rstudio-server
END
cat > ${workdir}/rsession.sh <<END
#!/bin/sh
export OMP_NUM_THREADS=${SLURM_JOB_CPUS_PER_NODE}
exec /usr/lib/rstudio-server/bin/rsession "\${@}"
END
chmod +x ${workdir}/rsession.sh
export SINGULARITY_BIND="${workdir}/run:/run,${workdir}/tmp:/tmp,${workdir}/database.conf:/etc/rstudio/database.conf,${workdir}/rsession.sh:/etc/rstudio/rsession.sh,${workdir}/var/lib/rstudio-server:/var/lib/rstudio-server"
export SINGULARITYENV_RSTUDIO_SESSION_TIMEOUT=0
export SINGULARITYENV_USER=$(id -un)
export SINGULARITYENV_PASSWORD=$(echo $RANDOM | base64 | head -c 20)
readonly PORT=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')
cat 1>&2 <<END
1. SSH tunnel from your workstation using the following command:
ssh -t -L 8787:localhost:${PORT} ${SINGULARITYENV_USER}@luria.mit.edu ssh -t ${HOSTNAME} -L ${PORT}:localhost:${PORT}
and point your web browser to http://localhost:8787
2. log in to RStudio Server using the following credentials:
user: ${SINGULARITYENV_USER}
password: ${SINGULARITYENV_PASSWORD}
When done using RStudio Server, terminate the job by:
1. Exit the RStudio Session ("power" button in the top right corner of the RStudio window)
2. Issue the following command on the login node:
scancel -f ${SLURM_JOB_ID}
END
singularity exec -B /net:/net docker://asoberan/abrfseurat:20250910 /usr/lib/rstudio-server/bin/rserver \
--server-user ${USER} --www-port ${PORT} \
--auth-none=0 \
--auth-pam-helper-path=pam-helper \
--auth-stay-signed-in-days=30 \
--auth-timeout-minutes=0 \
--rsession-path=/etc/rstudio/rsession.sh
printf 'rserver exited' 1>&2For more information on Singularity, visit the following page:
Running Images in SingularityLast updated
Was this helpful?
