Skip to content

fix(plotting): Fix groupComparisonPlots to render when viewport dims are low#206

Merged
tonywu1999 merged 1 commit intodevelfrom
fix-plots
Apr 29, 2026
Merged

fix(plotting): Fix groupComparisonPlots to render when viewport dims are low#206
tonywu1999 merged 1 commit intodevelfrom
fix-plots

Conversation

@tonywu1999
Copy link
Copy Markdown
Contributor

@tonywu1999 tonywu1999 commented Apr 29, 2026

PR Type

Bug fix, Other


Description

  • Skip printing Plotly plot objects

  • Prevent plot rendering viewport failures

  • Keep generated plots stored normally

  • Ignore local AI tool folders


Diagram Walkthrough

flowchart LR
  gc["groupComparisonPlots loop"]
  make["Create plot object"]
  check["Check isPlotly"]
  print["Print non-Plotly plot"]
  store["Store plot in plots[[i]]"]
  gc -- "builds" --> make
  make -- "routes to" --> check
  check -- "`FALSE`" --> print
  check -- "`TRUE`" --> store
  print -- "then" --> store
Loading

File Walkthrough

Relevant files
Configuration changes
.Rbuildignore
Ignore local AI tooling directories                                           

.Rbuildignore

  • Add .positai to ignored build paths
  • Add .claude to ignored build paths
+3/-1     
Bug fix
groupComparisonPlots.R
Guard Plotly plots from direct printing                                   

R/groupComparisonPlots.R

  • Only print plots when isPlotly is false
  • Apply the guard in volcano plotting flow
  • Apply the guard in comparison plotting flow
  • Preserve plot assignment to plots[[i]]
+2/-2     

Motivation and Context

The groupComparisonPlots function has issues rendering plots when the viewport has low dimensions, particularly when used in the MSstatsShiny application with Plotly mode enabled. When isPlotly = TRUE, the function is intended to generate interactive Plotly visualizations for web-based rendering. However, unconditional printing of ggplot2 plot objects during Plotly rendering can interfere with the rendering pipeline and cause viewport-related failures. The fix conditionally suppresses these print statements when in Plotly mode, allowing the plots to render correctly regardless of viewport dimensions while maintaining full functionality by returning the plots in their respective lists.

Changes

  • .Rbuildignore: Updated to exclude hidden configuration directories .positai and .claude from R package builds, while continuing to exclude appspec.yml. Added trailing newline to file.

  • .gitignore: Added .positai pattern to ignore list.

  • R/groupComparisonPlots.R:

    • Modified .plotVolcano() function to conditionally print volcano plots only when !isPlotly (i.e., when not in Plotly rendering mode)
    • Modified .plotComparison() function to conditionally print comparison plots only when !isPlotly
    • The plots themselves are still stored in the returned lists regardless of the isPlotly flag, preserving all functionality
    • Changes align with the existing pattern throughout the codebase where Plotly and ggplot2 rendering paths are differentiated by the isPlotly parameter

Testing

No tests were added or modified to verify these changes. The existing test suite in inst/tinytest/test_groupComparison.R covers the groupComparison analysis function but does not include tests for the plotting functions or the isPlotly parameter behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

The pull request excludes AI configuration directories (.positai, .claude) from R package builds and version control, and conditionally restricts plot printing in comparison plot generation to non-Plotly runs.

Changes

Cohort / File(s) Summary
Build and VCS Configuration
.Rbuildignore, .gitignore
Added exclusion patterns for .positai directory; .Rbuildignore also excludes .claude directory while maintaining existing appspec.yml exclusion and adding trailing newline.
Plot Output Behavior
R/groupComparisonPlots.R
Modified volcano plot and comparison plot functions to conditionally print ggplot objects only when not in Plotly mode (!isPlotly), reducing console side effects.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Review effort 2/5

Poem

🐰 Hidden configs tucked away with care,
AI secrets, now beyond compare,
Plots print quiet when Plotly's near,
A bundle built without the noise we'd hear!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title mentions fixing rendering for low viewport dimensions, but the actual changes focus on conditional print behavior in Plotly mode and adding ignore patterns. Clarify whether the primary change is the print behavior adjustment in groupComparisonPlots or the ignore file updates, and align the title with the actual main change in the changeset.
Description check ❓ Inconclusive PR description lacks structured adherence to template with missing detailed changes list and testing documentation despite having mermaid diagram and file walkthrough. Expand Changes section with detailed bullet points and document any unit tests or manual testing performed to verify the Plotly plotting fix works correctly.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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-plots

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.

@tonywu1999 tonywu1999 changed the title fix(plotting): Fix groupComparisonPlots to render when viewport dims … fix(plotting): Fix groupComparisonPlots to render when viewport dims are low Apr 29, 2026
@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Empty output

When isPlotly is TRUE, the plot is no longer printed to the active graphics device before dev.off() runs. In calls that also pass a file address, this means the returned list still contains plot objects but the generated file can be blank or contain no pages because nothing was actually drawn to the device.

if (!isPlotly) print(plot)
plots[[i]] = plot

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Preserve interactive widget rendering

plotly widgets created inside loops/functions usually still need an explicit print()
to render in interactive and notebook contexts. Skipping print(plot) entirely can
make isPlotly = TRUE appear broken; use a guarded print so rendering still happens
where possible without aborting on the small-viewport error this PR is addressing.

R/groupComparisonPlots.R [372]

