BootStrap: docker
From: ubuntu:18.04

%help 
This is a singularity container packing R version 3.6.3 and all the dependencies necessary to run the outrider ("Outlier in rnaseq finder") package, version 1.4.2, for rnaseq analysis.
(BiocManager version : 3.10)
built-in R packages are installed in /usr/lib/R/library
other R packages were added in /usr/local/lib/R/site-library
Authors : valentin.vautrot@u-bourgogne.fr

%post

export R_VERSION=3.6.3
echo "export R_VERSION=${R_VERSION}" >> $SINGULARITY_ENVIRONMENT
export DEBIAN_FRONTEND=noninteractive

apt-get update
apt-get install -y --no-install-recommends apt-utils
apt-get install -y --no-install-recommends \
    locales \
    software-properties-common \
    dirmngr \
    wget \

wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/"
apt update

apt-get install -y --no-install-recommends -t bionic-cran35 r-base=${R_VERSION}-1bionic r-recommended=${R_VERSION}-1bionic r-base-core=${R_VERSION}-1bionic r-base-dev=${R_VERSION}-1bionic r-base-html=${R_VERSION}-1bionic r-doc-html=${R_VERSION}-1bionic
# TO DO : test removing of r-base-core, r-doc-html and r-base-html which in theory are not necessary. Or replace r-base with r-base-core to remove R documentation and lighten the image.

apt-get install -y --no-install-recommends libcurl4-openssl-dev libxml2-dev libssl-dev libfontconfig1-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev

# install R packages :
Rscript -e 'install.packages("devtools")'
Rscript -e 'devtools::install_version("XML", version ="3.98.1.20", repos = "https://cran.r-project.org")'
Rscript -e 'devtools::install_version("htmlTable", version ="1.13.3", repos = "https://cran.r-project.org")'
Rscript -e 'devtools::install_version("locfit", version ="1.5.9.1", repos = "https://cran.r-project.org")'
Rscript -e 'devtools::install_version("Hmisc", version ="4.3.0", repos = "https://cran.r-project.org")'
Rscript -e 'install.packages("BiocManager", dependencies=TRUE)'
Rscript -e 'BiocManager::install("OUTRIDER", version = "3.10")'

# Clean up
rm -rf /var/lib/apt/lists/*

%test
echo "installed R version :"
R --version
echo "installed OUTRIDER package version :"
Rscript -e 'packageVersion("OUTRIDER")'

%labels 
Auhtors valentin.vautrot@u-bourgogne.fr
Contained_OS_version Ubuntu_18.04_LTS_BionicBeaver
Contained_R_version 3.6.3
Contained_OUTRIDER_version 1.4.2