diff --git a/config/F2.config b/config/F2.config index b7334aec..aaea5be5 100644 --- a/config/F2.config +++ b/config/F2.config @@ -1,4 +1,4 @@ -// Other processes after create_IndelCandidate_SAMtools will only run one at a time, so +// Other processes will only run one at a time, so // we don't need to control their resources. // The configuration below forces processes to run one at a time by needing // the total memory available on a lowmem node. diff --git a/docker/plot-venn/Dockerfile b/docker/plot-venn/Dockerfile index ef47a4a3..12e5afcf 100644 --- a/docker/plot-venn/Dockerfile +++ b/docker/plot-venn/Dockerfile @@ -1,16 +1,16 @@ +ARG MINIFORGE_VERSION=22.9.0-2 ARG UBUNTU_VERSION=20.04 -FROM ubuntu:${UBUNTU_VERSION} -ARG DEBIAN_FRONTEND=noninteractive +FROM condaforge/mambaforge:${MINIFORGE_VERSION} AS builder -RUN apt-get update && \ - apt-get install -y --no-install-recommends libxml2 libxml2-dev libcurl4-gnutls-dev build-essential r-base r-base-dev \ - libfontconfig1-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev r-cran-rgl \ - git libssl-dev r-cran-curl && \ - apt-get clean && rm -rf /var/lib/apt/lists/* +RUN mamba create -qy -p /usr/local \ + 'r-base>=4.2.1' \ + r-argparse \ + r-VennDiagram -RUN R -q -e 'install.packages(c("devtools", "argparse", "VennDiagram"))' -RUN R -q -e 'devtools::install_github("uclahs-cds/public-R-BoutrosLab-utilities")' +# Copy from builder into final image +FROM ubuntu:${UBUNTU_VERSION} AS final +COPY --from=builder /usr/local /usr/local # Add a new user/group called bldocker RUN groupadd -g 500001 bldocker \ diff --git a/main.nf b/main.nf index 82745a97..d55b9b3b 100755 --- a/main.nf +++ b/main.nf @@ -84,8 +84,11 @@ include { muse } from './module/muse' addParams( include { intersect } from './module/intersect' addParams( workflow_output_dir: "${params.output_dir_base}/intersect-BCFtools-${params.BCFtools_version}", - workflow_log_output_dir: "${params.log_output_dir}/process-log/intersect-BCFtools-${params.BCFtools_version}" - ) + workflow_log_output_dir: "${params.log_output_dir}/process-log/intersect-BCFtools-${params.BCFtools_version}", + output_filename: generate_standard_filename("Consensus", + params.dataset_id, + params.sample_id, + [:])) // Returns the index file for the given bam or vcf def indexFile(bam_or_vcf) { @@ -117,12 +120,18 @@ Channel } .set { normal_input } + script_dir_ch = Channel.fromPath( + "$projectDir/r-scripts", + checkIfExists: true + ) + workflow { reference_ch = Channel.from( params.reference, params.reference_index, params.reference_dict ) + // Input file validation if (params.tumor_only_mode) { file_to_validate = reference_ch @@ -227,7 +236,8 @@ workflow { intersect( tool_vcfs, - tool_indices + tool_indices, + script_dir_ch ) } } diff --git a/module/intersect-processes.nf b/module/intersect-processes.nf index 6a8edf8a..91e50374 100644 --- a/module/intersect-processes.nf +++ b/module/intersect-processes.nf @@ -4,7 +4,7 @@ log.info """\ ==================================== Docker Images: - docker_image_BCFtools: ${params.docker_image_BCFtools} -- docker_image_r_scripts: ${params.docker_image_r_VennDiagram} +- docker_image_r_VennDiagram: ${params.docker_image_r_VennDiagram} ==================================== """ process intersect_VCFs_BCFtools { @@ -71,6 +71,6 @@ process intersect_VCFs_BCFtools { script: """ set -euo pipefail - Rscript ${script_dir}/plot-venn.R --isec_dir ${isec_dir} --dataset ${params.dataset_id} + Rscript ${script_dir}/plot-venn.R --isec_dir ${isec_dir} --outfile ${params.output_filename}_Venn-diagram.tiff """ } diff --git a/module/intersect.nf b/module/intersect.nf index cb4e2c7b..c0084dec 100644 --- a/module/intersect.nf +++ b/module/intersect.nf @@ -2,12 +2,10 @@ include { generate_sha512sum } from './common' include { intersect_VCFs_BCFtools; plot_VennDiagram_R } from './intersect-processes.nf' workflow intersect { - // pass bin directory in project folder as channel into docker - script_dir_ch = Channel.fromPath("$projectDir/r-scripts", checkIfExists: true) - take: tool_vcfs tool_indices + script_dir_ch main: intersect_VCFs_BCFtools( diff --git a/r-scripts/plot-venn.R b/r-scripts/plot-venn.R index c51ff605..501264e7 100644 --- a/r-scripts/plot-venn.R +++ b/r-scripts/plot-venn.R @@ -8,13 +8,12 @@ ## Setup the environment ########################################################################### library('argparse'); -library('BoutrosLab.utilities'); library('VennDiagram'); ## Parse the arguments ############################################################################# parser <- ArgumentParser(); parser$add_argument('-i', '--isec_dir', help = 'The directory containing the output from BCFtools intersect', type = 'character'); -parser$add_argument('-d', '--dataset', help = 'The dataset ID passed from nextflow', type = 'character'); +parser$add_argument('-o', '--outfile', help = 'Output filename', type = 'character'); args <- parser$parse_args(); ## Function: plot venn diagram ##################################################################### @@ -48,4 +47,4 @@ colnames(sites) <- header variants <- paste(sites$chrom, sites$pos, sep = '_'); tool.variants <- lapply(sites[, algorithms], function(x) variants[x == 1]) tool.variants.ordered <- tool.variants[order(lengths(tool.variants), decreasing = TRUE)]; -plot.venn(tool.variants.ordered, generate.filename(args$dataset, 'Venn-diagram', 'tiff')); +plot.venn(tool.variants.ordered, args$outfile);