New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple dose AUC with actual times #140
Comments
I have converted your code into a reprex and added the option to show all warnings to help clarify my responses below: library(PKNCA)
library(tidyverse, quietly=TRUE)
#> Warning: package 'tibble' was built under R version 4.0.4
options(warn=1)
e.dat <-
data.frame(
conc=c(0.5,2,5,9.2,12,2,1.85,1.08,0.5,0.3,2.4,4.5,10.2,15,2.6,1.65,1.1,
0.5,2,5,9.2,12,2,1.85,1.08,NA,0.3,2.4,4.5,10.2,15,2.6,1.65,1.1),
time=c(seq(264.2,312.2,3),seq(264,312,3)),
ARM=rep(c(rep(1,8),rep(2,9)),2),
SUBJ=c(rep(1,17),rep(2,17)),
Dose=c(rep(5,17)),rep(5,17)
)
## Generate the dosing data
d_dose <- e.dat %>% distinct(SUBJ,Dose,ARM) %>% mutate(time=rep(c(264,288),2))
# d_dose$Time <- 0
conc_obj <-
PKNCAconc(
e.dat,
conc~time|SUBJ + ARM
)
dose_obj <-
PKNCAdose(
d_dose,
Dose~time|SUBJ + ARM
)
## Calculate the NCA parameters
intervals_manual <- data.frame(start = c(264, 288),
end = c(288, 312),
auclast=c(TRUE,TRUE),
aucall=c(TRUE,TRUE),
tlast=c(TRUE,TRUE))
data_obj <- PKNCAdata(conc_obj, dose_obj, intervals=intervals_manual)
results_obj <- pk.nca(data_obj)
#> Warning in pk.calc.auxc(conc = conc, time = time, ..., options = options, :
#> Requesting an AUC range starting (0) before the first measurement (0.2) is not
#> allowed
#> Warning in pk.calc.auxc(conc = conc, time = time, ..., options = options, :
#> Requesting an AUC range starting (0) before the first measurement (0.2) is not
#> allowed
#> Warning in FUN(X[[i]], ...): Error with interval SUBJ=1, ARM=1, start=288,
#> end=312: No data for interval
#> Warning in FUN(X[[i]], ...): Error with interval SUBJ=1, ARM=2, start=264,
#> end=288: No data for interval
#> Warning in pk.calc.auxc(conc = conc, time = time, ..., options = options, :
#> Requesting an AUC range starting (0) before the first measurement (0.2) is not
#> allowed
#> Warning in pk.calc.auxc(conc = conc, time = time, ..., options = options, :
#> Requesting an AUC range starting (0) before the first measurement (0.2) is not
#> allowed
#> Warning in FUN(X[[i]], ...): Error with interval SUBJ=2, ARM=1, start=288,
#> end=312: No data for interval
#> Warning in check.conc.time(conc, time): All concentration data is missing
#> Warning in check.conc.time(conc, time): All concentration data is missing
#> Warning in check.conc.time(conc, time): All concentration data is missing
#> Warning in pk.calc.auxc(conc = conc, time = time, ..., options = options, :
#> Requesting an AUC range starting (0) before the first measurement (3) is not
#> allowed
#> Warning in pk.calc.auxc(conc = conc, time = time, ..., options = options, :
#> Requesting an AUC range starting (0) before the first measurement (3) is not
#> allowed
as.data.frame(results_obj, out.format = "wide")
#> start end SUBJ ARM exclude aucall auclast tlast
#> 1 264 288 1 1 <NA> NA NA 21.2
#> 2 264 288 2 1 <NA> 94.15728 94.15728 21.0
#> 3 264 288 2 2 <NA> NA NA NA
#> 4 288 312 1 2 <NA> NA NA 21.2
#> 5 288 312 2 2 <NA> NA NA 24.0 Created on 2021-03-17 by the reprex package (v1.0.0) |
PKNCA does not impute before the beginning of the interval. That is (currently) a required data management step before putting your data into One challenge with the way your data are setup is that the With that assumption, I would setup your grouping to only have the The next question is about how to individualize the intervals. You can add any group to an interval specification, and the interval will only apply to that group. So, in the code below, I have made the start and end times subject-specific by adding a In the example below, the only missing result is due to the missing value at time 288 for library(PKNCA)
library(tidyverse, quietly=TRUE)
#> Warning: package 'tibble' was built under R version 4.0.4
options(warn=1)
e.dat <-
data.frame(
conc=c(0.5,2,5,9.2,12,2,1.85,1.08,0.5,0.3,2.4,4.5,10.2,15,2.6,1.65,1.1,
0.5,2,5,9.2,12,2,1.85,1.08,NA,0.3,2.4,4.5,10.2,15,2.6,1.65,1.1),
time=c(seq(264.2,312.2,3),seq(264,312,3)),
ARM=rep(c(rep(1,8),rep(2,9)),2),
SUBJ=c(rep(1,17),rep(2,17)),
Dose=c(rep(5,17)),rep(5,17)
)
## Generate the dosing data
d_dose <- e.dat %>% distinct(SUBJ,Dose,ARM) %>% mutate(time=rep(c(264,288),2))
# d_dose$Time <- 0
conc_obj <-
PKNCAconc(
e.dat,
conc~time|SUBJ
)
dose_obj <-
PKNCAdose(
d_dose,
Dose~time|SUBJ
)
## Calculate the NCA parameters
intervals_manual_first <-
e.dat %>%
group_by(SUBJ) %>%
summarize(
start=time[between(time, 264, 265)],
end=time[between(time, 288, 289)]
)
intervals_manual_second <-
e.dat %>%
group_by(SUBJ) %>%
summarize(
start=time[between(time, 288, 289)],
end=time[between(time, 312, 313)]
)
intervals_manual <-
bind_rows(intervals_manual_first, intervals_manual_second) %>%
mutate(
auclast=TRUE,
aucall=TRUE,
tlast=TRUE
)
as.data.frame(intervals_manual)
#> SUBJ start end auclast aucall tlast
#> 1 1 264.2 288.2 TRUE TRUE TRUE
#> 2 2 264.0 288.0 TRUE TRUE TRUE
#> 3 1 288.2 312.2 TRUE TRUE TRUE
#> 4 2 288.0 312.0 TRUE TRUE TRUE
# There is some other issue here where intervals are having an issue being a tibble
data_obj <- PKNCAdata(conc_obj, dose_obj, intervals=as.data.frame(intervals_manual))
results_obj <- pk.nca(data_obj)
#> Warning in pk.calc.auxc(conc = conc, time = time, ..., options = options, :
#> Requesting an AUC range starting (0) before the first measurement (3) is not
#> allowed
#> Warning in pk.calc.auxc(conc = conc, time = time, ..., options = options, :
#> Requesting an AUC range starting (0) before the first measurement (3) is not
#> allowed
as.data.frame(results_obj, out.format = "wide")
#> start end SUBJ exclude aucall auclast tlast
#> 1 264.0 288.0 2 <NA> 94.15728 94.15728 21
#> 2 264.2 288.2 1 <NA> 96.41671 96.41671 24
#> 3 288.0 312.0 2 <NA> NA NA 24
#> 4 288.2 312.2 1 <NA> 106.98769 106.98769 24 Created on 2021-03-17 by the reprex package (v1.0.0) |
Is it possible to individualize start and/or stop times with manual interval specifications. For example, if I have the following data and time is TAFD, how could I specify that for subject 1, arm 1 the first dose was administered at time=264.2 so I want AUC with start=264.2 and end =288.2. While for subject 2, arm 1 the interval I want is for 264-288? If I specify a manual interval with start=264 and end=288, I don't get an AUC for subject 1.
With the same example, you'll notice the concentration for subject 2 at time=288 is missing. If I wanted another AUC interval from 288-312 for all subjects, the AUC is not calculated for this subject. Do I have to insert records at every time specified in my manual_interval in order to get AUC?
I hope that was clear.
The text was updated successfully, but these errors were encountered: