leafcutter icon indicating copy to clipboard operation
leafcutter copied to clipboard

Leafcutter Singularity Recipe

Open Iain-S opened this issue 4 years ago • 1 comments

Hi David

I struggled to get leafcutter set up using the info on the installation page. In particular:

  • it doesn't seem to work with R > v4 and installing a compatible version of r-stan installed was tricky.
  • I had to build samtools and regtools from source
  • Getting leafviz to work required a number of extra conda and centos packages

Please find below my singularity .def file and conda .yml file, which may be of use.

All the best

Iain

singularity-leafcutter-0.2.def

Bootstrap: docker
From: centos:7.7.1908

%help
    Singularity container with Leafcutter
    Built with Singularity v3.5.3

%files
    ./R332.yml /envs/R332.yml

%post
    # Installation dependencies
    yum install -y wget
    yum group install -y "Development Tools"
    yum install -y cmake
    yum install -y zlib-devel

    # For leafviz
    yum install -y libXrender-devel libSM libXext xorg-x11-fonts-Type1

    # Download miniconda
    MINICONDA=Miniconda2-py27_4.8.3-Linux-x86_64.sh
    wget --no-clobber https://repo.anaconda.com/miniconda/$MINICONDA

    # Check the integrity of miniconda
    SHA256=b820dde1a0ba868c4c948fe6ace7300a252b33b5befd078a15d4a017476b8979
    echo "$SHA256 $MINICONDA" > miniconda.sha256
    sha256sum --check miniconda.sha256

    # Install miniconda
    chmod +x $MINICONDA
    ./$MINICONDA -b -p /usr/local/miniconda2
    rm $MINICONDA

    # Activate the conda base environment
    source /usr/local/miniconda2/bin/activate

    # Make and activate a new conda environment
    mkdir -p /envs
    conda env create -f /envs/R332.yml --prefix=/envs/R332
    conda activate /envs/R332

    # Avoids a locale warning from R
    export LC_ALL=C

    # Install R libraries to the container
    mkdir /rlibs
    export R_LIBS_USER=/rlibs

    # Install stringi (undocumented dependency of leafcutter?)
    R -e "install.packages(\"stringi\", repos=\"https://cran.ma.imperial.ac.uk/\")"

    # Install regtools
    git clone https://github.com/griffithlab/regtools
    cd regtools/
    mkdir build
    cd build/
    cmake ..
    make
    cp regtools /usr/bin/
    cd ../../

    # Install samtools
    SAMTOOLS=samtools-1.10.tar.bz2
    wget --no-clobber https://github.com/samtools/samtools/releases/download/1.10/$SAMTOOLS
    tar -jxvf $SAMTOOLS
    rm $SAMTOOLS
    cd samtools-1.10
    ./configure --without-curses --disable-bz2 --disable-lzma
    make
    make install
    cd ../

    # Free up some space
    yum group remove -y "Development Tools"
    yum remove -y zlib-devel cmake wget
    yum clean all

%environment
    export LC_ALL=C
    export R_LIBS_USER=/rlibs
    echo "Activating leafcutter conda environment....."
    source /usr/local/miniconda2/bin/activate
    conda activate /envs/R332

%test
    source /usr/local/miniconda2/bin/activate
    conda activate /envs/R332

    # Test Python
    python --version 2>&1 | grep -q "Python 2.7"

    # Test R
    R --version | grep -q "R version 3.3.2"

    # Test leafcutter
    R -e "packageVersion(\"leafcutter\")==0.2" | grep -q TRUE

    # Test samtools
    samtools 2>&1 | grep -q "Version: 1."

    # Test regtools
    regtools 2>&1 | grep -q "Version:.*0.5"

    echo "passed"

leafcutter-conda-env.yml

