From 7f5175d96d3b44a3d9a0c6a2012774879f5eca36 Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Fri, 22 Aug 2025 15:36:46 -0400 Subject: [PATCH 1/3] duplicate conc values can occur via cmaxes, which causes error in predict_with_exposure_plot. adding failing test showing conc column is not unique. --- .../test-compute_exposure_predictions.R | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/testthat/test-compute_exposure_predictions.R b/tests/testthat/test-compute_exposure_predictions.R index a407742..eeff853 100644 --- a/tests/testthat/test-compute_exposure_predictions.R +++ b/tests/testthat/test-compute_exposure_predictions.R @@ -32,3 +32,42 @@ test_that('compute_exposure_predictions runs fine for good model and full data', ) ) }) + + +test_that('compute_exposure_predictions does not add non-unique conc values with cmaxes', { + data_proc <- preprocess(cqtkit_data_dofetilide) + mod <- fit_prespecified_model( + data_proc, + deltaQTCF, + ID, + CONC, + deltaQTCFBL, + TRTG, + TAFD, + method = "ML", + remove_conc_iiv = FALSE + ) + + expo_pred <- compute_exposure_predictions( + data_proc, + mod, + CONC, + treatment_predictors = list( + CONC = 10, + deltaQTCFBL = 0, + TRTG = "Dofetilide", + TAFD = "1 HR" + ), + control_predictors = list( + CONC = 0, + deltaQTCFBL = 0, + TRTG = "Placebo", + TAFD = "1 HR" + ), + cmaxes = c(100, 200, 300) + ) + + expect_true( + expo_pred$conc |> length() == expo_pred$conc |> unique() |> length() + ) +}) From 2ee537ea06ba255fcf324d6e3573edb8c52b5258 Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Fri, 22 Aug 2025 15:43:21 -0400 Subject: [PATCH 2/3] remove IIV for test --- tests/testthat/test-compute_exposure_predictions.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-compute_exposure_predictions.R b/tests/testthat/test-compute_exposure_predictions.R index eeff853..04d86a9 100644 --- a/tests/testthat/test-compute_exposure_predictions.R +++ b/tests/testthat/test-compute_exposure_predictions.R @@ -45,7 +45,7 @@ test_that('compute_exposure_predictions does not add non-unique conc values with TRTG, TAFD, method = "ML", - remove_conc_iiv = FALSE + remove_conc_iiv = TRUE ) expo_pred <- compute_exposure_predictions( From b04ebe0362f2739772606894b3f8faa312a7eba9 Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Fri, 22 Aug 2025 15:49:12 -0400 Subject: [PATCH 3/3] added unique call for updating conc with cmaxes values. --- R/compute.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/compute.R b/R/compute.R index 241fe1c..70074fe 100644 --- a/R/compute.R +++ b/R/compute.R @@ -1385,7 +1385,7 @@ compute_exposure_predictions <- function( if (!rlang::is_empty(cmaxes)) { new_conc <- c(prediction_df$conc, cmaxes) - prediction_df <- tibble::tibble(conc = sort(new_conc)) + prediction_df <- tibble::tibble(conc = sort(unique(new_conc))) } ########## SHOULD THIS BE ITS OWN FUNCTION? ############