Skip to content

fix(profile-plot): Fix summaries for profile plots for protein turnover#196

Merged
tonywu1999 merged 1 commit intodevelfrom
fix-profile-2
Apr 14, 2026
Merged

fix(profile-plot): Fix summaries for profile plots for protein turnover#196
tonywu1999 merged 1 commit intodevelfrom
fix-profile-2

Conversation

@tonywu1999
Copy link
Copy Markdown
Contributor

@tonywu1999 tonywu1999 commented Apr 14, 2026


PR Type

Bug fix


Description

  • Fix summary labels in profile plots

  • Map raw labels by labeling mode

  • Support turnover and heavy/light outputs


Diagram Walkthrough

flowchart LR
  p["Processed labels"] -- "derive" --> m["Raw label map"]
  s["Summarized run data"] -- "apply mapped LABEL" --> q["Correct profile plot summaries"]
  m -- "used by" --> q
Loading

File Walkthrough

Relevant files
Bug fix
dataProcessPlots.R
Correct summary label mapping in profile plots                     

R/dataProcessPlots.R

  • Add raw_label_map for each label mode
  • Map H/L to displayed summary labels
  • Replace fixed summary label selection
  • Fix run summaries for turnover plots
+7/-4     

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

Warning

Rate limit exceeded

@tonywu1999 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 57 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 3 minutes and 57 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 66019f94-222b-41fd-a1cf-0197e31413ab

📥 Commits

Reviewing files that changed from the base of the PR and between 8ebaa57 and 9dd21b0.

📒 Files selected for processing (1)
  • R/dataProcessPlots.R
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-profile-2

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 profile 2 fix(profile-plot): Fix summaries for profile plots for protein turnover Apr 14, 2026
@github-actions github-actions Bot changed the title fix(profile-plot): Fix summaries for profile plots for protein turnover Fix profile 2 Apr 14, 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

Runtime error

The new run-summary path now requires summarized to have a LABEL column. The previous implementation worked without that field by assigning a constant summary label, but this lookup will fail with object 'LABEL' not found for summary tables that are only keyed by protein/run, such as label-free or single-label outputs.

single_protein_summ = summarized[Protein == all_proteins[i], ]
quant = single_protein_summ[
  Protein == all_proteins[i],
  list(PROTEIN = unique(Protein), PEPTIDE = "Run summary",
       TRANSITION = "Run summary", FEATURE = "Run summary",
       LABEL = raw_label_map[LABEL], RUN = RUN,
       ABUNDANCE = LogIntensities, FRACTION = 1, 
Wrong mapping

raw_label_map[LABEL] is unsafe when LABEL is a factor, because R subsets named vectors by the factor's underlying integer codes rather than its displayed values. If the factor levels are ordered differently from H, L, the summary traces can be mislabeled (for example, H becoming Light). Converting LABEL to character before indexing avoids this.

LABEL = raw_label_map[LABEL], RUN = RUN,

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix factor-based lookup

LABEL is often a factor in data.table, and indexing a named vector with a factor
uses the underlying integer codes instead of the label text. That can silently
assign the wrong summary label when the factor levels are reordered or reduced.
Convert LABEL to character before looking it up in raw_label_map.

R/dataProcessPlots.R [392]

-LABEL = raw_label_map[LABEL], RUN = RUN,
+LABEL = unname(raw_label_map[as.character(LABEL)]), RUN = RUN,
Suggestion importance[1-10]: 8

__

Why: This is a valid correctness issue: if summarized$LABEL is a factor, raw_label_map[LABEL] can index by the factor's internal integer codes instead of its text values. Converting LABEL with as.character() makes the lookup reliable and prevents silently wrong labels in the summary plot.

Medium
Preserve unmapped label values

The new mapping assumes every summary LABEL is a raw H/L code, but rows that already
contain normalized values like Heavy, Light, Reference, or Endogenous will become
NA. Preserve the original label when no entry exists in raw_label_map so the summary
rows are still plotted correctly.

R/dataProcessPlots.R [392]

-LABEL = raw_label_map[LABEL], RUN = RUN,
+LABEL = {
+  mapped_label <- unname(raw_label_map[as.character(LABEL)])
+  ifelse(is.na(mapped_label), as.character(LABEL), mapped_label)
+}, RUN = RUN,
Suggestion importance[1-10]: 7

__

Why: This is a reasonable robustness fix because raw_label_map only defines raw H/L keys, so already-normalized values in LABEL would otherwise become NA. Falling back to the original LABEL preserves plotting behavior without changing the mapped case.

Medium

@tonywu1999 tonywu1999 changed the title Fix profile 2 fix(profile-plot): Fix summaries for profile plots for protein turnover Apr 14, 2026
@tonywu1999 tonywu1999 merged commit 293e522 into devel Apr 14, 2026
2 checks passed
@tonywu1999 tonywu1999 deleted the fix-profile-2 branch April 14, 2026 21:09
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