Skip to content

fix(profile-plot): Only add error bars to profile plots if bounds exist#197

Merged
tonywu1999 merged 1 commit intodevelfrom
fix-error-bars
Apr 14, 2026
Merged

fix(profile-plot): Only add error bars to profile plots if bounds exist#197
tonywu1999 merged 1 commit intodevelfrom
fix-error-bars

Conversation

@tonywu1999
Copy link
Copy Markdown
Contributor

@tonywu1999 tonywu1999 commented Apr 14, 2026

PR Type

Bug fix


Description

  • Skip error bars without bounds

  • Filter Run summary rows by bounds

  • Prevent invalid profile plot rendering


Diagram Walkthrough

flowchart LR
  input["Profile plot input rows"]
  filter["Filter Run summary rows with non-NA bounds"]
  errorbars["Render error bars only when valid"]
  plot["Stable censored profile plot"]
  input -- "apply bounds check" --> filter
  filter -- "provides valid rows" --> errorbars
  errorbars -- "avoids missing-bound errors" --> plot
Loading

File Walkthrough

Relevant files
Bug fix
utils_dataprocess_plots.R
Guard profile error bars against missing bounds                   

R/utils_dataprocess_plots.R

  • Restricts geom_errorbar() data to Run summary rows
  • Excludes rows with NA in UPPERBOUND or LOWERBOUND
  • Prevents adding error bars when bounds are unavailable
+4/-4     

Motivation and Context

Error bars in run-summary profile plots were being rendered regardless of whether confidence bound values were actually available. This could cause rendering issues or misleading visualizations when the UPPERBOUND and LOWERBOUND columns contained missing values (NA). The fix ensures that error bars are only added to the plot when both upper and lower bounds are present, preventing display artifacts and maintaining visual integrity.

Changes

  • Modified the geom_errorbar() call in the .makeSummaryProfilePlot() function in R/utils_dataprocess_plots.R
  • Enhanced the data filtering condition for the error bar layer from:
    • input[input$PEPTIDE == "Run summary"]
    • to: input[input$PEPTIDE == "Run summary" & !is.na(input$UPPERBOUND) & !is.na(input$LOWERBOUND)]
  • This addition of two new filtering conditions (!is.na(input$UPPERBOUND) and !is.na(input$LOWERBOUND)) ensures error bars are only rendered when both bound values are defined
  • All other aesthetic properties and styling of the error bar layer remain unchanged

Coding Guidelines

No violations of coding guidelines were identified. The change follows the existing code style and conventions used throughout the codebase for conditional data filtering in ggplot2 layer definitions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

The .makeSummaryProfilePlot function's error bar layer for run summaries now applies an additional filter to exclude rows with missing upper or lower bounds, ensuring only complete error bar data is visualized rather than attempting to render bars with incomplete bound information.

Changes

Cohort / File(s) Summary
Error Bar Data Filtering
R/utils_dataprocess_plots.R
Added filter condition to run-summary error bar layer to exclude rows with missing UPPERBOUND or LOWERBOUND values, preventing incomplete error bars from being rendered.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Vitek-Lab/MSstats#179: Modifies the same .makeSummaryProfilePlot function's run-summary error bar handling using LOWERBOUND/UPPERBOUND filtering logic.

Suggested reviewers

  • devonjkohler

Poem

🐰 Bounds need both, or none at all,
No halfway lines upon the wall!
Empty bounds? They're cast away,
Clean error bars will save the day!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description lacks required template sections: Motivation and Context is missing, Changes section is empty, Testing section is empty, and checklist items are unchecked. Complete all required template sections: add motivation/context explaining the bug, provide detailed bullet-point list of changes made, describe any tests added or modified, and check the required checklist items before requesting review.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding error bars only when bounds exist, which aligns with the code modification that filters Run summary rows by bound availability.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-error-bars

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.

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@tonywu1999 tonywu1999 merged commit 9b4cf23 into devel Apr 14, 2026
3 checks passed
tonywu1999 added a commit that referenced this pull request Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant