billdenney / pknca

An R package is designed to perform all noncompartmental analysis (NCA) calculations for pharmacokinetic (PK) data.
http://billdenney.github.io/pknca/
GNU Affero General Public License v3.0
68 stars 23 forks source link

Unable to calculate AUC #205

Closed Ravua1992 closed 1 year ago

Ravua1992 commented 1 year ago

Hello,

I am unable to calculate the partial AUC. It is always NC. Can you kindly help how to address this ?

Thanks,

Brief description of the problem

start  end        Regimen    N       auclast        cmax        cmin                 tmax         cav   half.life    aucinf.obs
1      0  Inf 100mg/m2 (Q3W) 1000            NC 4010 [30.0] 35.5 [10.1]    1010 [1010, 1060]          NC 50.5 [6.35]            NC
2      0   24 100mg/m2 (Q3W) 1000            NC 3990 [29.9] 2190 [42.7]    4.00 [2.00, 24.0]          NC   142 [211]            NC
3      0  336 100mg/m2 (Q3W) 1000            NC 3990 [29.9] 80.8 [85.9]    4.00 [2.00, 48.0]          NC 51.6 [7.61]            NC
billdenney commented 1 year ago

Hi @Ravua1992 , there are many reasons that could be the case. The most common is missing initial concentrations. Can you please share a full reproducible example so that I can help?

Ravua1992 commented 1 year ago

It's basically for multiple dose simulation (in mrgsolve) where the drug is given every 3 weeks. I am filtering out EVID==1 for dose data and evid==0 for concentrations. Does the concentration need to start from Time=0 i.e conc=0 or Time=1 hour when concentration is >0?

Ravua1992 commented 1 year ago
sim_data<-sim2 %>% carry.out(ID,COH,evid,amt,ii,addl) %>%
    idata_set(idata)%>%
   ev(doses_1) %>% mrgsim(delta = 1, end = 12*168, hmax =0.5,maxsteps =50000,rtol =1E-05) %>% as.data.frame ()

In this example 'simdata' is the object I am importing from mrgsolve.

 conc_raw <- sim_data %>% filter(evid==0)
 conc_raw1<-conc_raw %>% filter(time %in% c(seq(0,24,1),
                                            seq(24,24*21,24),
                                            seq(24*21,24*22,1),
                                            seq(24*23,24*42,24),
                                            seq(24*42,24*43,1),
                                            seq(24*43,24*90,24)))

 conc_raw1<-conc_raw1 %>% filter(CONC_BOUND>30)
 # Load your dose data
 dose_raw <- sim_data %>% filter(evid==1)
 # Put your concentration data into a PKNCAconc object
 o_conc <- PKNCAconc(data=conc_raw1,
                     formula=CONC_BOUND~time|Regimen+ID)
 # Put your dose data into a PKNCAdose object
 o_dose <- PKNCAdose(data=dose_raw,
                     formula=amt~time|Regimen+ID)
 # Combine the two (and automatically determine the intervals of
 # interest
 #Cavg
 #2-21d Cavg
 #2-14d Cave, 
 #off window 
 #d15-d20   AUC
 #2-21d AUC
 #2-14d AUC, off window 
 #d15-d20   Cmax
 #day 2 Cmin 
 #day 21 (predose)  Cumulative AUC for 5 wk DLT period
 #~C1D2-C2D10   Cumulative AUC for 3 cycles

 intervals_manual <-
   data.frame(
     start=c(0,0,0,0,0,15*24,0,0,24*21,24*7),
     end=c(Inf,24,168*2,168*3,168*5,20*24,168*5,168*9,24*22,24*8),
     cav=TRUE,
     cmax=TRUE,
     tmax=TRUE,
     cmin=TRUE,
     half.life=TRUE, 
     aucinf.obs=(TRUE),
     auclast=c(TRUE))

 o_data <- PKNCAdata(o_conc, o_dose,intervals=intervals_manual)
 # Compute the NCA parameters
 o_results <- pk.nca(o_data)
 data_nca<-as.data.frame(o_results)
 # Summarize the results
 summary_total<-summary(o_results) %>% as.data.frame()
Ravua1992 commented 1 year ago

I think I figured it out. It's only when at T=0 and there is no concentration, we can compute the AUC. When I change the interval to T==1 where CONC>0 it works.

billdenney commented 1 year ago

@Ravua1992, I'm glad that you found the solution. I was guessing that was the issue. FYI, you can have PKNCA impute the time 0 concentrations for you using an imputation function as described here: http://billdenney.github.io/pknca/articles/v08-data-imputation.html (And, if that vignette isn't clear, please let me know so that I can improve it.)

Also, I don't recall how mrgsolve outputs the concentrations at a given time. But, you may also solve the issue by keeping EVID != 0 or doing something like dropping the EVID column and running unique() on your input data.frame. Those may keep the TIME == 0 rows that were dropped.