Skip to content

Commit

Permalink
Fix build and add custom parameterization (#24)
Browse files Browse the repository at this point in the history
* add battenberg.R for customization

* add max.rho to battenberg_bl_custom.R

* add max rho default

* add custom battenberg wrapper

* add max rho to wrapper

* add max rho to wrapper

* add max rho to wrapper

* use battenberg.R from v2.2.9 and add max.rho

* rename battenberg_wgs.R  battenberg_wgs_bl_custom.R

* resolve merge conflict again

* Add renv.lock file containining R package versions

* remove modify_reference_path.sh

* resolve merge conflict in Dockerfile

* resue ascat/battenberg version arg

* Update CHANGELOG.md

* Update changes

* commit to remove installer.R

* specify removal of files under /usr/local/src/

* verify checksum and set up workdir

* update CHANGELOG

* Update license year

---------

Co-authored-by: Mootor <mmootor@ip-0A125937.rhxrlfvjyzbupc03cc22jkch3c.xx.internal.cloudapp.net>
  • Loading branch information
Faizal-Eeman and Mootor authored Nov 14, 2024
1 parent 23cd01c commit 0041d85
Show file tree
Hide file tree
Showing 9 changed files with 2,748 additions and 83 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

---

## [2.2.9-bl-parametrize-max-rho] - 2024-10-29
### Added
- Add `renv.lock` file containing R packages and their version
- Add `battenberg_bl_custom.R`, a customized `battenberg.R` script that allows parameterization of `max_rho`
- Add `battenberg_wgs_bl_custom.R`, a customized `battenberg_wgs.R` wrapper that allows parameterization of options

### Changed
- Reproduce R packages environment using `renv.lock` file
- Install ASCAT and Battenberg using `R CMD INSTALL`

### Removed
- Remove `modify_reference_path.sh`

## [2.2.9] - 2023-06-27
### Added
- Add `modify_reference_path.sh`
Expand Down
108 changes: 67 additions & 41 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
ARG MINIFORGE_VERSION=23.1.0-1
ARG ASCAT_VERSION=3.1.2
ARG BATTENBERG_VERSION=2.2.9

FROM condaforge/mambaforge:${MINIFORGE_VERSION} AS builder

Expand All @@ -13,49 +15,73 @@ RUN mamba create -qy -p /usr/local \
cancerit-allelecount==${ALLELECOUNT_VERSION} \
impute2==${IMPUTE2_VERSION}

FROM rocker/r-ver:4.4.1
# Deploy the target tools into a base image
FROM ubuntu:20.04
COPY --from=builder /usr/local /usr/local

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libcurl4-openssl-dev \
libbz2-dev \
liblzma-dev \
libpng-dev \
libssl-dev \
libxml2-dev \
python3 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Main tool version
ARG BATTENBERG_VERSION="2.2.9"

# Dependency version or commit ID
ARG ASCAT_VERSION=3.1.3
ARG COPYNUMBER_VERSION="b404a4d"

# GitHub repo link
ARG ASCAT="VanLoo-lab/ascat/ASCAT@v${ASCAT_VERSION}"
ARG COPYNUMBER="igordot/copynumber@${COPYNUMBER_VERSION}"
ARG BATTENBERG="Wedge-lab/battenberg@v${BATTENBERG_VERSION}"

# Install Package Dependency toolkit
RUN R -e 'install.packages(c("argparse", "BiocManager", "pkgdepends", "optparse"))' && \
R -q -e 'BiocManager::install(c("ellipsis", "splines", "VariantAnnotation"))'

# Install Battenberg
COPY installer.R /usr/local/bin/installer.R
RUN chmod +x /usr/local/bin/installer.R

RUN Rscript /usr/local/bin/installer.R -d ${COPYNUMBER} ${ASCAT} ${BATTENBERG}

# Modify paths to reference files
COPY modify_reference_path.sh /usr/local/bin/modify_reference_path.sh
RUN chmod +x /usr/local/bin/modify_reference_path.sh && \
bash /usr/local/bin/modify_reference_path.sh /usr/local/lib/R/site-library/Battenberg/example/battenberg_wgs.R /usr/local/bin/battenberg_wgs.R

RUN ln -sf /usr/local/lib/R/site-library/Battenberg/example/filter_sv_brass.R /usr/local/bin/filter_sv_brass.R && \
ln -sf /usr/local/lib/R/site-library/Battenberg/example/battenberg_cleanup.sh /usr/local/bin/battenberg_cleanup.sh
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y --no-install-recommends \
libxml2 \
libxml2-dev \
libcurl4-gnutls-dev \
build-essential \
libfontconfig1-dev \
libharfbuzz-dev \
libfribidi-dev \
libfreetype6-dev \
libpng-dev \
libtiff5-dev \
libjpeg-dev \
r-cran-rgl \
git \
libssl-dev \
r-cran-curl \
r-cran-devtools \
wget && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN R -q -e 'install.packages("renv")' && \
mkdir -p /usr/local/src

COPY renv.lock /usr/local/renv.lock
COPY battenberg_bl_custom.R /usr/local/src/
COPY battenberg_wgs_bl_custom.R /usr/local/src/

ARG ASCAT_VERSION
ARG ASCAT_SHA512="a60e75405c3999c86d19e20d717eee9d1e1915e647e2626be5b5bb0d266a6f96535d9cd21ee7717d6fb04d4f76a5b78a1b45e3315bf823e480a8e27afdec364b"
ARG BATTENBERG_VERSION
ARG BATTENBERG_SHA512="a4784ca3e6523bd47b5a6d86c1e7ef5f0023371bd0b5bf3685440e3336333cddf3937f768910462c98eb5cb8b5cfd2c63db052c3186a3b1f0363e460ace521d4"

WORKDIR /usr/local/src/

RUN set -eux && \
# Ignore specific packages from `renv.lock` file
R -q -e 'renv::settings$ignored.packages(c("ASCAT", "Battenberg"))' && \
R -q -e 'renv::restore(lockfile = "/usr/local/renv.lock")' && \
# Install ASCAT
wget -q -O ascat-${ASCAT_VERSION}.tar.gz \
https://github.com/VanLoo-lab/ascat/archive/refs/tags/v${ASCAT_VERSION}.tar.gz && \
if echo "$ASCAT_SHA512" ascat-${ASCAT_VERSION}.tar.gz | sha512sum -c --quiet; \
then echo "ASCAT SHA512 checksum verified successfully!"; \
else echo "ASCAT SHA512 checksum verification failed. Downloaded file checksum does not match the SHA512 hash."; exit 1; \
fi && \
tar -xzf ascat-${ASCAT_VERSION}.tar.gz && \
R CMD INSTALL ascat-${ASCAT_VERSION}/ASCAT/ && \
# Instal Battenberg
wget -q -O battenberg-${BATTENBERG_VERSION}.tar.gz \
https://github.com/Wedge-lab/battenberg/archive/refs/tags/v${BATTENBERG_VERSION}.tar.gz && \
if echo "$BATTENBERG_SHA512" battenberg-${BATTENBERG_VERSION}.tar.gz | sha512sum -c --quiet; \
then echo "Battenberg SHA512 checksum verified successfully!"; \
else echo "Battenberg SHA512 checksum verification failed. Downloaded file checksum does not match the SHA512 hash."; exit 1; \
fi && \
tar -xzf battenberg-${BATTENBERG_VERSION}.tar.gz && \
cp battenberg_bl_custom.R battenberg-${BATTENBERG_VERSION}/R/battenberg.R && \
cp battenberg_wgs_bl_custom.R battenberg-${BATTENBERG_VERSION}/inst/example/battenberg_wgs.R && \
R CMD INSTALL battenberg-${BATTENBERG_VERSION}/ && \
# Cleanup
rm -rf /usr/local/src/*

# Add a new user/group called bldocker
RUN groupadd -g 500001 bldocker && \
Expand Down
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
# docker-Battenberg
This repository contains code for the whole genome sequencing subclonal copy number caller Battenberg, as described in [Nik-Zainal, Van Loo, Wedge, et al. (2012), Cell](https://www.ncbi.nlm.nih.gov/pubmed/22608083).

It installs the release v2.2.9 of Battenberg and modifies the Battenberg resource paths for GRCh37 and GRCh38 based on how they are structured in the Boutros Lab cluster.
It installs Battenberg v2.2.9 using
- a custom battenberg.R script that allows parameterization of `max_rho`
- a custom battenberg_wgs.R script that allows parameterization of all available options

GRCh37 resources - `/hot/ref/tool-specific-input/Battenberg/download_202204/GRCh37/`
## Resources
GRCh37 resources - `/hot/resource/tool-specific-input/Battenberg/download_202204/GRCh37/`

GRCh38 resources -
- with `chr` name (default): `/hot/ref/tool-specific-input/Battenberg/download_202204/GRCh38/battenberg_ref_hg38_chr/`
- without `chr` name: `/hot/ref/tool-specific-input/Battenberg/download_202204/GRCh38/battenberg_ref_hg38_non_chr/`
- with `chr` name (default): `/hot/resource/tool-specific-input/Battenberg/download_202204/GRCh38/battenberg_ref_hg38_chr/`
- without `chr` name: `/hot/resource/tool-specific-input/Battenberg/download_202204/GRCh38/battenberg_ref_hg38_non_chr/`

This image can be found in docker-Battenberg's GitHub package page [here](https://github.com/uclahs-cds/docker-Battenberg/pkgs/container/battenberg).

# Example Usage
```
docker run --rm -u $(id -u):$(id -g) -w $(pwd) -v /hot/:/hot/ \
-v /hot/ref/tool-specific-input/Battenberg/download_202204/GRCh38/battenberg_ref_hg38_chr/:/opt/battenberg_reference/ \
battenberg:2.2.9 Rscript /usr/local/bin/battenberg_wgs.R \
-v /hot/resource/tool-specific-input/Battenberg/download_202204/GRCh38/battenberg_ref_hg38_chr/:/opt/battenberg_reference/ \
battenberg:2.2.9-bl-parametrize-max-rho Rscript /usr/local/lib/R/site-library/Battenberg/example/battenberg_wgs.R \
-t ${tumor_sample_name} \
-n ${normal_sample_name} \
--tb ${tumor_bam} \
--nb ${normal_bam} \
-o ${sample_out_dir} \
--sex ${sample_sex}
--sex ${sample_sex} \
--min_ploidy 1.6 \
--max_ploidy 4.8 \
--min_rho 0.1 \
--max_rho 1.0
```

# Documentation
Expand Down Expand Up @@ -65,9 +72,9 @@ Author: 'Mohammed Faizal Eeman Mootor', 'Ardalan Davarifar'

docker-Battenberg is licensed under the GNU General Public License version 2. See the file LICENSE for the terms of the GNU GPL license.

docker-Battenberg can be used to create a docker instance to use the Battenberg tool.
docker-Battenberg can be used to create a docker instance to use the Battenberg tool.

Copyright (C) 2021-2023 University of California Los Angeles ("Boutros Lab") All rights reserved.
Copyright (C) 2021-2024 University of California Los Angeles ("Boutros Lab") All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Expand Down
Loading

0 comments on commit 0041d85

Please sign in to comment.