Skip to content

Supplementary: Singularity Container Setup

Ryan Mulqueen edited this page Jun 22, 2024 · 3 revisions

For students:

Download the singularity images off of sylabs singularity hub with commands:

singularity pull library://rmulqueen/cshl_course/scrna:latest #for scrna workshops
singularity pull library://rmulqueen/cshl_course/scdna:latest #for scdna workshops
singularity pull library://kris69w/cshl_course/spatial_celltrek:latest #for visium spatial workshops
#singularity pull library://rmulqueen/cshl_course/spatial:latest #for curio spatial workshops #not yet hosted

For Navin Lab instructors:

SIF Files for workshops locally located here:

/volumes/USR2/Ryan/projects/cshl_workshops/cshl_singularity/scdna.sif #dna for kris workshop
/volumes/USR2/Ryan/projects/cshl_workshops/cshl_singularity/scrna.sif #rna for yiyun, chenling, ryan workshop
/volumes/USR2/Ryan/projects/cshl_workshops/cshl_singularity/spatial.sif #spatial for ping, aatish workshops

Detailed singularity file creations.

Single cell RNA

Built off the rocker/rstudio docker file to have Rstudio support.

Contains:

  • seuratv5
  • copyKAT
  • inferCNV
  • harmony
  • batchelor
  • singleR
  • fastMNN
  • LIGER

scrna.def

Bootstrap: docker
From: rocker/rstudio:latest

%environment
    # set up all essential environment variables
    export LC_ALL=C
    export PATH=/opt/miniconda3/bin:$PATH
    export PYTHONPATH=/opt/miniconda3/lib/python3.9/:$PYTHONPATH

%post
 
	# update and install essential dependencies
	apt-get -y update
	apt-get update && apt-get install -y automake \
	build-essential \
	bzip2 \
	wget \
	git \
	default-jre \
	unzip \
	zlib1g-dev \
	parallel \
	libhdf5-dev \
	libfl-dev

	# download, install, and update miniconda3
	wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
	bash Miniconda3-latest-Linux-x86_64.sh -b -f -p /opt/miniconda3/
	rm Miniconda3-latest-Linux-x86_64.sh
	chmod --recursive a+rw /opt/miniconda3

	# activate conda
	export PATH="/opt/miniconda3/bin:$PATH"

	#build full conda environment for sif
	conda install -y -c conda-forge mamba 
	conda config --add channels bioconda
	conda config --add channels conda-forge
	
	# denotes installed in sandbox without error
	#install additional tools
	mamba install -y -f \
	bioconda::bwa \
	bioconda::samtools \
	bioconda::bedtools \
	bioconda::fastqc \
	bioconda::multiqc \
	anaconda::graphviz \
	conda-forge::parallel \
	conda-forge::ncurses 

	#install base R packages
	conda install -y -f r-base=4.2 #
	mamba install -y -f conda-forge::r-devtools
	mamba install -y -f conda-forge::r-remotes
	mamba install -y -f conda-forge::r-essentials
	mamba install -y -f conda-forge::r-biocmanager=1.30.19
	mamba install -y -f conda-forge::r-rlang
	mamba install -y -f conda-forge::r-ggplot2 

	#R utility libraries
	R --slave -e 'install.packages("circlize", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("optparse", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("patchwork", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("plyr", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("stringr", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("tidyverse", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("RColorBrewer", repos="http://cran.us.r-project.org")' #
	mamba install -y -f conda-forge::r-hdf5r #

	#Bioconductor packages through conda
	mamba install -y -f bioconda::bioconductor-biocparallel 
	mamba install -y -f bioconda::bioconductor-bsgenome.hsapiens.ucsc.hg38 
	mamba install -y -f bioconda::bioconductor-ensdb.hsapiens.v86 
	mamba install -y -f bioconda::bioconductor-org.hs.eg.db 
	mamba install -y -f bioconda::bioconductor-txdb.hsapiens.ucsc.hg38.knowngene 
	mamba install -y -f bioconda::bioconductor-decoupler 
	mamba install -y -f bioconda::bioconductor-scran 
	mamba install -y -f bioconda::bioconductor-infercnv 
	mamba install -y -f bioconda::bioconductor-complexheatmap 
	mamba install -y -f bioconda::bioconductor-biovizbase 
	mamba install -y -f bioconda::bioconductor-singler 
	mamba install -y -f bioconda::bioconductor-batchelor

	#Funner stuff!
	R --slave -e 'install.packages("rliger", repos="http://cran.us.r-project.org")' #
	R --slave -e 'devtools::install_github("navinlabcode/copykat")'
	R --slave -e 'install.packages("Seurat", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("harmony", repos="http://cran.us.r-project.org")'
	R --slave -e 'install.packages("R.utils", repos="http://cran.us.r-project.org")'
	R --slave -e 'remotes::install_github("satijalab/seurat-wrappers")'

	#install scvi-tools for integration
	conda create -n scvi-env \
	python=3.9 \
	conda-forge::scvi-tools \
	scanpy \
	python-igraph \
	leidenalg

