Skip to content

App crashes when all NCA parameters are selected #1231

@Gero1999

Description

@Gero1999

Bug Report

Description

Selecting all NCA parameters and running NCA causes the app to crash with:

Error in [<-: Can't recycle input of size 996 to size 83.

preceded by:

Warning: Values from `PPSTRES` are not uniquely identified; output will contain list-cols.

Root Cause

When all parameters are selected, PKNCA produces result rows with PPTESTCD = NA and PPSTRES = NA. These are internal dependency calculations that PKNCA runs but doesn't expose as named parameters.

In pivot_wider_pknca_results(), these NA-keyed rows create duplicate keys for pivot_wider() (multiple NA rows per subject/interval), which produces list-columns instead of atomic vectors. Downstream code then crashes trying to assign list-columns into a regular data frame.

Additional finding: missing metadata mappings

Comparing PKNCA::get.interval.cols() with metadata_nca_parameters, 4 PKNCA parameters have no CDISC mapping:

PKNCA parameter Description
clr.last Renal clearance (to Tlast)
clr.obs Renal clearance (observed, using AUCinf.obs)
clr.pred Renal clearance (predicted, using AUCinf.pred)
count_conc_measured Count of measured (non-imputed) concentrations

These are not the direct cause of the crash (the NA rows are), but they should be added to the metadata for completeness. When selected, translate_terms() returns the raw PKNCA name unchanged, which could cause issues in CDISC exports.

Debugging evidence

# 24 duplicate rows, all with PPTESTCD = NA
dupes %>% select(USUBJID, PPTESTCD, PPSTRES, start, end, DOSNOA) %>% print(n = 10)
# A tibble: 24 x 6
   USUBJID PPTESTCD PPSTRES start   end DOSNOA
   <chr>   <chr>      <dbl> <dbl> <dbl>  <int>
 1 S1-01   NA            NA     0  24.1      1
 2 S1-01   NA            NA     0  24.1      1
 3 S1-01   NA            NA     0  24.1      1
 4 S1-01   NA            NA     0  24.1      1
 ...

Steps to Reproduce

  1. Upload data with multiple study types
  2. Go to Parameter Selection -> click "Select all"
  3. Click "Run NCA"
  4. App crashes

Fix

Filter out NA PPTESTCD rows before pivoting in pivot_wider_pknca_results(). See PR #1232.

Separately, consider adding the 4 missing parameters to metadata_nca_parameters for completeness."

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions