Skip to content

SamThilmany/JupyterLab-with-R_Docker-Environment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JupyterLab R Environment

A Reproducible Docker Environment for Statistical Analysis in R

Version 2.1.0

A Docker-based JupyterLab environment with R as the kernel, designed for reproducible data analysis. All R and Python package versions are pinned via renv.lock and requirements.txt so that the analysis environment can be reconstructed exactly on any machine.

Table of Contents

  1. Getting Started
  2. HTTPS Support
  3. Package Management
  4. Pre-installed R Packages
  5. Pre-installed Bioconductor Packages
  6. Versioning
  7. License

Getting Started

Prerequisites

(back to top)

Installation

1. Clone the Repository

git clone git@github.com:SamThilmany/JupyterLab-with-R--Docker-Environment.git
cd JupyterLab-with-R--Docker-Environment

2. Build the Docker Image

cd jupyter-r
docker compose build

The image is pinned to linux/amd64 because rawrr's .NET assembly is only available as an x86-64 binary on Linux. On Apple Silicon (M1/M2/M3/…), Docker Desktop runs the container via Rosetta 2 — no additional configuration is required.

Building downloads all R and Python packages and may take several minutes depending on network speed. If the build fails due to a transient download error, re-running the command is safe — Docker caches completed layers and renv retries failed package downloads automatically.

3. Start the Container

docker compose up -d

The container restarts automatically after Docker Desktop or system restarts.

4. Access JupyterLab

Open a browser and navigate to:

  • https://localhost:8888 — if HTTPS certificates are configured (see below)
  • http://localhost:8888 — fallback when no certificates are present

5. Stop the Container

docker compose down

(back to top)

HTTPS Support

JupyterLab can be served over HTTPS using a locally-trusted certificate generated by mkcert. This avoids browser security warnings without requiring any exceptions to be added manually.

macOS

brew install mkcert
mkcert -install

mkdir -p jupyter-r/certs
cd jupyter-r/certs
mkcert localhost 127.0.0.1
mv localhost+1.pem cert.pem
mv localhost+1-key.pem key.pem

Windows

choco install mkcert
mkcert -install

mkdir jupyter-r\certs
cd jupyter-r\certs
mkcert localhost 127.0.0.1
Rename-Item localhost+1.pem cert.pem
Rename-Item localhost+1-key.pem key.pem

After placing the certificate files, restart the container:

docker compose restart jupyter

The server falls back to HTTP automatically when no certificate files are present, so the setup remains functional on machines without mkcert configured.

Note: The jupyter-r/certs/ directory is excluded from version control. Do not commit certificate files.

(back to top)

Package Management

R packages are installed from renv.lock, which records the exact version of every package in the image. Python packages are pinned in requirements.txt. Both files are committed to the repository to ensure that any rebuild produces an identical environment.

Adding R Packages

  1. Add the package name to the appropriate list in jupyter-r/install_packages.R.
  2. Delete jupyter-r/renv.lock to force a fresh install.
  3. Rebuild the image:
    docker compose build
  4. On the next docker compose up, the updated renv.lock is copied to the notebooks/ directory. Move it to jupyter-r/ and commit it:
    mv notebooks/renv.lock jupyter-r/renv.lock
    git add jupyter-r/renv.lock
    git commit -m "add <package-name>"

(back to top)

Pre-installed R Packages

Package Description
IRkernel, IRdisplay, repr R kernel for JupyterLab
languageserver R language server for editor support
devtools Package development tools
tidyverse Collection of data science packages (dplyr, ggplot2, tidyr, …)
ggplot2 Grammar of graphics plotting
ggfortify ggplot2 extensions for statistical objects
ggforce ggplot2 extension with additional geoms
ggtext Markdown and HTML text rendering in ggplot2
ggrepel Non-overlapping text labels for ggplot2
GGally ggplot2 extension for matrix plots and model diagnostics
ggVennDiagram Venn diagram geoms for ggplot2
eulerr Euler and Venn diagrams
patchwork Composing multiple ggplot2 panels
cowplot Plot arrangement and annotation
metR Meteorological and geophysical field visualisation
scales Scale functions for visualisation
showtext Custom font rendering in R graphics
RColorBrewer Colour palettes for data visualisation
doParallel Parallel computing backend
combinat Combinatorics utilities
s2 Spherical geometry

(back to top)

Pre-installed Bioconductor Packages

Package Description
rawrr Direct access to Thermo raw mass spectrometry data
limma Linear models for microarray and RNA-seq data
fgsea Fast gene set enrichment analysis
clusterProfiler Statistical analysis of functional gene clusters
enrichplot Visualisation of functional enrichment results
DOSE Disease ontology semantic and enrichment analysis
biomaRt Interface to BioMart databases (Ensembl, etc.)
AnnotationDbi Annotation database interface
org.Hs.eg.db Human genome-wide annotation
ComplexHeatmap Complex heatmap and annotation visualisation
circlize Circular visualisation
MSstats Statistical analysis of quantitative mass spectrometry data
MSstatsTMT MSstats extension for TMT labelling experiments

(back to top)

Versioning

Semantic Versioning is used for versioning. For available versions, see the Releases.

(back to top)

License

This project is distributed under the Apache License 2.0. See LICENSE for more information.

(back to top)

About

Get started with data science using the JupyterLab Environment for Statistical Analysis using R! Run JupyterLab with R as the default language, pre-configured with essential dependencies and popular packages. Enjoy an isolated workspace for reproducible and collaborative data science workflows.

Resources

License

Stars

Watchers

Forks

Contributors