Skip to content

fix(comparisonPlot): Add 95% CI description in tooltip#202

Merged
tonywu1999 merged 1 commit intodevelfrom
ci-interval
Apr 24, 2026
Merged

fix(comparisonPlot): Add 95% CI description in tooltip#202
tonywu1999 merged 1 commit intodevelfrom
ci-interval

Conversation

@tonywu1999
Copy link
Copy Markdown
Contributor

@tonywu1999 tonywu1999 commented Apr 23, 2026

PR Type

Bug fix, Documentation


Description

  • Pass sig into comparison plot helper

  • Show CI percent in tooltips

  • Document sig-driven CI behavior


Diagram Walkthrough

flowchart LR
  A["groupComparisonPlots"] 
  B["makeComparison helper"]
  C["Tooltip with CI percentage"]
  D["Rd documentation"]

  A -- "passes sig" --> B
  B -- "builds label" --> C
  D -- "documents sig argument" --> B
Loading

File Walkthrough

Relevant files
Bug fix
groupComparisonPlots.R
Forward significance level to plot helper                               

R/groupComparisonPlots.R

  • Pass sig into .makeComparison
  • Align helper inputs with CI calculation
+2/-2     
utils_groupcomparison_plots.R
Add dynamic confidence interval tooltip label                       

R/utils_groupcomparison_plots.R

  • Add sig parameter to .makeComparison
  • Derive confidence interval label from sig
  • Append CI percentage text to tooltip
+4/-4     
Documentation
dot-makeComparison.Rd
Document significance argument for comparison plots           

man/dot-makeComparison.Rd

  • Add sig to .makeComparison usage
  • Document confidence interval meaning of sig
+4/-1     

Motivation and Context

This PR enhances the user interface of the comparison plot by providing clearer information about the confidence interval (CI) level displayed in interactive tooltips. When users hover over data points in a comparison plot, the tooltip now explicitly indicates what confidence level (e.g., 95% CI) is being visualized, removing ambiguity about the statistical measure being presented.

Summary of Changes

  • Parameter Flow: The sig parameter (FDR/significance cutoff) is now forwarded from the groupComparisonPlots function through to the internal .makeComparison helper function, enabling access to the significance level during plot construction.

  • Confidence Interval Label Generation: The .makeComparison function now computes a formatted ci_label string as "(X% CI)" where X is calculated as (1 - sig) × 100. With the default sig = 0.05, this produces "(95% CI)".

  • Tooltip Enhancement: The point tooltip text in the comparison plot (via geom_point aesthetic) is updated to append the confidence interval label after the existing log fold change and confidence interval width values, resulting in tooltips like: "logFC: 1.2345 ± 0.6789 (95% CI)".

  • Documentation Update: The .makeComparison function's Roxygen documentation is updated to document the new sig parameter, clarifying that it sets the significance level for computing and displaying the 100(1-sig)% confidence interval in the comparison plot.

Files Modified

  • R/groupComparisonPlots.R: Passes sig parameter to .makeComparison invocation (lines 423-425)
  • R/utils_groupcomparison_plots.R: Adds sig parameter to function signature and implements ci_label creation and tooltip integration (lines 284-296)
  • man/dot-makeComparison.Rd: Documents the new sig parameter and its role in confidence interval calculation

Unit Tests

No unit tests are included in this PR to verify the tooltip text generation or the confidence interval label formatting. Existing test suites (test_groupComparison.R, test_groupComparisonQCPlots.R) do not contain tests that would validate this tooltip enhancement.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

The sig parameter is forwarded from .plotComparison into .makeComparison during comparison plot construction. This allows the comparison plot builder to compute and display a confidence interval label in point tooltips derived from the provided FDR cutoff level.

Changes

Cohort / File(s) Summary
Comparison Plot Construction
R/groupComparisonPlots.R, R/utils_groupcomparison_plots.R
The sig parameter is passed through the function call chain and used to compute a confidence interval label ((<(1-sig)*100>% CI)) that is appended to point tooltip text in the comparison plot.
Function Documentation
man/dot-makeComparison.Rd
Documentation for .makeComparison is updated to document the new sig parameter, specifying it controls the FDR cutoff and confidence interval level (default: sig=0.05).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

Review effort 2/5

Suggested reviewers

  • devonjkohler

Poem

🐰 A hop, skip, and a parameter jump,
Through functions the sig values bump,
Tooltips now shine with CI pride,
Confidence intervals on the ride! 📊✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description lacks required sections from the template: 'Motivation and Context' and 'Changes' are incomplete, and 'Testing' section is entirely missing. Add detailed motivation explaining the bug or issue, provide a complete bullet-point list of all changes made across files, and document any unit tests added or modified to verify the changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding confidence interval percentage information to comparison plot tooltips.
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 ci-interval

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: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect CI label

The tooltip now reports the interval as (1 - sig) * 100% CI, but the plotted error bars are computed earlier with qt(1 - sig / (2 * nrow(single_protein)), ...), which is a Bonferroni-adjusted interval when there is more than one comparison for a protein. For example, with sig = 0.05 and 4 comparisons, the bars correspond to about a 98.75% CI per comparison, not 95%. This makes the new tooltip misleading for any protein with multiple comparisons.

ci_label = paste0("(", (1 - sig) * 100, "% CI)")
protein = unique(input$Protein)
plot = ggplot(input, aes(x = .data$Label, y = .data$logFC)) +
    geom_errorbar(aes(ymax = .data$logFC + .data$ciw, ymin = .data$logFC - .data$ciw),
                  data = input,
                  width = 0.1,
                  colour = "red") +
    geom_point(aes(text = paste0("logFC: ", round(.data$logFC, 4), " ± ", round(.data$ciw, 4), " ", ci_label)),

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Correct displayed confidence level

The tooltip label is currently inconsistent with the interval actually plotted. ciw
is computed using a Bonferroni-adjusted alpha (sig / (2 * nrow(...))), so showing (1
- sig) * 100% CI misreports the confidence level whenever there is more than one
comparison.

R/utils_groupcomparison_plots.R [289]

-ci_label = paste0("(", (1 - sig) * 100, "% CI)")
+ci_level = (1 - sig / nrow(input)) * 100
+ci_label = paste0("(", format(round(ci_level, 1), trim = TRUE, scientific = FALSE), "% CI)")
Suggestion importance[1-10]: 5

__

Why: This is a correct observation: ci_label shows (1 - sig)% while ciw is computed using a Bonferroni-adjusted level based on the number of rows. The fix improves tooltip accuracy in .makeComparison, but it only affects displayed text rather than the plotted interval itself.

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.

🧹 Nitpick comments (1)
R/utils_groupcomparison_plots.R (1)

284-296: Tooltip CI label addition looks good.

The new sig parameter and ci_label integration are clean and consistent with the documented family-wise confidence level (ciw at the call site uses a Bonferroni-corrected quantile qt(1 - sig/(2n), DF), so the (1-sig)*100% CI label correctly reflects the joint confidence level — matching the existing @param sig description in groupComparisonPlots.R line 12).

One optional nit: since ci_label is a constant per plot, you could also surface it in a subtitle/caption (e.g., labs(subtitle = ci_label)) so the CI level is visible in the static ggplot output (PDF), not only in the plotly tooltip. Feel free to ignore if the tooltip-only surfacing is intentional.

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

In `@R/utils_groupcomparison_plots.R` around lines 284 - 296, The plot currently
only shows the CI level in the interactive tooltip; add the constant ci_label to
the static ggplot output so PDF/PNG exports show the CI too by adding it to plot
labels (e.g., use labs(subtitle = ci_label) or labs(caption = ci_label)) in the
.makeComparison function after the ggplot/geom layers so the CI text appears on
the static plot as well as in the tooltip.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@R/utils_groupcomparison_plots.R`:
- Around line 284-296: The plot currently only shows the CI level in the
interactive tooltip; add the constant ci_label to the static ggplot output so
PDF/PNG exports show the CI too by adding it to plot labels (e.g., use
labs(subtitle = ci_label) or labs(caption = ci_label)) in the .makeComparison
function after the ggplot/geom layers so the CI text appears on the static plot
as well as in the tooltip.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 99661923-7928-4d28-861d-bb818fbf01e4

📥 Commits

Reviewing files that changed from the base of the PR and between ffcf6d7 and e4d30ae.

📒 Files selected for processing (3)
  • R/groupComparisonPlots.R
  • R/utils_groupcomparison_plots.R
  • man/dot-makeComparison.Rd

@tonywu1999 tonywu1999 merged commit 2cb7066 into devel Apr 24, 2026
3 checks passed
@tonywu1999 tonywu1999 deleted the ci-interval branch April 24, 2026 00:12
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