#Changelog v0.2:
#added changed r irlba and rmatrix installation due to an error in newer matrix installs. 

%labels
    Author Ryan Mulqueen
    Version v0.2
    MyLabel scRNA

To build the container and push to public repo:

singularity build --fakeroot scrna.sif scrna.def

singularity key newpair #run once, generate key pair for signing sifs
#passphrase is cshl
singularity sign scrna.sif

singularity push scrna.sif library://rmulqueen/cshl_course/scrna:latest #push
singularity singularity pull --name cshl_scrna.sif library://rmulqueen/cshl_course/scrna #test pull

Spatial transcriptomics

Built off the rocker/rstudio docker file to have Rstudio support.

Contains:

  • R 4.4
  • seuratv5
  • celltrek
  • hdf5r
  • arrow
  • ggplot2
  • patchwork
  • dplyr
  • remotes
  • Banksy
  • spacexr

Files:

  • Allen Brainspan reference file. Location in container: /data/allen_scRNAseq_ref.Rds
  • Preprocessed Spatial data file. Location in container: /data/braindataset.Rds

spatial.def

Bootstrap: docker
From: rocker/rstudio:latest

%environment
	# set up all essential environment variables
	export PATH=/opt/miniconda3/bin:$PATH
	export PYTHONPATH=/opt/miniconda3/lib/python3.9/:$PYTHONPATH
	export LC_ALL=C.UTF-8

%files
	/volumes/USR2/Aatish/Projects/Curiodata/allen_scRNAseq_ref.Rds /data/allen_scRNAseq_ref.Rds
	/volumes/USR2/Aatish/Projects/Curiodata/PingBraindatasetsketcheddownsampledwithBANKSYandRCTD.rds /data/braindataset.Rds
%post
	# update and install essential dependencies
	apt-get -y update
	apt-get update && apt-get install -y automake \
	build-essential \
	bzip2 \
	wget \
	git \
	default-jre \
	unzip \
	zlib1g-dev \
	parallel \
	libglpk40 \
	gfortran

	# download, install, and update miniconda3
	wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
	bash Miniconda3-latest-Linux-x86_64.sh -b -f -p /opt/miniconda3/
	rm Miniconda3-latest-Linux-x86_64.sh

	# install dependencies via conda
	export PATH="/opt/miniconda3/bin:$PATH"
	conda install -y -c conda-forge mamba 

	#install R packages
	mamba install -y -f conda-forge::r-base=4.4
	mamba install -y -f conda-forge::r-devtools
	mamba install -y -f conda-forge::r-remotes
	mamba install -y -f conda-forge::r-essentials
	mamba install -y -f conda-forge::r-biocmanager=1.30.19
	mamba install -y -f conda-forge::r-rlang
	mamba install -y -f conda-forge::r-ggplot2 

	#R utility libraries
	R --slave -e 'install.packages("remotes", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("circlize", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("optparse", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("patchwork", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("plyr", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("stringr", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("tidyverse", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("RColorBrewer", repos="http://cran.us.r-project.org")' #
	mamba install -y -f conda-forge::r-hdf5r #
	mamba install -y -f conda-forge::r-arrow #


	#Funner stuff!
	R --slave -e 'install.packages("Seurat", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("harmony", repos="http://cran.us.r-project.org")'
	R --slave -e 'install.packages("R.utils", repos="http://cran.us.r-project.org")'
	R --slave -e 'remotes::install_github("satijalab/seurat-wrappers")'
	R --slave -e 'remotes::install_github("prabhakarlab/Banksy",ref="devel")'
	R --slave -e 'devtools::install_github("dmcable/spacexr", build_vignettes = FALSE)'


