Add robust parsing for temperature, time, and dosage for response curves#152
Add robust parsing for temperature, time, and dosage for response curves#152tonywu1999 merged 9 commits intodevelfrom
Conversation
📝 WalkthroughWalkthroughThis PR refactors the dose-response workflow by replacing the convertGroupToNumericDose-dependent build_response_curve_matrix with a data-driven implementation. It introduces prepare_dose_response_fit helper function, adds utility for applying matrix edits, extends package imports (stringr, dplyr, tidyr), and updates corresponding tests and server logic. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
|
Failed to generate code suggestions for PR |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@R/module-statmodel-server.R`:
- Around line 261-287: The function prepare_dose_response_fit should validate
required columns before building cols_to_use: check that the expected response
column ("LogIntensities") and the expected protein column ("Protein") exist (or
explicitly allow a documented alternative), and if any are missing, stop() with
a clear error listing the missing columns rather than inserting NA and silently
dropping them; perform this validation after computing intervention_value but
before constructing cols_to_use/subset_df so downstream doseResponseFit gets a
predictable schema (refer to prepare_dose_response_fit, cols_to_use, subset_df,
and doseResponseFit).
- Around line 205-257: The build_response_curve_matrix function creates a
list-column measurements via str_extract_all which breaks downstream when groups
have multiple tokens; to fix, unnest measurements (use tidyr::unnest on the
measurements column) right after creating measurements so each row has a single
token, then extract numeric value and unit from that character column (use
str_extract on the unnested measurements) before pivot_wider (measurement_type,
value, unit); also remove or replace the direct UI call showNotification with a
returned warning value or a callback parameter so the data-processing function
remains UI-free and testable.
🧹 Nitpick comments (1)
tests/testthat/test-utils-statmodel-server.R (1)
380-420: Tests cover single-measurement groups well but lack multi-measurement coverage.The tests validate the core scenarios (dose, time, temperature) but only for groups containing a single numeric+unit token. Consider adding a test for groups with multiple measurements (e.g.,
"Drug_10nM_24h") to verify thepivot_widerpath and catch the list-column issue flagged inbuild_response_curve_matrix.
Summary by CodeRabbit
Chores
Refactor
Tests