Skip to content

Commit

Permalink
Add option to auto-detect strandedness
Browse files Browse the repository at this point in the history
  • Loading branch information
drpatelh committed Mar 3, 2022
1 parent 9b1cc4b commit 0d760d2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
20 changes: 20 additions & 0 deletions lib/WorkflowRnaseq.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

//
Expand Down Expand Up @@ -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
//
Expand Down
9 changes: 7 additions & 2 deletions modules/nf-core/modules/salmon/quant/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions modules/nf-core/modules/salmon/quant/meta.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions subworkflows/local/quantify_salmon.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand All @@ -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 ]
}
14 changes: 14 additions & 0 deletions workflows/rnaseq.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down

0 comments on commit 0d760d2

Please sign in to comment.