%labels
	Author Ryan Mulqueen
	Version v0.1
	MyLabel SpatialTranscriptomics
singularity build --fakeroot spatial.sif spatial.def

Spatial transcriptomics for CellTrek

Built off the rocker/rstudio docker file to have Rstudio support. Similar container to the first spatial transcriptomics one above, but with added files and downgraded seurat version for celltrek.

Contains:

  • R 4.1.2
  • seuratv4
  • celltrek
  • hdf5r
  • ggplot2
  • patchwork
  • dplyr

Files:

  • /volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/DCIS_SC.rds Location in container: /data/DCIS_SC.rds
  • /volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/DCIS_ST.rds Location in container: /data/DCIS_ST.rds
  • /volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/DCIS_traint.rds Location in container: /data/DCIS_traint.rds
  • /volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/DCIS_celltrek.rds Location in container: /data/DCIS_celltrek.rds
  • /volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/Processed_DCIS_ST.rds Location in container: /data/Processed_DCIS_ST.rds
  • /volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/RCTD.rds Location in container: /data/RCTD.rds
  • /volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/RCTD_full.rds Location in container: /data/RCTD_full.rds

spatial2.def

Bootstrap: docker
From: rocker/rstudio:latest

%environment
	# set up all essential environment variables
	export PATH=/opt/miniconda3/bin:$PATH
	export PYTHONPATH=/opt/miniconda3/lib/python3.9/:$PYTHONPATH
	export LC_ALL=C.UTF-8

%files
	/volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/DCIS_SC.rds /data/DCIS_SC.rds
	/volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/DCIS_ST.rds /data/DCIS_ST.rds
	/volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/DCIS_traint.rds /data/DCIS_traint.rds 
	/volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/DCIS_celltrek.rds /data/DCIS_celltrek.rds
	/volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/Processed_DCIS_ST.rds /data/Processed_DCIS_ST.rds
	/volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/RCTD.rds /data/RCTD.rds
	/volumes/USR1/pingxu/CSHL_course_2024_Summer/Spatial_transcriptomics/RCTD_full.rds /RCTD_full.rds
