Skip to content

Commit

Permalink
multiqc enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
MarieLataretu committed Jun 5, 2020
1 parent 07b3b7c commit 03e306b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
13 changes: 13 additions & 0 deletions assets/multiqc_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module_order:
- fastqc:
name: 'FastQC (raw)'
path_filters_exclude:
- '*.trimmed_fastqc.zip'
- fastp
- fastqc:
name: 'FastQC (trimmed)'
path_filters:
- '*.trimmed_fastqc.zip'
- sortmerna
- hisat2
- featureCounts
15 changes: 12 additions & 3 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ deseq2_script_refactor_reportingtools_table = Channel.fromPath( workflow.project
deseq2_script_improve_deseq_table = Channel.fromPath( workflow.projectDir + '/bin/improve_deseq_table.rb', checkIfExists: true )
deseq2_script_csv2xlsx = Channel.fromPath( workflow.projectDir + '/bin/csv_to_excel.py', checkIfExists: true )

/*
* MultiQC config
*/
multiqc_config = Channel.fromPath( workflow.projectDir + '/assets/multiqc_config.yaml', checkIfExists: true )

//if (params.index) {
// index_ch = Channel.fromPath("${params.index}.*", checkIfExists: true)
//}
Expand Down Expand Up @@ -215,7 +220,7 @@ include featurecounts from './modules/featurecounts'
include tpm_filter from './modules/tpm_filter'
include deseq2 from './modules/deseq2'
include { fastqc as fastqcPre; fastqc as fastqcPost } from './modules/fastqc'
include multiqc from './modules/multiqc'
include { multiqc; multiqc_sample_names } from './modules/multiqc'

// helpers
include {format_annotation; format_annotation_gene_rows} from './modules/prepare_annotation'
Expand Down Expand Up @@ -289,6 +294,7 @@ workflow analysis_reference_based {
deseq2_script_refactor_reportingtools_table
deseq2_script_improve_deseq_table
deseq2_script_csv2xlsx
multiqc_config

main:
// initial QC of raw reads
Expand Down Expand Up @@ -352,7 +358,10 @@ workflow analysis_reference_based {
deseq2(tpm_filter.out.filtered_counts, annotated_sample.condition.collect(), annotated_sample.col_label.collect(), deseq2_comparisons, format_annotation.out, format_annotation_gene_rows.out, annotated_sample.patient.collect(), deseq2_script, deseq2_script_refactor_reportingtools_table, deseq2_script_improve_deseq_table, deseq2_script_csv2xlsx)

// run MultiQC
multiqc(fastp.out.json_report.collect(),
multiqc_sample_names(annotated_reads.map{ row -> row[0..-3]}.collect())
multiqc(multiqc_config,
multiqc_sample_names.out,
fastp.out.json_report.collect(),
sortmerna.out.log.collect(),
hisat2.out.log.collect(),
featurecounts.out.log.collect(),
Expand Down Expand Up @@ -392,7 +401,7 @@ workflow {
sortmerna_db = download_sortmerna.out

// start reference-based analysis
analysis_reference_based(illumina_input_ch, reference, annotation, sortmerna_db, dge_comparisons_input_ch, deseq2_script, deseq2_script_refactor_reportingtools_table, deseq2_script_improve_deseq_table, deseq2_script_csv2xlsx)
analysis_reference_based(illumina_input_ch, reference, annotation, sortmerna_db, dge_comparisons_input_ch, deseq2_script, deseq2_script_refactor_reportingtools_table, deseq2_script_improve_deseq_table, deseq2_script_csv2xlsx, multiqc_config)
}


Expand Down
32 changes: 31 additions & 1 deletion modules/multiqc.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ process multiqc {
else { publishDir "${params.output}/${params.multiqc_dir}" }

input:
path(config)
path(sample_names)
path(fastp)
path(sortmerna)
path(hisat2)
Expand All @@ -22,6 +24,34 @@ process multiqc {

script:
"""
multiqc .
multiqc . -c ${config} --sample-names ${sample_names}
"""
}

process multiqc_sample_names {
label 'smallTask'

input:
val(list)

output:
path('multiqc_sample_names.tsv')

script:
def tbl = ''
if (params.mode == 'single') {
for( int i=0; i<list.size()-1; i=i+2 ){
tbl += "${list[i+1].baseName.tokenize('.')[0]}\t${list[i]}\n"
}
}
else {
for( int i=0; i<list.size()-2; i=i+3 ){
tbl += "${list[i+1].baseName.tokenize('.')[0]}\t${list[i]}.R1\n"
tbl += "${list[i+2].baseName.tokenize('.')[0]}\t${list[i]}.R2\n"
}
}
"""
echo "Read File Names\tSample Names" > multiqc_sample_names.tsv
echo "${tbl}" >> multiqc_sample_names.tsv
"""
}

0 comments on commit 03e306b

Please sign in to comment.