-if (!isPlotly) print(plot)
+if (isPlotly) {
+    try(print(plot), silent = TRUE)
+} else {
+    print(plot)
+}
Suggestion importance[1-10]: 7

__

Why: This correctly flags a likely regression: skipping print(plot) for plotly objects inside groupComparisonPlots() can prevent them from rendering in functions, loops, and notebook contexts. The proposed guarded print() keeps plotly output visible while still tolerating the rendering error this PR appears to address.

Medium
Reject unsupported save mode

When address is set and isPlotly is TRUE, this branch now skips emitting anything
while the function can still proceed with device-based saving, which can leave users
with blank output files. Guard that combination explicitly here (and in the matching
block below) so the function fails fast instead of silently succeeding with no plot.

R/groupComparisonPlots.R [372]

-if (!isPlotly) print(plot)
+if (!isPlotly) {
+    print(plot)
+} else if (address != FALSE) {
+    stop("`address` is not supported when `isPlotly = TRUE`; save the returned plotly object with a widget export function.")
+}
Suggestion importance[1-10]: 5

__

Why: This is a plausible correctness concern because address != FALSE combined with isPlotly = TRUE may leave the function writing to a graphics device without ever printing a plot. The suggestion is relevant, but its impact is somewhat uncertain since the device-opening and save-path logic are outside the shown hunk.

Low

Copy link
Copy Markdown

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.Rbuildignore (1)

1-11: ⚠️ Potential issue | 🟡 Minor

Inconsistency between PR objectives and files shown.

The PR title indicates this is a fix for "groupComparisonPlots to render when viewport dims are low," and the AI summary mentions "conditionally restricts plot printing in comparison plot generation to non-Plotly runs." However, the files provided for review only contain changes to .gitignore and .Rbuildignore (excluding AI tool directories).

Are the main plotting-related code changes in other files not included in this review? If so, those files should be the primary focus of review for this PR.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.Rbuildignore around lines 1 - 11, The PR claims to fix rendering in
groupComparisonPlots (and conditionally restrict plot printing for non-Plotly
runs), but the diff only touches .gitignore/.Rbuildignore; update the PR to
include the actual plotting changes (the functions/methods that implement
groupComparisonPlots and any plotly-related code paths), or if those changes
exist in other commits/branches, add them to this branch/PR so reviewers can
inspect functions such as groupComparisonPlots, any helper like
renderComparisonPlot or isPlotlyEnabled, and the conditional print logic; ensure
the commit/message clearly references the updated functions and that the diff
contains the files with the plotting/rendering logic for review.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.Rbuildignore:
- Line 8: Update the .Rbuildignore entry for the appspec file to use anchored
regex like the surrounding entries: replace the unanchored literal "appspec.yml"
with a pattern such as "^appspec\\.yml$" so it matches only the root filename
and remains consistent with entries like "^\\.positai$" and "^\\.claude$"; edit
the existing appspec.yml line accordingly.

---

Outside diff comments:
In @.Rbuildignore:
- Around line 1-11: The PR claims to fix rendering in groupComparisonPlots (and
conditionally restrict plot printing for non-Plotly runs), but the diff only
touches .gitignore/.Rbuildignore; update the PR to include the actual plotting
changes (the functions/methods that implement groupComparisonPlots and any
plotly-related code paths), or if those changes exist in other commits/branches,
add them to this branch/PR so reviewers can inspect functions such as
groupComparisonPlots, any helper like renderComparisonPlot or isPlotlyEnabled,
and the conditional print logic; ensure the commit/message clearly references
the updated functions and that the diff contains the files with the
plotting/rendering logic for review.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bd94cdd6-2d98-435c-ab25-0fc81e2fdb6e

📥 Commits

Reviewing files that changed from the base of the PR and between 505e961 and a5f242c.

📒 Files selected for processing (3)
  • .Rbuildignore
  • .gitignore
  • R/groupComparisonPlots.R

Comment thread .Rbuildignore
^docs$
^pkgdown$
appspec.yml No newline at end of file
appspec.yml
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the previous format of the appspec.yml pattern
git log -p --follow -S "appspec" -- .Rbuildignore | head -30

Repository: Vitek-Lab/MSstats

Length of output: 43


🏁 Script executed:

cat -n .Rbuildignore

Repository: Vitek-Lab/MSstats

Length of output: 258


Ensure pattern consistency for .Rbuildignore entries.

The appspec.yml pattern on line 8 lacks regex anchors, making it inconsistent with all other entries in the file. Every other pattern uses the ^ prefix (and many use trailing $ as well), including the newly added ^\.positai$ and ^\.claude$ on lines 9-10. The unanchored pattern appspec.yml will match the filename anywhere in the path, whereas the anchored patterns match only at the root.

Consider changing it to ^appspec\.yml$ to match the format of surrounding entries.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.Rbuildignore at line 8, Update the .Rbuildignore entry for the appspec file
to use anchored regex like the surrounding entries: replace the unanchored
literal "appspec.yml" with a pattern such as "^appspec\\.yml$" so it matches
only the root filename and remains consistent with entries like "^\\.positai$"
and "^\\.claude$"; edit the existing appspec.yml line accordingly.

@tonywu1999 tonywu1999 merged commit dd22ffb into devel Apr 29, 2026
3 checks passed
@tonywu1999 tonywu1999 deleted the fix-plots branch April 29, 2026 20:36
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