Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions modules/local/diann/assemble_empirical_library/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ process ASSEMBLE_EMPIRICAL_LIBRARY {
path "empirical_library.*", emit: empirical_library
path "assemble_empirical_library.log", emit: log
path "versions.yml", emit: versions
path "diann_calibrated_params.csv", emit: calibrated_params

when:
task.ext.when == null || task.ext.when
Expand Down Expand Up @@ -83,6 +84,14 @@ process ASSEMBLE_EMPIRICAL_LIBRARY {

cp report.log.txt assemble_empirical_library.log

val_mass_acc_ms2=\$(grep "Averaged recommended settings" assemble_empirical_library.log | cut -d ' ' -f 11 | tr -cd "[0-9.]")
val_mass_acc_ms1=\$(grep "Averaged recommended settings" assemble_empirical_library.log | cut -d ' ' -f 15 | tr -cd "[0-9.]")
val_scan_window=\$(grep "Averaged recommended settings" assemble_empirical_library.log | cut -d ' ' -f 19 | tr -cd "[0-9.]")
if [ -z "\$val_mass_acc_ms2" ]; then val_mass_acc_ms2="0"; fi
if [ -z "\$val_mass_acc_ms1" ]; then val_mass_acc_ms1="0"; fi
if [ -z "\$val_scan_window" ]; then val_scan_window="0"; fi
echo "\${val_mass_acc_ms2},\${val_mass_acc_ms1},\${val_scan_window}" > diann_calibrated_params.csv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
DIA-NN: \$(diann 2>&1 | grep "DIA-NN" | grep -oP "\\d+\\.\\d+(\\.\\w+)*(\\.[\\d]+)?")
Expand Down
4 changes: 4 additions & 0 deletions modules/local/diann/assemble_empirical_library/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@ output:
type: file
description: File containing software version
pattern: "versions.yml"
- calibrated_params:
type: file
description: A file containing mass_acc_ms2, mass_acc_ms1, and scan_window extracted from the DIA-NN log.
pattern: "diann_calibrated_params.csv"
authors:
- "@daichengxin"
42 changes: 31 additions & 11 deletions modules/local/diann/individual_analysis/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ process INDIVIDUAL_ANALYSIS {
'docker.io/biocontainers/diann:v1.8.1_cv1' }"

input:
tuple val(meta), path(ms_file), path(fasta), path(diann_log), path(library)
tuple val(meta), path(ms_file), path(fasta), path(library)
path(diann_config)

output:
Expand Down Expand Up @@ -44,19 +44,39 @@ process INDIVIDUAL_ANALYSIS {
}
}

scan_window = params.scan_window

if (params.mass_acc_automatic | params.scan_window_automatic) {
mass_acc_ms2 = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 11 | tr -cd \"[0-9]\")"
scan_window = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 19 | tr -cd \"[0-9]\")"
mass_acc_ms1 = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 15 | tr -cd \"[0-9]\")"
} else if (meta['precursormasstoleranceunit'].toLowerCase().endsWith('ppm') && meta['fragmentmasstoleranceunit'].toLowerCase().endsWith('ppm')) {
if (params.mass_acc_automatic || params.scan_window_automatic) {
if (meta.mass_acc_ms2 != "0" && meta.mass_acc_ms2 != null) {
mass_acc_ms2 = meta.mass_acc_ms2
mass_acc_ms1 = meta.mass_acc_ms1
scan_window = meta.scan_window
}
else if (meta['fragmentmasstolerance']) {
mass_acc_ms2 = meta['fragmentmasstolerance']
mass_acc_ms1 = meta['precursormasstolerance']
scan_window = params.scan_window
}
else {
mass_acc_ms2 = params.mass_acc_ms2
mass_acc_ms1 = params.mass_acc_ms1
scan_window = params.scan_window
}
} else if (meta['precursormasstoleranceunit']?.toLowerCase()?.endsWith('ppm') && meta['fragmentmasstoleranceunit']?.toLowerCase()?.endsWith('ppm')) {
mass_acc_ms1 = meta["precursormasstolerance"]
mass_acc_ms2 = meta["fragmentmasstolerance"]
} else {
mass_acc_ms2 = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 11 | tr -cd \"[0-9]\")"
scan_window = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 19 | tr -cd \"[0-9]\")"
mass_acc_ms1 = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 15 | tr -cd \"[0-9]\")"
if (meta.mass_acc_ms2 != "0" && meta.mass_acc_ms2 != null) {
mass_acc_ms2 = meta.mass_acc_ms2
mass_acc_ms1 = meta.mass_acc_ms1
scan_window = meta.scan_window
} else if (meta['fragmentmasstolerance']) {
mass_acc_ms2 = meta['fragmentmasstolerance']
mass_acc_ms1 = meta['precursormasstolerance']
scan_window = params.scan_window
} else {
mass_acc_ms2 = params.mass_acc_ms2
mass_acc_ms1 = params.mass_acc_ms1
scan_window = params.scan_window
}
}

diann_no_peptidoforms = params.diann_no_peptidoforms ? "--no-peptidoforms" : ""
Expand Down
4 changes: 0 additions & 4 deletions modules/local/diann/individual_analysis/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ tools:
homepage: https://github.com/vdemichev/DiaNN
documentation: https://github.com/vdemichev/DiaNN
input:
- diann_log:
type: file
description: DIA-NN log file
pattern: "assemble_empirical_library.log"
- empirical_library:
type: file
description: An empirical spectral library from the .quant files.
Expand Down
4 changes: 4 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ params {
random_preanalysis_seed = 42
empirical_assembly_ms_n = 200

// DIA-NN: INDIVIDUAL_ANALYSIS
mass_acc_ms2 = 15
mass_acc_ms1 = 15

// DIA-NN: FINAL_QUANTIFICATION — summarization & output
pg_level = 2
species_genes = false
Expand Down
14 changes: 14 additions & 0 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,20 @@
"help_text": " Ideally, should be approximately equal to the average number of data points per peak",
"default": 8
},
"mass_acc_ms2": {
"type": "number",
"description": "Set the MS2 mass accuracy (tolerance) to a specific value in ppm.",
"fa_icon": "fas fa-bullseye",
"help_text": "If specified, this overrides the automatic calibration. Corresponds to the --mass-acc parameter in DIA-NN.",
"default": 15
},
"mass_acc_ms1": {
"type": "number",
"description": "Set the MS1 mass accuracy (tolerance) to a specific value in ppm.",
"fa_icon": "fas fa-bullseye",
"help_text": "If specified, this overrides the automatic calibration. Corresponds to the --mass-acc-ms1 parameter in DIA-NN.",
"default": 15
},
"performance_mode": {
"type": "boolean",
"description": "Set Low RAM & High Speed Mode for DIANN, including min-corr, corr-diff, and time-corr-only three parameters",
Expand Down
42 changes: 34 additions & 8 deletions workflows/dia.nf
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,30 @@ workflow DIA {
}

if (params.skip_preliminary_analysis) {
assembly_log = channel.fromPath(params.empirical_assembly_log)
empirical_library = channel.fromPath(params.diann_speclib)
indiv_fin_analysis_in = ch_file_preparation_results.combine(ch_searchdb)
.combine(assembly_log)
.combine(empirical_library)
empirical_lib = empirical_library
def log_file = params.empirical_assembly_log ? file(params.empirical_assembly_log) : null
def parsed_m2 = "0"
def parsed_m1 = "0"
def parsed_w = "0"
if (log_file && log_file.exists()) {
def matcher = log_file.text =~ /Mass accuracy = ([0-9.]+)ppm, MS1 accuracy = ([0-9.]+)ppm, Scan window = ([0-9.]+)/
if (matcher) {
parsed_m2 = matcher[0][1]
parsed_m1 = matcher[0][2]
parsed_w = matcher[0][3]
}
}
indiv_fin_analysis_in = ch_file_preparation_results
.combine(ch_searchdb)
.combine(speclib)
.map { meta_map, ms_file, fasta, library ->
def new_meta = meta_map + [
mass_acc_ms2 : parsed_m2,
mass_acc_ms1 : parsed_m1,
scan_window : parsed_w
]
return [ new_meta, ms_file, fasta, library ]
}
empirical_lib = speclib
} else {
//
// MODULE: PRELIMINARY_ANALYSIS
Expand Down Expand Up @@ -102,9 +120,17 @@ workflow DIA {
.mix(ASSEMBLE_EMPIRICAL_LIBRARY.out.versions)
indiv_fin_analysis_in = ch_file_preparation_results
.combine(ch_searchdb)
.combine(ASSEMBLE_EMPIRICAL_LIBRARY.out.log)
.combine(ASSEMBLE_EMPIRICAL_LIBRARY.out.empirical_library)

.combine(ASSEMBLE_EMPIRICAL_LIBRARY.out.calibrated_params)
.map { meta_map, ms_file, fasta, library, param_file ->
def values = param_file.text.trim().split(',')
def new_meta = meta_map + [
mass_acc_ms2 : values[0],
mass_acc_ms1 : values[1],
scan_window : values[2]
]
return [ new_meta, ms_file, fasta, library ]
}
empirical_lib = ASSEMBLE_EMPIRICAL_LIBRARY.out.empirical_library
}

Expand Down
Loading