%post
	# update and install essential dependencies
	apt-get -y update
	apt-get update && apt-get install -y automake \
	build-essential \
	bzip2 \
	wget \
	git \
	default-jre \
	unzip \
	zlib1g-dev \
	parallel \
	libglpk40 \
	gfortran

	# download, install, and update miniconda3
	wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
	bash Miniconda3-latest-Linux-x86_64.sh -b -f -p /opt/miniconda3/
	rm Miniconda3-latest-Linux-x86_64.sh

	# install dependencies via conda
	export PATH="/opt/miniconda3/bin:$PATH"
	conda install -y -c conda-forge mamba 

	#install R packages
	mamba install -y -f conda-forge::r-base=4.1.2
	mamba install -y -f conda-forge::r-devtools
	mamba install -y -f conda-forge::r-remotes
	mamba install -y -f conda-forge::r-essentials
	mamba install -y -f conda-forge::r-biocmanager=1.30.19
	mamba install -y -f conda-forge::r-rlang
	mamba install -y -f conda-forge::r-ggplot2 

	#R utility libraries
	R --slave -e 'install.packages("remotes", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("circlize", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("optparse", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("patchwork", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("plyr", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("stringr", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("tidyverse", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("RColorBrewer", repos="http://cran.us.r-project.org")' #
	mamba install -y -f conda-forge::r-hdf5r #
	mamba install -y -f conda-forge::r-arrow #

	R --slave -e 'remotes::install_version("Seurat", "4.3.0", repos = c("https://satijalab.r-universe.dev", getOption("repos")))'
	R --slave -e 'remotes::install_version("SeuratObject", "4.1.4", repos = c("https://satijalab.r-universe.dev", getOption("repos")))'

	#Funner stuff!
	R --slave -e 'install.packages("R.utils", repos="http://cran.us.r-project.org")'
	R --slave -e 'devtools::install_github("dmcable/spacexr", build_vignettes = FALSE)'


%labels
	Author Ryan Mulqueen
	Version v0.1
	MyLabel SpatialTranscriptomics with celltrek
singularity build --fakeroot spatial2.sif spatial2.def

Single cell DNA

Contains:

  • R 4.2
  • seurat
  • copykit

scdna.def

Bootstrap: docker
From: rocker/rstudio:latest

%environment
	# set up all essential environment variables
	export LC_ALL=C
	export PATH=/opt/miniconda3/bin:$PATH
	export PYTHONPATH=/opt/miniconda3/lib/python3.9/:$PYTHONPATH
	export LC_ALL=C.UTF-8
%post
	# update and install essential dependencies
	apt-get -y update
	apt-get update && apt-get install -y automake \
	build-essential \
	bzip2 \
	wget \
	git \
	default-jre \
	unzip \
	zlib1g-dev \
	parallel \
	libglpk40 \
	gfortran

	# download, install, and update miniconda3
	wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
	bash Miniconda3-latest-Linux-x86_64.sh -b -f -p /opt/miniconda3/
	rm Miniconda3-latest-Linux-x86_64.sh

	# install dependencies via conda
	export PATH="/opt/miniconda3/bin:$PATH"
	conda install -y -c conda-forge mamba 
	mamba install -y -f bioconda::samtools #
	mamba install -y -f bioconda::bedtools #
	mamba install -y -f conda-forge::parallel #

	#install R packages
	mamba install -y -f conda-forge::r-base #=4.2
	mamba install -y -f conda-forge::r-devtools
	mamba install -y -f conda-forge::r-tidyverse
	#mamba install -y -f bioconda::bioconductor-ensdb.hsapiens.v86

	#R utility libraries
	R --slave -e 'install.packages("remotes", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("circlize", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("optparse", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("patchwork", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("plyr", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("stringr", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("tidyverse", repos="http://cran.us.r-project.org")' #
	R --slave -e 'install.packages("RColorBrewer", repos="http://cran.us.r-project.org")' #

	R --slave -e 'devtools::install_github("navinlabcode/copykit")'
	conda install -y -f --no-deps conda-forge::r-igraph
	conda install -y -f --no-deps bioconda::bioconductor-bluster
	conda install -y -f --no-deps bioconda::bioconductor-copynumber
	conda install -y -f --no-deps bioconda::bioconductor-ggtree
	wget https://github.com/navinlabcode/copykit/releases/download/v.0.1.2/copykit_0.1.2.tar.gz
	R --slave -e 'install.packages("copykit_0.1.2.tar.gz", repos = NULL)' # the install_github is broken so pulling from archive

%labels
	Author Ryan Mulqueen
	Version v0.1
	MyLabel Copykit 

Build the container.

singularity build --fakeroot scdna.sif scdna.def