Skip to content

Interval Parameters as options for to compute Ratio Parameter Calculations#1224

Open
Gero1999 wants to merge 13 commits intomainfrom
1135-enhancement/ratio-interval-params
Open

Interval Parameters as options for to compute Ratio Parameter Calculations#1224
Gero1999 wants to merge 13 commits intomainfrom
1135-enhancement/ratio-interval-params

Conversation

@Gero1999
Copy link
Copy Markdown
Collaborator

@Gero1999 Gero1999 commented Apr 14, 2026

Issue

Closes #1135

Description

Interval/partial parameters (e.g. AUCINT_0-20, AUMCINT_0-30) can now be selected as Test or Reference parameters in the Ratio Calculations table.

Key changes:

  1. Wiring: int_parameters reactive from NCA settings is passed into ratios_table_server so the ratio module can read the current interval definitions.

  2. UI dropdown: .build_interval_param_options() constructs range-suffixed entries from the int_parameters table (e.g. AUCINT_0-20), filtering out incomplete rows. These are merged into ratio_param_options() alongside the existing main-interval parameters.

  3. Ratio computation: parse_interval_parameter() detects range-suffixed parameters and extracts the base PPTESTCD + start/end values. .filter_interval_results() pre-filters res$result to only the matching interval rows before calculate_ratios() runs. Uses start_dose/end_dose (dose-relative times) since int_parameters defines intervals relative to dose time. Non-interval parameters are unaffected.

Definition of Done

  • Interval parameters from int_parameters() appear in the ratio Test/Ref Parameter dropdowns with range suffix (e.g. AUCINT_0-20)
  • Dropdown updates reactively when int_parameters() changes
  • calculate_ratio_app() correctly parses range-suffixed parameters and filters by start/end
  • Existing ratio calculations for non-interval parameters are unaffected
  • Unit tests cover interval parameter ratio scenarios
  • Ratio calculations produce correct results for interval parameters (manual app verification)

How to test

  1. Upload a dataset and configure interval/partial parameters in NCA > Settings (e.g. AUCINT with start=0, end=20).
  2. Open the Ratio Calculations accordion — the interval parameters should appear in the Test/Ref Parameter dropdowns as AUCINT_0-20.
  3. Add a ratio row using an interval parameter and run NCA — verify the ratio is computed correctly.
  4. Change the interval definitions in Settings — verify the dropdown updates.
  5. Verify existing (non-interval) ratio calculations still work as before.

Contributor checklist

  • Code passes lintr checks
  • Code passes all unit tests
  • New logic covered by unit tests
  • New logic is documented
  • App or package changes are reflected in NEWS
  • Package version is incremented
  • R script works with the new implementation (if applicable)
  • Settings upload works with the new implementation (if applicable)
  • If any .scss change was done, run data-raw/compile_css.R

Notes to reviewer

  • R is not available in the dev container, so devtools::document(), lintr::lint_package(), and devtools::test() could not be run locally. CI will validate these.
  • The range suffix format (PARAM_start-end) follows the same convention already used in descriptive_statistics.R, nca_results.R, and parameter_plots.R.
  • parse_interval_parameter() supports decimal start/end values (e.g. AUCINT_0.5-12.5).

Gero1999 and others added 7 commits April 14, 2026 13:40
Wire int_parameters from NCA settings into ratios_table_server so the
ratio module can read the current interval/partial parameter definitions.

Closes #1135

Co-authored-by: Ona <no-reply@ona.com>
Add .build_interval_param_options() to construct range-suffixed entries
(e.g. AUCINT_0-20) from the int_parameters table. Merge them into
ratio_param_options() so they appear in the Test/Ref Parameter dropdowns.

Refs #1135
Add parse_interval_parameter() to detect range-suffixed parameters
(e.g. AUCINT_0-20) and extract the base PPTESTCD + start/end values.

Add .filter_interval_results() to pre-filter the result data to only
the specific interval rows before computing ratios.

calculate_ratio_app() now parses both test and ref parameters, filters
the result data when intervals are involved, and passes the base
PPTESTCD to calculate_ratios().

Non-interval parameters are unaffected — parse_interval_parameter()
returns is_interval=FALSE and no filtering occurs.

Refs #1135
Cover parse_interval_parameter() parsing logic (range suffix, decimals,
regular params, multi-part base names) and calculate_ratio_app()
end-to-end with interval parameters as test/ref, verifying correct
interval filtering and backward compatibility with non-interval params.

Refs #1135
Update @param docs to mention range suffix support. Use @nord for
internal helpers parse_interval_parameter and .filter_interval_results.

Refs #1135
.filter_interval_results() now uses start_dose/end_dose (dose-relative
times) instead of absolute start/end when available. int_parameters
defines intervals relative to dose time, so the filter must match
against dose-relative columns to correctly identify intervals across
multiple doses.

Falls back to absolute start/end when dose-relative columns are absent
(e.g. in unit tests with simplified data).

Refs #1135
@Gero1999 Gero1999 requested review from Shaakon35 and js3110 April 14, 2026 13:51
@Gero1999 Gero1999 marked this pull request as ready for review April 14, 2026 13:51
@Gero1999 Gero1999 changed the title 1135 enhancement/ratio interval params Interval Parameters as options for to compute Ratio Parameter Calculations Apr 14, 2026
Copy link
Copy Markdown
Collaborator

@js3110 js3110 left a comment

Choose a reason for hiding this comment

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

Worked well for me :)

Comment thread inst/shiny/modules/tab_nca/setup/ratio_calculations_table.R Outdated
When either test or ref is an interval parameter, start/end cannot be
used as join keys because different interval parameters have different
ranges (e.g. AUCINT_0-20 vs CAVGINT_0-30). The correct rows are
already selected by .filter_interval_results(), so start/end are
redundant as match columns.

Also adds the interval parameter tests that were missing from the
previous commit (only a blank line was inserted).

Refs #1135

Co-authored-by: Ona <no-reply@ona.com>
@Gero1999
Copy link
Copy Markdown
Collaborator Author

While reviewing myself I realized that doing a ratio of two interval parameters (e.g, AUCINT_0-20, AUCINT_0-30) was not working as expected (PKNCA run produced a warning: Ratio MRAUCINT_0-20 not computed.No comparable groups found between RefGroups (PARAM: DrugA)and TestGroups ((all other levels))).

Now it should be fixed

Gero1999 and others added 4 commits April 14, 2026 16:37
…PPTESTCD

When test and ref are different intervals of the same parameter
(e.g. AUCINT_0-2 vs AUCINT_2-4), the sequential filtering was removing
the ref's rows during the test filter pass. Now builds a single removal
mask that preserves rows matching either requested range.

Refs #1135

Co-authored-by: Ona <no-reply@ona.com>
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.

Enhancement: Add interval parameters to ratio calculations section

2 participants