From f477b083dca630dcc39a368795c8951b3a1f6019 Mon Sep 17 00:00:00 2001 From: Gero1999 Date: Mon, 27 Oct 2025 08:53:57 +0100 Subject: [PATCH 1/7] add depends "ae" for "fe" --- R/pk.calc.urine.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/pk.calc.urine.R b/R/pk.calc.urine.R index 3dcf2310..746e6f12 100644 --- a/R/pk.calc.urine.R +++ b/R/pk.calc.urine.R @@ -126,6 +126,7 @@ add.interval.col("fe", unit_type="amount_dose", pretty_name="Fraction excreted", values=c(FALSE, TRUE), + depends = "ae", desc="The fraction of the dose excreted") PKNCA.set.summary( name="fe", From 97010d4ec7a0009ad3d1d541951c659932a182dd Mon Sep 17 00:00:00 2001 From: Gero1999 Date: Mon, 27 Oct 2025 08:56:09 +0100 Subject: [PATCH 2/7] news: communicate bug fix --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 2da1b658..d8aa687b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,6 +10,7 @@ the dosing including dose amount and route. * `get_halflife_points()` now correctly accounts for start time != 0 and sets times outside of any interval to `NA` (#470) +* `pk.nca` will calculate `fe` even if `ae` was not requested to be calculated in the intervals (#473) ## New features From 364b34c2d1eff989163f678f69fb69523cc26572 Mon Sep 17 00:00:00 2001 From: Gero1999 Date: Fri, 7 Nov 2025 18:05:17 +0100 Subject: [PATCH 3/7] draft: test to check all parameters with pk.nca indepedently --- tests/testthat/test-pk.calc.all.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/testthat/test-pk.calc.all.R b/tests/testthat/test-pk.calc.all.R index 6ce369d2..f63af8aa 100644 --- a/tests/testthat/test-pk.calc.all.R +++ b/tests/testthat/test-pk.calc.all.R @@ -758,3 +758,16 @@ test_that("do not give rbind error when interval columns have attributes (#381)" list(label = "start") ) }) + +test_that("pk.nca can be run for each parameter independently", { + all_params <- setdiff(names(get.interval.cols()), c("start", "end")) + d_conc <- Theoph + d_conc$volume <- 1 + o_conc <- PKNCAconc(d_conc, formula = conc~Time|Subject, volume = "volume") + + for (param in all_params){ + expect_no_error( + + ) + } +}) From 220998cf68b1e63db43ed329dff9d6a316f5ddc8 Mon Sep 17 00:00:00 2001 From: Gero1999 Date: Tue, 11 Nov 2025 06:46:34 +0100 Subject: [PATCH 4/7] add depends for clr calculations --- R/pk.calc.urine.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/pk.calc.urine.R b/R/pk.calc.urine.R index 746e6f12..74232399 100644 --- a/R/pk.calc.urine.R +++ b/R/pk.calc.urine.R @@ -73,6 +73,7 @@ add.interval.col("clr.last", unit_type="renal_clearance", pretty_name="Renal clearance (from AUClast)", formalsmap=list(auc="auclast"), + depends = c("ae", "auclast"), desc="The renal clearance calculated using AUClast") PKNCA.set.summary( name="clr.last", @@ -86,6 +87,7 @@ add.interval.col("clr.obs", unit_type="renal_clearance", pretty_name="Renal clearance (from AUCinf,obs)", formalsmap=list(auc="aucinf.obs"), + depends = c("ae", "aucinf.obs"), desc="The renal clearance calculated using AUCinf,obs") PKNCA.set.summary( name="clr.obs", @@ -99,6 +101,7 @@ add.interval.col("clr.pred", unit_type="renal_clearance", pretty_name="Renal clearance (from AUCinf,pred)", formalsmap=list(auc="aucinf.pred"), + depends = c("ae", "aucinf.pred"), desc="The renal clearance calculated using AUCinf,pred") PKNCA.set.summary( name="clr.pred", From 7403a204ae267f5ab4135842cc577750ac380294 Mon Sep 17 00:00:00 2001 From: Gero1999 Date: Tue, 11 Nov 2025 06:47:44 +0100 Subject: [PATCH 5/7] test: running each parameter independently in pk.nca --- tests/testthat/test-pk.calc.all.R | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-pk.calc.all.R b/tests/testthat/test-pk.calc.all.R index f63af8aa..0bb334e6 100644 --- a/tests/testthat/test-pk.calc.all.R +++ b/tests/testthat/test-pk.calc.all.R @@ -760,14 +760,32 @@ test_that("do not give rbind error when interval columns have attributes (#381)" }) test_that("pk.nca can be run for each parameter independently", { - all_params <- setdiff(names(get.interval.cols()), c("start", "end")) - d_conc <- Theoph + + d_conc <- Theoph[Theoph$Subject %in% "1", ] + d_conc <- rbind(d_conc, mutate(d_conc, Time = Time + 25)) d_conc$volume <- 1 - o_conc <- PKNCAconc(d_conc, formula = conc~Time|Subject, volume = "volume") + d_conc$duration <- 1 + d_dose <- data.frame(Subject = "1", Time = c(0, 25), Dose = 5, duration = 1) + + o_conc <- PKNCAconc(d_conc, formula = conc~Time|Subject, volume = "volume", duration = "duration") + o_dose <- PKNCAdose(d_dose, formula = Dose~Time|Subject, route = "intravascular", duration = "duration") + + non_pknca_covered_params <- c( + "f", "time_above", "mrt.md.obs", "mrt.md.pred", "sparse_auclast", "sparse_auc_se", "sparse_auc_df", + "vss.md.obs", "vss.md.pred", "ceoi" + ) + all_params <- setdiff(names(get.interval.cols()), c("start", "end", non_pknca_covered_params)) + intervals <- data.frame(start = c(0, 25), end = c(25, Inf)) for (param in all_params){ - expect_no_error( - + intervals_with_param <- intervals + intervals_with_param[[param]] <- TRUE + o_data <- PKNCAdata(o_conc, o_dose, intervals = intervals_with_param) + + expect_no_error(param_res <- pk.nca(o_data)) + expect_false( + all(is.na(param_res$result$PPORRES)), + info = paste0("Parameter ", param, " can be calculated independently") ) } }) From 043468d29542fe535bee4007c3815f8b6aeacc29 Mon Sep 17 00:00:00 2001 From: Gero1999 Date: Tue, 11 Nov 2025 06:55:59 +0100 Subject: [PATCH 6/7] fix: typpo end of test added --- tests/testthat/test-pk.calc.all.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test-pk.calc.all.R b/tests/testthat/test-pk.calc.all.R index 644d8ff7..da9d1939 100644 --- a/tests/testthat/test-pk.calc.all.R +++ b/tests/testthat/test-pk.calc.all.R @@ -787,6 +787,7 @@ test_that("pk.nca can be run for each parameter independently (#473)", { info = paste0("Parameter ", param, " can be calculated independently") ) } +}) test_that("Cannot include and exclude half-life points at the same time (#406)", { o_conc <- PKNCAconc(data = data.frame(conc = 1, time = 0, inex = TRUE), conc~time, include_half.life = "inex", exclude_half.life = "inex") From eaeef7c030907ef1f49134cefdfcc858f2476b19 Mon Sep 17 00:00:00 2001 From: Gero1999 Date: Tue, 11 Nov 2025 07:06:55 +0100 Subject: [PATCH 7/7] news: include also clr --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 246f28ec..6cb30d2d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,7 +14,7 @@ the dosing including dose amount and route. * `get_halflife_points()` now correctly accounts for start time != 0 and sets times outside of any interval to `NA` (#470) -* `pk.nca` will calculate `fe` even if `ae` was not requested to be calculated in the intervals (#473) +* `pk.nca` will calculate `fe` and `clr` even if their dependant parameters (e.g, `ae`) were not requested to be calculated in the intervals (#473) ## New features