Skip to content

Commit 3b72ee4

Browse files
authored
Merge pull request #474 from Gero1999/473-fe_not_calculated_without_ae
Fix: fe and clr not calculated if ae not included in intervals (#473)
2 parents aac6a30 + eaeef7c commit 3b72ee4

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ the dosing including dose amount and route.
1414

1515
* `get_halflife_points()` now correctly accounts for start time != 0 and sets
1616
times outside of any interval to `NA` (#470)
17+
* `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)
1718

1819
## New features
1920

R/pk.calc.urine.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ add.interval.col("clr.last",
7878
unit_type="renal_clearance",
7979
pretty_name="Renal clearance (from AUClast)",
8080
formalsmap=list(auc="auclast"),
81+
depends = c("ae", "auclast"),
8182
desc="The renal clearance calculated using AUClast")
8283
PKNCA.set.summary(
8384
name="clr.last",
@@ -91,6 +92,7 @@ add.interval.col("clr.obs",
9192
unit_type="renal_clearance",
9293
pretty_name="Renal clearance (from AUCinf,obs)",
9394
formalsmap=list(auc="aucinf.obs"),
95+
depends = c("ae", "aucinf.obs"),
9496
desc="The renal clearance calculated using AUCinf,obs")
9597
PKNCA.set.summary(
9698
name="clr.obs",
@@ -104,6 +106,7 @@ add.interval.col("clr.pred",
104106
unit_type="renal_clearance",
105107
pretty_name="Renal clearance (from AUCinf,pred)",
106108
formalsmap=list(auc="aucinf.pred"),
109+
depends = c("ae", "aucinf.pred"),
107110
desc="The renal clearance calculated using AUCinf,pred")
108111
PKNCA.set.summary(
109112
name="clr.pred",
@@ -131,6 +134,7 @@ add.interval.col("fe",
131134
unit_type="amount_dose",
132135
pretty_name="Fraction excreted",
133136
values=c(FALSE, TRUE),
137+
depends = "ae",
134138
desc="The fraction of the dose excreted")
135139
PKNCA.set.summary(
136140
name="fe",

tests/testthat/test-pk.calc.all.R

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,38 @@ test_that("do not give rbind error when interval columns have attributes (#381)"
757757
)
758758
})
759759

760+
761+
test_that("pk.nca can be run for each parameter independently (#473)", {
762+
763+
d_conc <- Theoph[Theoph$Subject %in% "1", ]
764+
d_conc <- rbind(d_conc, mutate(d_conc, Time = Time + 25))
765+
d_conc$volume <- 1
766+
d_conc$duration <- 1
767+
d_dose <- data.frame(Subject = "1", Time = c(0, 25), Dose = 5, duration = 1)
768+
769+
o_conc <- PKNCAconc(d_conc, formula = conc~Time|Subject, volume = "volume", duration = "duration")
770+
o_dose <- PKNCAdose(d_dose, formula = Dose~Time|Subject, route = "intravascular", duration = "duration")
771+
772+
non_pknca_covered_params <- c(
773+
"f", "time_above", "mrt.md.obs", "mrt.md.pred", "sparse_auclast", "sparse_auc_se", "sparse_auc_df",
774+
"vss.md.obs", "vss.md.pred", "ceoi"
775+
)
776+
all_params <- setdiff(names(get.interval.cols()), c("start", "end", non_pknca_covered_params))
777+
intervals <- data.frame(start = c(0, 25), end = c(25, Inf))
778+
779+
for (param in all_params){
780+
intervals_with_param <- intervals
781+
intervals_with_param[[param]] <- TRUE
782+
o_data <- PKNCAdata(o_conc, o_dose, intervals = intervals_with_param)
783+
784+
expect_no_error(param_res <- pk.nca(o_data))
785+
expect_false(
786+
all(is.na(param_res$result$PPORRES)),
787+
info = paste0("Parameter ", param, " can be calculated independently")
788+
)
789+
}
790+
})
791+
760792
test_that("Cannot include and exclude half-life points at the same time (#406)", {
761793
o_conc <- PKNCAconc(data = data.frame(conc = 1, time = 0, inex = TRUE), conc~time, include_half.life = "inex", exclude_half.life = "inex")
762794
d_interval <- data.frame(start = 0, end = Inf, half.life = TRUE)

0 commit comments

Comments
 (0)