Skip to content

fix: IsobaricWorkflow - auto-detect labelling type, pass isotope correction and extraction params#693

Merged
ypriverol merged 1 commit intobigbio:dev_IsobaricWorkflowfrom
ypriverol:fix/isobaric-workflow-integration
Apr 3, 2026
Merged

fix: IsobaricWorkflow - auto-detect labelling type, pass isotope correction and extraction params#693
ypriverol merged 1 commit intobigbio:dev_IsobaricWorkflowfrom
ypriverol:fix/isobaric-workflow-integration

Conversation

@ypriverol
Copy link
Copy Markdown
Member

Summary

Fixes several issues in the IsobaricWorkflow integration (PR #604) to make it ready for merge:

  • Auto-detect labelling type from SDRF instead of hardcoded params.type='itraq4plex'. The labelling_type is extracted from the meta channel (already parsed from SDRF), matching how IsobaricAnalyzer works.
  • Pass isotope correction matrix when params.isotope_correction is enabled, using the same correction matrix parsing logic as IsobaricAnalyzer
  • Pass extraction parameters (min_precursor_purity, precursor_isotope_deviation, min_reporter_intensity) that were missing from the IsobaricWorkflow invocation
  • Remove unused type parameter from nextflow.config (no longer needed since type is auto-detected)

Changes

File Change
modules/local/openms/isobaric_workflow/main.nf Add labelling_type input, isotope correction matrix handling, extraction params
workflows/tmt.nf Extract labelling_type from meta channel and pass to IsobaricWorkflow
nextflow.config Remove hardcoded type = 'itraq4plex'

Test plan

  • Run with TMT16plex dataset — verify labelling_type is correctly auto-detected
  • Run with isotope_correction enabled — verify correction matrix is passed
  • Run with iTRAQ4plex dataset — verify 4-plex correction matrix format works

🤖 Generated with Claude Code

…rection

- Use labelling_type from SDRF meta (auto-detected) instead of
  hardcoded params.type='itraq4plex' default
- Pass isotope correction matrix when params.isotope_correction is
  enabled, matching the IsobaricAnalyzer module behavior
- Pass extraction parameters (min_precursor_purity,
  precursor_isotope_deviation, min_reporter_intensity) that were
  missing from the IsobaricWorkflow invocation
- Remove unused 'type' parameter from nextflow.config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 3, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ad56dc98-4619-4579-b3ca-76bf638cbb76

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review
Copy link
Copy Markdown
Contributor

ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan

Review Summary by Qodo

Auto-detect IsobaricWorkflow labelling type and pass correction parameters

🐞 Bug fix ✨ Enhancement

Grey Divider

Walkthroughs

Description
• Auto-detect labelling type from SDRF metadata instead of hardcoded parameter
• Pass isotope correction matrix when enabled, matching IsobaricAnalyzer behavior
• Add missing extraction parameters to IsobaricWorkflow invocation
• Remove unused hardcoded type parameter from configuration
Diagram
flowchart LR
  SDRF["SDRF metadata"]
  META["Meta channel<br/>labelling_type"]
  TMT["TMT workflow"]
  ISO["IsobaricWorkflow<br/>process"]
  PARAMS["Extraction &<br/>correction params"]
  
  SDRF -- "auto-detected" --> META
  META -- "extracted" --> TMT
  TMT -- "labelling_type" --> ISO
  PARAMS -- "passed" --> ISO
Loading

Grey Divider

File Changes

1. modules/local/openms/isobaric_workflow/main.nf ✨ Enhancement +24/-1

Add dynamic labelling type and correction parameters

• Add labelling_type as input parameter to process
• Implement isotope correction matrix parsing and formatting based on labelling type
• Replace hardcoded params.type with dynamic labelling_type input
• Add missing extraction parameters: min_precursor_purity, precursor_isotope_deviation,
 min_reporter_intensity

modules/local/openms/isobaric_workflow/main.nf


2. workflows/tmt.nf ✨ Enhancement +5/-2

Extract and pass labelling type to workflow

• Extract labelling_type from meta channel in multiMap operation
• Pass extracted labelling_type as first argument to ISOBARIC_WORKFLOW process
• Use .first() to get single labelling type value from channel

workflows/tmt.nf


3. nextflow.config ⚙️ Configuration changes +0/-3

Remove unused hardcoded type parameter

• Remove hardcoded type = 'itraq4plex' parameter from IsobaricWorkflow configuration section

nextflow.config


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented Apr 3, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX Issues (0)

Grey Divider


Action required

1. Isotope correction silently skipped 🐞 Bug ≡ Correctness
Description
In ISOBARIC_WORKFLOW, enabling params.isotope_correction without setting
params.plex_corr_matrix_file results in no isotope-correction flags being passed to
IsobaricWorkflow, producing uncorrected reporter quantification without any error. This differs from
ISOBARIC_ANALYZER, which hard-fails when the matrix path is missing, making the workflow behavior
inconsistent and error-prone.
Code

modules/local/openms/isobaric_workflow/main.nf[R42-58]

+    // Build isotope correction matrix argument if enabled
+    def isotope_correction = ""
+    if (params.isotope_correction && params.plex_corr_matrix_file != null) {
+        def matrix_lines = new File(params.plex_corr_matrix_file).readLines()
+            .findAll { !it.startsWith('#') && it.trim() }
+            .drop(1)
+            .collect { line ->
+                def values = line.split('/')
+                if (labelling_type == 'tmt18plex' || labelling_type == 'tmt16plex') {
+                    return "\"${values[1]}/${values[2]}/${values[3]}/${values[4]}/${values[5]}/${values[6]}/${values[7]}/${values[8]}\""
+                } else {
+                    return "\"${values[1]}/${values[2]}/${values[3]}/${values[4]}\""
+                }
+            }
+        def correction_matrix = matrix_lines.join(" ")
+        isotope_correction = "-quantification:isotope_correction true -${labelling_type}:correction_matrix ${correction_matrix}"
+    }
Evidence
ISOBARIC_WORKFLOW only constructs the isotope correction CLI flags when both
params.isotope_correction and params.plex_corr_matrix_file are set; otherwise it leaves the
interpolated ${isotope_correction} empty, so the tool runs without correction even though the user
enabled it. ISOBARIC_ANALYZER explicitly errors if isotope_correction is enabled but
plex_corr_matrix_file is null, demonstrating the intended contract and highlighting the
inconsistency.

modules/local/openms/isobaric_workflow/main.nf[42-58]
modules/local/openms/isobaric_workflow/main.nf[60-80]
modules/local/openms/isobaric_analyzer/main.nf[28-35]
nextflow_schema.json[776-785]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`ISOBARIC_WORKFLOW` silently omits isotope-correction flags when `params.isotope_correction` is true but `params.plex_corr_matrix_file` is null. This produces incorrect (uncorrected) quantification without failing.

### Issue Context
`ISOBARIC_ANALYZER` already enforces the expected contract by erroring when `isotope_correction` is enabled but the matrix file is missing. `ISOBARIC_WORKFLOW` should match that behavior.

### Fix Focus Areas
- modules/local/openms/isobaric_workflow/main.nf[42-58]
- modules/local/openms/isobaric_workflow/main.nf[60-79]
- modules/local/openms/isobaric_analyzer/main.nf[28-35]

### Suggested fix
- If `params.isotope_correction` is true and `params.plex_corr_matrix_file` is null/empty, `error("plex_corr_matrix_file is required when isotope_correction is enabled")`.
- Optionally mirror `ISOBARIC_ANALYZER` and always pass `-quantification:isotope_correction true/false` explicitly for clarity/consistency.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Missing matrix path validation 🐞 Bug ☼ Reliability
Description
ISOBARIC_WORKFLOW reads the correction matrix using new
File(params.plex_corr_matrix_file).readLines() without checking existence or producing a friendly
error, so a wrong path fails as an unhandled FileNotFoundException during task script construction.
This reduces reliability and debuggability compared to explicit pipeline validation used elsewhere.
Code

modules/local/openms/isobaric_workflow/main.nf[R44-46]

+    if (params.isotope_correction && params.plex_corr_matrix_file != null) {
+        def matrix_lines = new File(params.plex_corr_matrix_file).readLines()
+            .findAll { !it.startsWith('#') && it.trim() }
Evidence
The module directly reads the matrix path via java.io.File without a guard; if the path is
incorrect, Groovy will throw at readLines() (often surfacing as a stack trace rather than a clear
Nextflow error). In contrast, other inputs in the pipeline are explicitly checked for existence with
a clear message before continuing.

modules/local/openms/isobaric_workflow/main.nf[44-46]
subworkflows/local/create_input_channel/main.nf[97-100]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`ISOBARIC_WORKFLOW` reads `params.plex_corr_matrix_file` with `new File(...).readLines()` without validating that the file exists. Misconfiguration yields a cryptic runtime exception.

### Issue Context
The pipeline already performs explicit existence checks for other user-provided file paths.

### Fix Focus Areas
- modules/local/openms/isobaric_workflow/main.nf[44-46]
- subworkflows/local/create_input_channel/main.nf[97-100]

### Suggested fix
- Before `readLines()`, validate that `params.plex_corr_matrix_file` points to an existing file and fail with `error("...")` including the bad path.
- (Optional) also validate basic format (e.g., ensure after filtering+drop(1) the matrix has at least one line) to avoid IndexOutOfBounds errors later.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@ypriverol ypriverol merged commit 6f76db5 into bigbio:dev_IsobaricWorkflow Apr 3, 2026
6 of 25 checks passed
Comment on lines +42 to +58
// Build isotope correction matrix argument if enabled
def isotope_correction = ""
if (params.isotope_correction && params.plex_corr_matrix_file != null) {
def matrix_lines = new File(params.plex_corr_matrix_file).readLines()
.findAll { !it.startsWith('#') && it.trim() }
.drop(1)
.collect { line ->
def values = line.split('/')
if (labelling_type == 'tmt18plex' || labelling_type == 'tmt16plex') {
return "\"${values[1]}/${values[2]}/${values[3]}/${values[4]}/${values[5]}/${values[6]}/${values[7]}/${values[8]}\""
} else {
return "\"${values[1]}/${values[2]}/${values[3]}/${values[4]}\""
}
}
def correction_matrix = matrix_lines.join(" ")
isotope_correction = "-quantification:isotope_correction true -${labelling_type}:correction_matrix ${correction_matrix}"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Isotope correction silently skipped 🐞 Bug ≡ Correctness

In ISOBARIC_WORKFLOW, enabling params.isotope_correction without setting
params.plex_corr_matrix_file results in no isotope-correction flags being passed to
IsobaricWorkflow, producing uncorrected reporter quantification without any error. This differs from
ISOBARIC_ANALYZER, which hard-fails when the matrix path is missing, making the workflow behavior
inconsistent and error-prone.
Agent Prompt
### Issue description
`ISOBARIC_WORKFLOW` silently omits isotope-correction flags when `params.isotope_correction` is true but `params.plex_corr_matrix_file` is null. This produces incorrect (uncorrected) quantification without failing.

### Issue Context
`ISOBARIC_ANALYZER` already enforces the expected contract by erroring when `isotope_correction` is enabled but the matrix file is missing. `ISOBARIC_WORKFLOW` should match that behavior.

### Fix Focus Areas
- modules/local/openms/isobaric_workflow/main.nf[42-58]
- modules/local/openms/isobaric_workflow/main.nf[60-79]
- modules/local/openms/isobaric_analyzer/main.nf[28-35]

### Suggested fix
- If `params.isotope_correction` is true and `params.plex_corr_matrix_file` is null/empty, `error("plex_corr_matrix_file is required when isotope_correction is enabled")`.
- Optionally mirror `ISOBARIC_ANALYZER` and always pass `-quantification:isotope_correction true/false` explicitly for clarity/consistency.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ypriverol this feels important!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants