Skip to content

fix(maxQuant): Remove unmodified peptides from PTM dataset#116

Merged
tonywu1999 merged 4 commits intodevelfrom
maxq-fix
Jul 14, 2025
Merged

fix(maxQuant): Remove unmodified peptides from PTM dataset#116
tonywu1999 merged 4 commits intodevelfrom
maxq-fix

Conversation

@tonywu1999
Copy link
Contributor

@tonywu1999 tonywu1999 commented Jul 10, 2025

Motivation and Context

Unmodified peptides were showing up in the PTM dataset after conversion for MaxQuant. We should filter out these peptides since they add additional hypotheses to test that are not necessary to test.

Changes

  • Filter out unmodified peptides from the PTM dataset.

Testing

  • Verified with a test dataset
  • Added unit tests when setting useUnmodPeptides to False

Checklist Before Requesting a Review

  • I have read the MSstats contributing guidelines
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of PTM and protein data to ensure only peptides with the specified modification are included when unmodified peptides are excluded.
    • Enhanced processing to return results more efficiently when additional protein evidence is provided.
  • Tests
    • Added new test cases validating data conversion without unmodified peptides, ensuring accurate filtering and data integrity.

@coderabbitai
Copy link

coderabbitai bot commented Jul 10, 2025

"""

Walkthrough

The internal logic of the MaxQtoMSstatsPTMFormat function in R/converters.R was revised. Redundant intermediate list creation was removed, early return logic for evidence_prot was added, and the handling of the use_unmod_peptides flag was clarified to ensure explicit filtering and output structure based on input parameters. Additionally, the .validatePositiveNumberOfRows function in inst/tinytest/test_converters.R was updated to accept a global_profiling parameter, and new tests were added for use_unmod_peptides=FALSE cases.

Changes

File(s) Change Summary
R/converters.R Refactored MaxQtoMSstatsPTMFormat: removed intermediate list assignment, added early return for evidence_prot, clarified filtering logic for use_unmod_peptides, and ensured explicit PTM peptide filtering. No signature changes.
inst/tinytest/test_converters.R Updated .validatePositiveNumberOfRows to accept global_profiling parameter; added tests for MaxQtoMSstatsPTMFormat with use_unmod_peptides=FALSE reflecting absence of global profiling and validating PTM and protein data accordingly.

Poem

A hop and a skip in converters' domain,
Where lists once lingered, now logic is plain.
Early returns and filters so neat,
PTMs sorted, the code feels complete.
With every refactor, the carrots taste sweet! 🥕
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa3658e and f7b3b2f.

📒 Files selected for processing (1)
  • inst/tinytest/test_converters.R (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • inst/tinytest/test_converters.R
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refines the MaxQtoMSstatsPTMFormat converter to remove unmodified peptides from the PTM dataset when requested and to return early when protein evidence is supplied.

  • Moves the default MSstatsPTMformat assignment into branch-specific code and adds an early return for the evidence_prot case
  • Adds filtering of msstatsptm_input to drop peptides lacking the specified mod_id when use_unmod_peptides = FALSE
  • Adjusts list construction for PTM/PROTEIN outputs based on the new branching logic
Comments suppressed due to low confidence (3)

R/converters.R:663

  • The new conditional branch for filtering unmodified peptides lacks unit tests. Please add tests covering both use_unmod_peptides = TRUE and FALSE scenarios to verify expected outputs.
  if (use_unmod_peptides){

R/converters.R:659

  • [nitpick] Quotation style for list names is inconsistent across branches (sometimes quoted, sometimes not). Standardize to unquoted identifiers (e.g., PTM = …) for clarity and consistency.
                            "PROTEIN" = msstats.abun)

R/converters.R:667

  • Construction of MSstatsPTMformat is duplicated in multiple branches. Consider extracting a helper or building the list dynamically to reduce repetition.
    MSstatsPTMformat = list(PTM = msstatsptm_input, 

MSstatsPTMformat = list(PTM = msstatsptm_input,
PROTEIN = msstats.abun)
} else {
msstatsptm_input = msstatsptm_input[grepl(mod_id, msstatsptm_input$PeptideSequence),]
Copy link

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

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

Using grepl without fixed = TRUE treats mod_id as a regex. If mod_id is literal, add fixed = TRUE to avoid unintended regex interpretation.

Copilot uses AI. Check for mistakes.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
inst/tinytest/test_converters.R (1)

8-15: Update function documentation to include the new parameter.

The function signature was updated to include a global_profiling parameter, but the documentation comment above doesn't mention this new parameter.

#' Validate positive number of rows from converter output
#' 
#' @author Anthony Wu
#' 
#' @param msstats_ptm_input A list containing PTM and PROTEIN data tables
+#' @param global_profiling Boolean indicating whether to validate PROTEIN data presence (default TRUE)
.validatePositiveNumberOfRows = function(msstats_ptm_input, global_profiling = TRUE) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55b5a49 and fa3658e.

📒 Files selected for processing (1)
  • inst/tinytest/test_converters.R (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (4)
inst/tinytest/test_converters.R (4)

8-15: Validation logic correctly implements the expected behavior.

The conditional logic appropriately handles both scenarios:

  • When global_profiling=TRUE: validates both PTM and PROTEIN data have rows
  • When global_profiling=FALSE: validates PTM has rows but PROTEIN is NULL

This aligns with the PR objective to optionally exclude unmodified peptides (global profiling data).


96-108: Test case correctly validates use_unmod_peptides=FALSE behavior.

The test properly:

  • Calls MaxQtoMSstatsPTMFormat with use_unmod_peptides=FALSE
  • Uses global_profiling=FALSE in validation to expect only PTM data
  • Validates expected protein IDs and PTM modifications are present
  • Confirms all peptides contain the phosphorylation modification

This test case effectively verifies the PR's core functionality.


176-190: Test case for MaxQ LF properly mirrors the TMT test structure.

The LF test case follows the same pattern as the TMT test:

  • Sets use_unmod_peptides=FALSE
  • Validates with global_profiling=FALSE
  • Checks for expected protein IDs and PTM presence

The consistency between test cases is good for maintainability.


90-94: Minor formatting improvement enhances readability.

The line breaks in the .validatePtmSubstring calls improve code readability without changing functionality.

@tonywu1999 tonywu1999 merged commit 9eead60 into devel Jul 14, 2025
2 checks passed
@tonywu1999 tonywu1999 deleted the maxq-fix branch July 14, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant