Skip to content

VSSO unit mismatch between App and exported script (ADPP) #1151

@Gero1999

Description

@Gero1999

Problem

When customizing VSSO units in the app (e.g. mg/(ug/mL)mL), the ADPP output from the app and the ADPP output from running the exported script may show different units for VSSO.

Root cause

The app and the script apply custom units pre-calculation via rows_update on the PKNCAdata units table, but they use different join keys:

  • App (inst/shiny/modules/tab_nca.R:126-137): Uses dynamic by_cols computed from intersect(names(data$units), names(custom_units)), excluding PPSTRESU and conversion_factor. This includes group columns (e.g. PARAM).
  • Script (R/PKNCA.R, PKNCA_update_data_object): Uses hardcoded by = c("PPTESTCD", "PPORRESU"), ignoring group columns.

When the custom units table contains group columns (which it does — PKNCA_build_units_table includes them), the script's rows_update treats those group columns as columns to update rather than join keys. This can cause:

  • Incorrect matching across analytes sharing the same PPTESTCD + PPORRESU
  • Group column values being overwritten

Expected behavior

The script should produce the same ADPP output (including units) as the app for all parameters.

Suggested fix

Align the join logic in PKNCA_update_data_object with the app's tab_nca.R:

# In R/PKNCA.R, PKNCA_update_data_object, replace:
by = c("PPTESTCD", "PPORRESU")

# With:
by_cols <- intersect(names(data$units), names(custom_units_table))
by_cols <- setdiff(by_cols, c("PPSTRESU", "conversion_factor"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Next SprintThis issue will be picked on the next sprintbugSomething isn't working

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions