Skip to content

Commit

Permalink
Merge pull request #9 from ajmaurais/consolidate_qc
Browse files Browse the repository at this point in the history
Consolidate QC command line output
  • Loading branch information
mriffle authored Aug 1, 2024
2 parents 3acdc02 + 1c8df96 commit d15743b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 88 deletions.
2 changes: 1 addition & 1 deletion container_images.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ params {
panorama_client: 'quay.io/protio/panorama-client:1.1.0',
encyclopedia: 'quay.io/protio/encyclopedia:2.12.30-2',
encyclopedia3_mriffle: 'quay.io/protio/encyclopedia:3.0.0-MRIFFLE',
qc_pipeline: 'quay.io/mauraisa/dia_qc_report:2.0.0',
qc_pipeline: 'quay.io/mauraisa/dia_qc_report:2.2.2',
proteowizard: 'quay.io/protio/pwiz-skyline-i-agree-to-the-vendor-licenses:3.0.24172-63d00b1'
]
}
2 changes: 1 addition & 1 deletion modules/encyclopedia.nf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ process ENCYCLOPEDIA_SEARCH_FILE {
path("${mzml_file}.features.txt"), emit: features
path("${mzml_file}.encyclopedia.txt"), emit: results_targets
path("${mzml_file}.encyclopedia.decoy.txt"), emit: results_decoys


script:
"""
Expand Down
109 changes: 37 additions & 72 deletions modules/qc_report.nf
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ process MAKE_EMPTY_FILE {
path("${file_name}")

script:
"""
touch ${file_name}
"""
"""
touch ${file_name}
"""
}

process PARSE_REPORTS {
publishDir "${params.result_dir}/qc_report", pattern: '*.db3', enabled: params.qc_report.normalization_method == null, failOnError: true, mode: 'copy'
publishDir "${params.result_dir}/qc_report", pattern: '*.db3', failOnError: true, mode: 'copy'
publishDir "${params.result_dir}/qc_report", pattern: '*.stdout', failOnError: true, mode: 'copy'
publishDir "${params.result_dir}/qc_report", pattern: '*.stderr', failOnError: true, mode: 'copy'
label 'process_high_memory'
Expand All @@ -41,81 +41,46 @@ process PARSE_REPORTS {

output:
path('*.db3'), emit: qc_report_db
path('*.qmd'), emit: qc_report_qmd
path("*.stdout"), emit: stdout
path("*.stderr"), emit: stderr

script:
def metadata_arg = replicate_metadata.name == 'EMPTY' ? '' : "-m $replicate_metadata"
def metadata_arg = replicate_metadata.name == 'EMPTY' ? '' : "-m $replicate_metadata"

if(params.qc_report.normalization_method == null)
"""
dia_qc parse --ofname qc_report_data.db3 ${metadata_arg} \
--groupBy ${params.skyline.group_by_gene ? 'gene' : 'protein'} \
'${replicate_report}' '${precursor_report}' \
> >(tee "parse_data.stdout") 2> >(tee "parse_data.stderr")
"""
stub:
"""
touch stub.stdout stub.stderr stub.db3 stub.qmd
dia_qc qc_qmd ${format_flags(params.qc_report.standard_proteins, '--addStdProtein')} \
${format_flags(params.qc_report.color_vars, '--addColorVar')} \
qc_report_data.db3 \
> >(tee "make_qmd.stdout") 2> >(tee "make_qmd.stderr")
"""
}

process NORMALIZE_DB {
publishDir "${params.result_dir}/qc_report", pattern: '*.db3', failOnError: true, mode: 'copy'
publishDir "${params.result_dir}/qc_report", pattern: '*.stdout', failOnError: true, mode: 'copy'
publishDir "${params.result_dir}/qc_report", pattern: '*.stderr', failOnError: true, mode: 'copy'
label 'process_high_memory'
container params.images.qc_pipeline

input:
path qc_report_db

output:
path('*_normalized.db3'), emit: qc_report_db
path("*.stdout"), emit: stdout
path("*.stderr"), emit: stderr

script:
else
"""
# It is necissary to make a copy to avoid breaking nextflow's caching
cp ${qc_report_db} ${qc_report_db.baseName}_normalized.db3
dia_qc parse --ofname qc_report_data.db3 ${metadata_arg} \
--groupBy ${params.skyline.group_by_gene ? 'gene' : 'protein'} \
'${replicate_report}' '${precursor_report}' \
> >(tee "parse_data.stdout") 2> >(tee "parse_data.stderr")
dia_qc normalize -m=${params.qc_report.normalization_method} ${qc_report_db.baseName}_normalized.db3 \
dia_qc normalize -m=${params.qc_report.normalization_method} qc_report_data.db3 \
> >(tee "normalize_db.stdout") 2> >(tee "normalize_db.stderr" >&2)
"""

stub:
"""
touch stub.stdout stub.stderr stub_normalized.db3
"""
}
process GENERATE_QC_QMD {
publishDir "${params.result_dir}/qc_report", pattern: '*.qmd', failOnError: true, mode: 'copy'
publishDir "${params.result_dir}/qc_report", pattern: '*.stdout', failOnError: true, mode: 'copy'
publishDir "${params.result_dir}/qc_report", pattern: '*.stderr', failOnError: true, mode: 'copy'
label 'process_high'
container params.images.qc_pipeline

input:
path qc_report_db

output:
path('*.qmd'), emit: qc_report_qmd
path("*.stdout"), emit: stdout
path("*.stderr"), emit: stderr

script:
"""
dia_qc qc_qmd ${format_flags(params.qc_report.standard_proteins, '--addStdProtein')} \
${format_flags(params.qc_report.color_vars, '--addColorVar')} \
${qc_report_db} \
qc_report_data.db3 \
> >(tee "make_qmd.stdout") 2> >(tee "make_qmd.stderr")
"""

stub:
"""
touch stub.stdout stub.stderr stub.qmd
"""
"""
touch stub.stdout stub.stderr stub.db3 stub.qmd
"""
}

process EXPORT_TABLES {
Expand All @@ -134,15 +99,15 @@ process EXPORT_TABLES {
path("*.stderr"), emit: stderr

script:
"""
dia_qc db_export --precursorTables=30 --proteinTables=30 ${precursor_db} \
> >(tee "export_tables.stdout") 2> >(tee "export_tables.stderr")
"""
"""
dia_qc db_export --precursorTables=30 --proteinTables=30 ${precursor_db} \
> >(tee "export_tables.stdout") 2> >(tee "export_tables.stderr")
"""

stub:
"""
touch stub.stdout stub.stderr stub.tsv
"""
"""
touch stub.stdout stub.stderr stub.tsv
"""
}

process RENDER_QC_REPORT {
Expand All @@ -163,15 +128,15 @@ process RENDER_QC_REPORT {
path("*.stderr"), emit: stderr

script:
"""
quarto render qc_report.qmd --to '${report_format}' \
> >(tee "render_${report_format}_report.stdout") 2> >(tee "render_${report_format}_report.stderr")
"""
"""
quarto render qc_report.qmd --to '${report_format}' \
> >(tee "render_${report_format}_report.stdout") 2> >(tee "render_${report_format}_report.stderr")
"""

stub:
"""
touch "qc_report.${report_format}"
touch stub.stdout stub.stderr
"""
"""
touch "qc_report.${report_format}"
touch stub.stdout stub.stderr
"""
}

6 changes: 3 additions & 3 deletions modules/skyline.nf
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ process ANNOTATION_TSV_TO_CSV {
path replicate_metadata

output:
path("sky_annotations.csv"), emit: annotation_csv
path("sky_annotation_definitions.bat"), emit: annotation_definitions
path("metadata.annotations.csv"), emit: annotation_csv
path("metadata.definitions.bat"), emit: annotation_definitions

shell:
"""
Expand All @@ -148,7 +148,7 @@ process ANNOTATION_TSV_TO_CSV {

stub:
"""
touch sky_annotation_definitions.bat sky_annotations.csv
touch metadata.definitions.bat metadata.annotations.csv
"""
}

Expand Down
13 changes: 2 additions & 11 deletions workflows/generate_qc_report.nf
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

include { SKYLINE_RUN_REPORTS } from "../modules/skyline.nf"
include { PARSE_REPORTS } from "../modules/qc_report.nf"
include { NORMALIZE_DB } from "../modules/qc_report.nf"
include { GENERATE_QC_QMD } from "../modules/qc_report.nf"
include { RENDER_QC_REPORT } from "../modules/qc_report.nf"
include { EXPORT_TABLES } from "../modules/qc_report.nf"

Expand Down Expand Up @@ -32,15 +30,8 @@ workflow generate_dia_qc_report {
precursor_report,
replicate_metadata)

if(params.qc_report.normalization_method != null) {
NORMALIZE_DB(PARSE_REPORTS.out.qc_report_db)
qc_report_db = NORMALIZE_DB.out.qc_report_db
} else {
qc_report_db = PARSE_REPORTS.out.qc_report_db
}

GENERATE_QC_QMD(qc_report_db)
qc_report_qmd = GENERATE_QC_QMD.out.qc_report_qmd
qc_report_db = PARSE_REPORTS.out.qc_report_db
qc_report_qmd = PARSE_REPORTS.out.qc_report_qmd

report_formats = Channel.fromList(['html', 'pdf'])
RENDER_QC_REPORT(qc_report_qmd.collect(), qc_report_db.collect(),
Expand Down

0 comments on commit d15743b

Please sign in to comment.