diff --git a/lib/WorkflowRnaseq.groovy b/lib/WorkflowRnaseq.groovy index bc4af5b818..ca0a601699 100755 --- a/lib/WorkflowRnaseq.groovy +++ b/lib/WorkflowRnaseq.groovy @@ -2,6 +2,8 @@ // This file holds several functions specific to the workflow/rnaseq.nf in the nf-core/rnaseq pipeline // +import groovy.json.JsonSlurper + class WorkflowRnaseq { // @@ -152,6 +154,24 @@ class WorkflowRnaseq { } } + // + // Function that parses Salmon quant 'meta_info.json' output file to get inferred strandedness + // + public static String getSalmonInferredStrandedness(json_file) { + def lib_type = new JsonSlurper().parseText(json_file.text).get('library_types')[0] + def strandedness = 'reverse' + if (lib_type) { + if (lib_type in ['U', 'IU']) { + strandedness = 'unstranded' + } else if (lib_type in ['SF', 'ISF']) { + strandedness = 'forward' + } else if (lib_type in ['SR', 'ISR']) { + strandedness = 'reverse' + } + } + return strandedness + } + // // Function that parses and returns the alignment rate from the STAR log output // diff --git a/modules/nf-core/modules/salmon/quant/main.nf b/modules/nf-core/modules/salmon/quant/main.nf index bd4792c52e..498400fc74 100644 --- a/modules/nf-core/modules/salmon/quant/main.nf +++ b/modules/nf-core/modules/salmon/quant/main.nf @@ -16,8 +16,9 @@ process SALMON_QUANT { val lib_type output: - tuple val(meta), path("${prefix}"), emit: results - path "versions.yml" , emit: versions + tuple val(meta), path("${prefix}") , emit: results + tuple val(meta), path("meta_info.json"), emit: json_info, optional: true + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -64,6 +65,10 @@ process SALMON_QUANT { $args \\ -o $prefix + if [ -f $prefix/aux_info/meta_info.json ]; then + cp $prefix/aux_info/meta_info.json . + fi + cat <<-END_VERSIONS > versions.yml "${task.process}": salmon: \$(echo \$(salmon --version) | sed -e "s/salmon //g") diff --git a/modules/nf-core/modules/salmon/quant/meta.yml b/modules/nf-core/modules/salmon/quant/meta.yml index 109109d8fb..1e65e3628c 100644 --- a/modules/nf-core/modules/salmon/quant/meta.yml +++ b/modules/nf-core/modules/salmon/quant/meta.yml @@ -46,6 +46,10 @@ output: type: directory description: Folder containing the quantification results for a specific sample pattern: "${prefix}" + - json_info: + type: file + description: File containing meta information from Salmon quant + pattern: "*_info.json" - versions: type: file description: File containing software versions diff --git a/subworkflows/local/quantify_salmon.nf b/subworkflows/local/quantify_salmon.nf index c1f869442c..8031b6396f 100644 --- a/subworkflows/local/quantify_salmon.nf +++ b/subworkflows/local/quantify_salmon.nf @@ -55,14 +55,15 @@ workflow QUANTIFY_SALMON { SALMON_TX2GENE.out.tsv.collect() ) - SALMON_SE_TRANSCRIPT ( - SALMON_TXIMPORT.out.counts_transcript, - SALMON_TXIMPORT.out.tpm_transcript, - SALMON_TX2GENE.out.tsv.collect() - ) + // SALMON_SE_TRANSCRIPT ( + // SALMON_TXIMPORT.out.counts_transcript, + // SALMON_TXIMPORT.out.tpm_transcript, + // SALMON_TX2GENE.out.tsv.collect() + // ) emit: results = SALMON_QUANT.out.results // channel: [ val(meta), results_dir ] + json_info = SALMON_QUANT.out.json_info // channel: [ val(meta), json_info ] tpm_gene = SALMON_TXIMPORT.out.tpm_gene // channel: [ val(meta), counts ] counts_gene = SALMON_TXIMPORT.out.counts_gene // channel: [ val(meta), counts ] @@ -77,7 +78,7 @@ workflow QUANTIFY_SALMON { merged_counts_transcript = SALMON_TXIMPORT.out.counts_transcript // path: *.transcript_counts.tsv merged_tpm_transcript = SALMON_TXIMPORT.out.tpm_transcript // path: *.transcript_tpm.tsv - merged_transcript_rds = SALMON_SE_TRANSCRIPT.out.rds // path: *.rds + // merged_transcript_rds = SALMON_SE_TRANSCRIPT.out.rds // path: *.rds versions = ch_versions // channel: [ versions.yml ] } diff --git a/workflows/rnaseq.nf b/workflows/rnaseq.nf index e6363235db..a19be49ef3 100755 --- a/workflows/rnaseq.nf +++ b/workflows/rnaseq.nf @@ -205,6 +205,20 @@ workflow RNASEQ { .set { ch_cat_fastq } ch_versions = ch_versions.mix(CAT_FASTQ.out.versions.first().ifEmpty(null)) + + // Add sub-workflow here that sub-samples FastQ files and runs SALMON_QUANT + // Filter channels beforehand for anything with strandedness not set to 'auto' + // QUANTIFY_SALMON + // .out + // .json_info + // //.filter { meta, json -> meta.strandedness != 'auto' } // Add this filter right at the beginning + // .filter { meta, json -> meta.strandedness != 'auto' } + // .map { meta, json -> + // meta.strandedness = WorkflowRnaseq.getSalmonInferredStrandedness(json) + // return [ meta, json ] + // } + // .view() + // // SUBWORKFLOW: Read QC, extract UMI and trim adapters //