diff --git a/NEWS.md b/NEWS.md index f279ffb7..6cb30d2d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +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` and `clr` even if their dependant parameters (e.g, `ae`) were not requested to be calculated in the intervals (#473) ## New features diff --git a/R/pk.calc.urine.R b/R/pk.calc.urine.R index 3dcf2310..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", @@ -126,6 +129,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", diff --git a/tests/testthat/test-pk.calc.all.R b/tests/testthat/test-pk.calc.all.R index 084e5843..da9d1939 100644 --- a/tests/testthat/test-pk.calc.all.R +++ b/tests/testthat/test-pk.calc.all.R @@ -757,6 +757,38 @@ test_that("do not give rbind error when interval columns have attributes (#381)" ) }) + +test_that("pk.nca can be run for each parameter independently (#473)", { + + d_conc <- Theoph[Theoph$Subject %in% "1", ] + d_conc <- rbind(d_conc, mutate(d_conc, Time = Time + 25)) + d_conc$volume <- 1 + 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){ + 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") + ) + } +}) + 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") d_interval <- data.frame(start = 0, end = Inf, half.life = TRUE)