From 63000ada5044bf387dc409e4f86986e63c840e4c Mon Sep 17 00:00:00 2001 From: LaurenceKuhl Date: Thu, 9 Nov 2023 16:34:50 +0100 Subject: [PATCH] Add versions --- modules/local/bagel2/bf.nf | 7 ++++++- modules/local/bagel2/fc.nf | 12 ++++++++---- modules/local/bagel2/graph.nf | 12 +++++++++++- modules/local/bagel2/pr.nf | 9 +++++++-- modules/local/mageck/graphrra.nf | 15 +++++++++++++++ workflows/crisprseq_screening.nf | 19 ++++++++++++++++++- 6 files changed, 65 insertions(+), 9 deletions(-) diff --git a/modules/local/bagel2/bf.nf b/modules/local/bagel2/bf.nf index 9f5fe090..3ff86603 100644 --- a/modules/local/bagel2/bf.nf +++ b/modules/local/bagel2/bf.nf @@ -16,7 +16,7 @@ process BAGEL2_BF { output: tuple val(meta), path("*.bf"), emit: bf - //path "versions.yml" , emit: versions + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -28,6 +28,11 @@ process BAGEL2_BF { """ BAGEL.py bf -i $foldchange -o '${meta.treatment}_vs_${meta.reference}.bf' $args -e $reference_essentials -n $reference_nonessentials -c ${meta.treatment} + cat <<-END_VERSIONS > versions.yml + "${task.process}": + python: \$(python --version | sed 's/Python //g') + BAGEL2: \$( BAGEL.py version | grep -o 'Version: [0-9.]*' | awk '{print \$2}' | grep -v '^\$') + END_VERSIONS """ } diff --git a/modules/local/bagel2/fc.nf b/modules/local/bagel2/fc.nf index bec12be1..b65afaea 100644 --- a/modules/local/bagel2/fc.nf +++ b/modules/local/bagel2/fc.nf @@ -11,9 +11,9 @@ process BAGEL2_FC { tuple val(meta), path(count_table) output: - tuple val(meta), path("*.foldchange"), emit: foldchange - tuple val(meta), path("*.normed_readcount"), emit: normed_counts - //path "versions.yml" , emit: versions + tuple val(meta), path("*.foldchange") , emit: foldchange + tuple val(meta), path("*.normed_readcount") , emit: normed_counts + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -24,7 +24,11 @@ process BAGEL2_FC { """ BAGEL.py fc -i $count_table -o ${meta.treatment}_vs_${meta.reference} -c $meta.reference $args - + cat <<-END_VERSIONS > versions.yml + "${task.process}": + python: \$(python --version | sed 's/Python //g') + BAGEL2: \$( BAGEL.py version | grep -o 'Version: [0-9.]*' | awk '{print \$2}' | grep -v '^\$') + END_VERSIONS """ } diff --git a/modules/local/bagel2/graph.nf b/modules/local/bagel2/graph.nf index c14e7810..270c265f 100644 --- a/modules/local/bagel2/graph.nf +++ b/modules/local/bagel2/graph.nf @@ -13,7 +13,7 @@ process BAGEL2_GRAPH { output: path("*.png") , emit: pictures - + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -60,6 +60,16 @@ process BAGEL2_GRAPH { plt.savefig(file_name) plt.show() + # Output version information + version = pd. __version__ + matplotlib_version = plt.matplotlib.__version__ + # alas, no `pyyaml` pre-installed in the cellranger container + with open("versions.yml", "w") as f: + f.write('"${task.process}":\\n') + f.write(f' pandas: "{version}"\\n') + f.write(f' matplotlib.pyplot: "{matplotlib_version}"\\n') + + """ diff --git a/modules/local/bagel2/pr.nf b/modules/local/bagel2/pr.nf index b5cd1793..cc4f3157 100644 --- a/modules/local/bagel2/pr.nf +++ b/modules/local/bagel2/pr.nf @@ -13,8 +13,7 @@ process BAGEL2_PR { output: tuple val(meta), path("*.pr") , emit: pr - - //path "versions.yml" , emit: versions + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -25,6 +24,12 @@ process BAGEL2_PR { """ BAGEL.py pr -i $bf -o '${meta.treatment}_vs_${meta.reference}.pr' -e $reference_essentials -n $reference_nonessentials + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + python: \$(python --version | sed 's/Python //g') + BAGEL2: \$( BAGEL.py version | grep -o 'Version: [0-9.]*' | awk '{print \$2}' | grep -v '^\$') + END_VERSIONS """ } diff --git a/modules/local/mageck/graphrra.nf b/modules/local/mageck/graphrra.nf index 2c531d5d..ec11bf55 100644 --- a/modules/local/mageck/graphrra.nf +++ b/modules/local/mageck/graphrra.nf @@ -48,6 +48,21 @@ process MAGECK_GRAPHRRA { print(p1) dev.off() + version_file_path <- "versions.yml" + version_flute <- paste(unlist(packageVersion("MAGeCKFlute")), collapse = ".") + version_ggplot <- paste(unlist(packageVersion("MAGeCKFlute")), collapse = ".") + + f <- file(version_file_path, "w") + writeLines('"${task.process}":', f) + writeLines(" MAGeCKFlute: ", f, sep = "") + writeLines(version_flute, f) + writeLines(" ggplot2: ", f, sep = "") + writeLines(version_ggplot, f) + close(f) + + + + """ diff --git a/workflows/crisprseq_screening.nf b/workflows/crisprseq_screening.nf index ff2a61b5..95a9e22d 100644 --- a/workflows/crisprseq_screening.nf +++ b/workflows/crisprseq_screening.nf @@ -116,7 +116,7 @@ workflow CRISPRSEQ_SCREENING { [[id: condition, single_end: single_end], fastqs] } .set { joined } - joined.dump(tag:"metadata") + // // MODULE: Run mageck count @@ -147,6 +147,9 @@ workflow CRISPRSEQ_SCREENING { params.min_targeted_genes ) + ch_versions = ch_versions.mix(CRISPRCLEANR_NORMALIZE.out.versions) + + CRISPRCLEANR_NORMALIZE.out.norm_count_file.map { it -> it[1] }.set { ch_counts } @@ -162,9 +165,12 @@ workflow CRISPRSEQ_SCREENING { counts ) + ch_versions = ch_versions.mix(MAGECK_TEST.out.versions) + MAGECK_GRAPHRRA ( MAGECK_TEST.out.gene_summary ) + //TODO: Missing versions } if(params.rra_contrasts) { @@ -180,6 +186,7 @@ workflow CRISPRSEQ_SCREENING { BAGEL2_FC ( counts ) + ch_versions = ch_versions.mix(BAGEL2_FC.out.versions) BAGEL2_BF ( BAGEL2_FC.out.foldchange, @@ -187,12 +194,18 @@ workflow CRISPRSEQ_SCREENING { ch_bagel_reference_nonessentials ) + ch_versions = ch_versions.mix(BAGEL2_BF.out.versions) + + ch_bagel_pr = BAGEL2_BF.out.bf.combine(ch_bagel_reference_essentials) .combine(ch_bagel_reference_nonessentials) BAGEL2_PR ( ch_bagel_pr ) + + ch_versions = ch_versions.mix(BAGEL2_PR.out.versions) + BAGEL2_GRAPH ( BAGEL2_PR.out.pr ) @@ -207,6 +220,10 @@ workflow CRISPRSEQ_SCREENING { MAGECK_MLE ( ch_designed_mle ) + + ch_versions = ch_versions.mix(MAGECK_MLE.out.versions) + + } CUSTOM_DUMPSOFTWAREVERSIONS (