Skip to content

Added synthesis/degradation toggle to turnover response curves#211

Merged
tonywu1999 merged 1 commit into
develfrom
MSstatsShiny/work/20260519_turnover_synthesis_vs_degradation
May 19, 2026
Merged

Added synthesis/degradation toggle to turnover response curves#211
tonywu1999 merged 1 commit into
develfrom
MSstatsShiny/work/20260519_turnover_synthesis_vs_degradation

Conversation

@tonywu1999

@tonywu1999 tonywu1999 commented May 19, 2026

Copy link
Copy Markdown
Contributor
  • Repurposed the increasing-trend checkbox in protein_turnover template to pick H_frac (synthesis) vs L_frac (degradation) in prepare_turnover_for_dose_response() and downstream curve fit, plot, and download paths
  • Defaulted zero-timepoint anchor to response = 1 for degradation (pre-existing light pool intact) and 0 for synthesis (no heavy incorporated yet)
  • Set turnover plot y-axis label to "Turnover Ratio"
  • Added 6 unit tests covering column selection and zero-timepoint behavior; no testServer() dependency

Motivation & Context

The protein turnover analysis module previously only supported analyzing synthesis (the incorporation of heavy isotopes measured by H_frac). This PR extends the functionality to also support degradation analysis (the loss of light isotopes measured by L_frac) by repurposing the existing "increasing-trend" checkbox as a synthesis/degradation toggle. This allows the dose-response curve fitting, visualization, and analysis workflows to handle both turnover mechanisms with appropriate response anchors at time zero.

Changes

Core Function Changes

  • prepare_turnover_for_dose_response() in R/statmodel-server-comparisons.R:
    • Added new parameter increasing (default TRUE) to the function signature
    • Function now selects H_frac when increasing=TRUE (synthesis) and L_frac when increasing=FALSE (degradation)
    • Updated response filtering to use the selected fraction column instead of always using H_frac
    • Modified synthetic zero-timepoint row generation: sets response = 0 for synthesis cases and response = 1 for degradation cases (previously always set to 0)
    • Updated documentation and comments to reflect new parameter and behavior

Server Logic Updates

  • R/module-statmodel-server.R:

    • Extracts increasing flag from the "increasing-trend" checkbox input
    • Passes the increasing flag consistently to both prepare_turnover_for_dose_response() and doseResponseFit() calls
    • Applied flag to both dose-response modeling and visualization code paths
  • R/statmodel-server-visualization.R:

    • Updated response-curve download handler to compute increasing boolean and pass it to both prepare_turnover_for_dose_response() and visualizeResponseProtein()
    • Changed turnover plot y-axis label from "relative abundance" to "Turnover Ratio"

User Interface Updates

  • R/statmodel-server-options-modeling.R:
    • Updated checkbox label and tooltip strings to explicitly frame the toggle as "Synthesis" vs "Degradation"
    • Enhanced text to reference the corresponding fractions (H_frac for synthesis, L_frac for degradation)

Unit Tests

Added six new unit tests in tests/testthat/test-module-turnover.R covering:

  • Response fraction column selection based on the increasing argument (H_frac when TRUE, L_frac when FALSE)
  • Default behavior (selecting H_frac when increasing parameter is not specified)
  • Synthetic zero-timepoint row generation with correct response values (response = 0 for synthesis, response = 1 for degradation)
  • Row filtering behavior (dropping rows with NA values in the selected fraction column)

All tests are designed as unit tests that do not depend on testServer() for simpler, more focused testing.

Review Change Stack

* Repurposed the increasing-trend checkbox in protein_turnover template to pick H_frac (synthesis) vs L_frac (degradation) in prepare_turnover_for_dose_response() and downstream curve fit, plot, and download paths
* Defaulted zero-timepoint anchor to response = 1 for degradation (pre-existing light pool intact) and 0 for synthesis (no heavy incorporated yet)
* Set turnover plot y-axis label to "Turnover Ratio"
* Added 6 unit tests covering column selection and zero-timepoint behavior; no testServer() dependency

See ai/todos/active/TODO-MSShiny-20260519_turnover_synthesis_vs_degradation.md

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5883d02d-99d1-4c30-8aa3-f268e76aec79

📥 Commits

Reviewing files that changed from the base of the PR and between 0ac1c03 and bce788a.

📒 Files selected for processing (5)
  • R/module-statmodel-server.R
  • R/statmodel-server-comparisons.R
  • R/statmodel-server-options-modeling.R
  • R/statmodel-server-visualization.R
  • tests/testthat/test-module-turnover.R

📝 Walkthrough

Walkthrough

This PR extends protein turnover dose-response modeling to support both synthesis and degradation modes by introducing an increasing flag throughout the workflow. The flag determines whether to use H_frac (synthesis, increasing=TRUE) or L_frac (degradation, increasing=FALSE) for modeling and visualization.

Changes

Protein Turnover Increasing/Decreasing Mode Support

Layer / File(s) Summary
Core function contract: fraction selection and zero-timepoint logic
R/statmodel-server-comparisons.R
prepare_turnover_for_dose_response now accepts increasing parameter (default TRUE) to select H_frac when TRUE, L_frac when FALSE. Synthetic zero-dose rows are assigned response=0 for synthesis and response=1 for degradation.
Fitting pipeline integration
R/module-statmodel-server.R
Turnover-response fitting workflow in statmodelServer derives increasing from UI state and passes it consistently into prepare_turnover_for_dose_response and doseResponseFit.
Visualization pipeline wiring
R/module-statmodel-server.R, R/statmodel-server-visualization.R
Both visualization paths compute and pass the increasing flag through prepare_turnover_for_dose_response into visualizeResponseProtein. Y-axis label updated to "Turnover Ratio".
UI label clarity
R/statmodel-server-options-modeling.R
Turnover response-curve checkbox labels and tooltips are clarified to explicitly map "Synthesis" (H_frac increasing) and "Degradation" (L_frac decreasing).
Test coverage
tests/testthat/test-module-turnover.R
New unit tests validate fraction selection (H_frac vs L_frac), zero-timepoint behavior (response=0 for synthesis, response=1 for degradation), and NA filtering on the selected column.

Possibly related PRs

  • Vitek-Lab/MSstatsShiny#153: Adds the "increasing trend" UI checkbox (modeling_response_curve_increasing_trend) that drives the increasing flag passed through prepare_turnover_for_dose_response and doseResponseFit in this PR.
  • Vitek-Lab/MSstatsShiny#139: Extends the response-curve workflow with visualizeResponseProtein and doseResponseFit; this PR builds on those same code paths by wiring the increasing flag through them.

Suggested labels

enhancement

Suggested reviewers

  • sszvetecz

Poem

🐰 A turnover flag hops through the code,
Now synthesis and degradation ✨ coexist,
H_frac and L_frac, each their own mode,
From fitting to plots, no logic is missed,
Tests validate all, from zero to true!


Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a synthesis/degradation toggle to turnover response curves, which is the core purpose of this PR.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch MSstatsShiny/work/20260519_turnover_synthesis_vs_degradation

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 merged commit b5c1964 into devel May 19, 2026
2 checks passed
@tonywu1999 tonywu1999 deleted the MSstatsShiny/work/20260519_turnover_synthesis_vs_degradation branch May 19, 2026 15:38
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