name: R332
channels:
  - davidaknowles
  - r
  - conda-forge
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - _r-mutex=1.0.0=anacondar_1
  - bzip2=1.0.8=h7b6447c_0
  - ca-certificates=2020.7.22=0
  - cairo=1.14.6=4
  - curl=7.54.1=0
  - fontconfig=2.12.1=6
  - freetype=2.7=1
  - gettext=0.19.8.1=h9b4dc7a_1
  - glib=2.51.4=0
  - graphite2=1.3.14=h23475e2_0
  - gsl=2.4=h14c3975_4
  - harfbuzz=1.4.3=0
  - icu=58.2=he6710b0_3
  - jpeg=9b=h024ee3a_2
  - krb5=1.14.2=h56d4222_4
  - libffi=3.3=he6710b0_2
  - libgcc=7.2.0=h69d50b8_2
  - libgcc-ng=9.1.0=hdf63c60_0
  - libiconv=1.15=h63c8f33_5
  - libpng=1.6.28=1
  - libssh2=1.8.0=h9cfc8f7_4
  - libstdcxx-ng=9.1.0=hdf63c60_0
  - libtiff=4.0.7=0
  - libxml2=2.9.5=0
  - ncurses=5.9=10
  - openssl=1.0.2u=h7b6447c_0
  - pango=1.40.4=0
  - pcre=8.44=he6710b0_0
  - pixman=0.34.0=hceecf20_3
  - r-acepack=1.4.1=r3.3.2_0
  - r-assertthat=0.1=r3.3.2_4
  - r-base=3.3.2=5
  - r-bh=1.62.0_1=r3.3.2_0
  - r-cairo=1.5_9=r3.3.2_1
  - r-cluster=2.0.5=r3.3.2_0
  - r-codetools=0.2_15=r3.3.2_0
  - r-colorspace=1.3_1=r3.3.2_0
  - r-data.table=1.10.0=r3.3.2_0
  - r-dbi=0.5_1=r3.3.2_0
  - r-dichromat=2.0_0=r3.3.2_2
  - r-digest=0.6.10=r3.3.2_0
  - r-domc=1.3.4=r3.3.2_0
  - r-dplyr=0.5.0=r3.3.2_0
  - r-dt=0.2=r3.3.2_0
  - r-evaluate=0.10=r3.3.2_0
  - r-foreach=1.4.3=r3.3.2_0
  - r-foreign=0.8_67=r3.3.2_0
  - r-formula=1.2_1=r3.3.2_0
  - r-getopt=1.20.0=r3.3.2_0
  - r-ggplot2=2.2.0=r3.3.2_0
  - r-ggrepel=0.7.0=r3.3.2_0
  - r-glue=1.2.0=r3.3.2_0
  - r-gridextra=2.2.1=r3.3.2_0
  - r-gtable=0.2.0=r3.3.2_0
  - r-highr=0.6=r3.3.2_0
  - r-hmisc=4.0_0=r3.3.2_0
  - r-htmltable=1.7=r3.3.2_0
  - r-htmltools=0.3.5=r3.3.2_0
  - r-htmlwidgets=0.8=r3.3.2_0
  - r-httpuv=1.3.3=r3.3.2_0
  - r-inline=0.3.14=r3.3.2_0
  - r-intervals=0.15.1=r341h749c5bb_0
  - r-iterators=1.0.8=r3.3.2_0
  - r-jsonlite=1.1=r3.3.2_0
  - r-knitr=1.15.1=r3.3.2_0
  - r-labeling=0.3=r3.3.2_2
  - r-lattice=0.20_34=r3.3.2_0
  - r-latticeextra=0.6_28=r3.3.2_0
  - r-lazyeval=0.2.0=r3.3.2_0
  - r-leafcutter=0.2=r3h6b519b2_0
  - r-magrittr=1.5=r3.3.2_2
  - r-markdown=0.7.7=r3.3.2_2
  - r-mass=7.3_45=r3.3.2_0
  - r-matrix=1.2_7.1=r3.3.2_0
  - r-mime=0.5=r3.3.2_0
  - r-miniui=0.1.1=r3.3.2_0
  - r-munsell=0.4.3=r3.3.2_0
  - r-nnet=7.3_12=r3.3.2_0
  - r-optparse=1.4.4=r341he427c5d_0
  - r-plyr=1.8.4=r3.3.2_0
  - r-r.methodss3=1.7.1=r3.3.2_0
  - r-r.oo=1.21.0=r3.3.2_0
  - r-r.utils=2.5.0=r3.3.2_0
  - r-r6=2.2.0=r3.3.2_0
  - r-rcolorbrewer=1.1_2=r3.3.2_3
  - r-rcpp=0.12.8=r3.3.2_0
  - r-rcppeigen=0.3.2.9.0=r3.3.2_0
  - r-reshape2=1.4.2=r3.3.2_0
  - r-rpart=4.1_10=r3.3.2_0
  - r-rstan=2.12.1=r3.3.2_0
  - r-scales=0.4.1=r3.3.2_0
  - r-shiny=0.14.2=r3.3.2_0
  - r-shinycssloaders=0.2.0=r341hc0feee7_0
  - r-shinyjs=0.8=r3.3.2_0
  - r-sourcetools=0.1.5=r3.3.2_0
  - r-stanheaders=2.12.0_1=r3.3.2_0
  - r-stringi=1.1.2=r3.3.2_0
  - r-stringr=1.1.0=r3.3.2_0
  - r-survival=2.40_1=r3.3.2_0
  - r-tibble=1.2=r3.3.2_0
  - r-viridis=0.3.4=r3.3.2_0
  - r-xtable=1.8_2=r3.3.2_0
  - r-yaml=2.1.14=r3.3.2_0
  - readline=6.2=0
  - tk=8.5.19=2
  - xz=5.2.5=h7b6447c_0
  - zlib=1.2.8=3
prefix: /usr/local/miniconda2/envs/R332

Iain-S avatar Oct 05 '20 10:10 Iain-S

Thank you so much @Iain-S, you saved me! I basically created an environment from the above yml file: conda env create -f leafcutter-conda-env.yml This didn't directly worked for me since some R packages were missing. I installed them as below:

source("https://bioconductor.org/biocLite.R")
biocLite("DirichletMultinomial")
biocLite("Biobase")
install.packages("TailRank")

After these steps, I was able to run leafcutterMD.R!

hkmztrk avatar May 22 '21 22:05 hkmztrk