The amount \(A_c\) in the central compartment is solution of the ODE \(\ \ \dot{A_c}(t) = - k \, A_c(t)\)

The concentration \(C_c\) in the central compartment is defined by \(\ \ C_c(t) = A_c(t)/V\)

\(V\) and \(k\) are both log-normally distributed: \[ \begin{aligned} \log(V) & \sim {\cal N}(\log(V_{\rm pop}), \omega^2_V) \\ \log(k) & \sim {\cal N}(\log(k_{\rm pop}), \omega^2_k) \end{aligned} \]

  • Define the dosage regimen in the tab dosage: time of first dose, number of doses, interdose interval, infusion time, amount.

  • select the PK parameters in the tab parameters:
    • \(k_{\rm pop}\), the population value of the elimination rate constant \(k\),
    • \(V_{\rm pop}\), the population value of the volume \(V\),
    • \(\omega_k\), the standard deviation of \(\log(k)\),
    • \(\omega_V\), the standard deviation of \(\log(V)\).

  • define the outputs in the tab outputs :
    • select the output to display: the amount \(A_c\) or the concentration \(C_c\),
    • select the time range where the prediction is computed,
    • select the number of time points of the grid where the prediction is computed.

  • define the prediction distribution to display in the tab settings:
    • select the level of the prediction interval (between 5% and 95%),
    • select the number of bands which form this prediction interval
    • the number of simulations used for estimating this prediction distribution.

By default a 80% prediction interval decomposed in 8 bands is used. Then, the 10th, 20th, 30th, …, 70th and 90th percentiles are displayed.










[LONGITUDINAL]
input = {V, k}

PK:
depot(target=Ac)

EQUATION:
ddt_Ac = -k*Ac
Cc=Ac/V

;-----------------------
[INDIVIDUAL]
input = {V_pop, k_pop, omega_V, omega_k}

DEFINITION:
V = {distribution=lognormal, reference=V_pop, sd=omega_V}
k = {distribution=lognormal, reference=k_pop, sd=omega_k}
adm <- list(time=1, amount=40)
Cc  <- list(name='Cc',time=seq(from=0, to=20, by=1))
p   <- list(name=c('V_pop','k_pop','omega_V','omega_k'), value=c(10,0.2,0.3,0.2))
g <- list(size=1000,level='individual')
res <- simulx(model='iiv1_model.txt', parameter=p, output=Cc, treatment=adm, group=g)

band.level=80
band.nb=8

qr <- prctilemlx(res$Cc,list(band.nb,band.level))

#----------------------------------
shinyUI(fluidPage(
#      titlePanel(
#        list(HTML('<p style="color:#4C0B5F; font-size:24px" fontsize=14>
#   PK model with inter individual variability</p>' )),
#        windowTitle="PK model with IIV"),
  navbarPage("", selected="Plot", inverse="FALSE", 
             title="PK model with inter individual variability",
             tabPanel("ReadMe", withMathJax(), includeMarkdown("ReadMe.Rmd")),
             tabPanel("Plot",
                      tabsetPanel( id="tabs", type="pills",
                        tabPanel("dosage"),
                        tabPanel("parameters"),
                        tabPanel("outputs"),
                        tabPanel("settings")
             ),
             fluidRow(
               column(3,
                      br(), br(),
                      conditionalPanel(condition="input.tabs=='dosage'",
                                       sliderInput("tfd", "Time of first dose:", value=0, min=0, max = 20, step=1),
                                       sliderInput("nd", "Number of doses:", value=6, min=1, max = 10, step=1),
                                       sliderInput("ii", "Interdose interval:", value = 3, min = 0.5, max = 10, step=0.5),
                                       sliderInput("tinf", "infusion time:", value = 1, min = 0, max = 5, step=0.5),
                                       sliderInput("amt", "Amount:", value = 5, min = 0, max = 20, step=1),
                                       br()
                      ),
                      
                      conditionalPanel(condition="input.tabs=='parameters'",
                                       sliderInput("V_pop", "V_pop :", value = 10, min = 1, max = 20, step=1),
                                       sliderInput("k_pop", "k_pop :", value = 0.2, min = 0, max = 1, step=0.05),
                                       sliderInput("omega_V", "omega_V :", value = 0.3, min = 0, max = 2, step=0.1),
                                       sliderInput("omega_k", "omega_k :", value = 0.2, min = 0, max = 2, step=0.1),
                                       br()
                      ),
                      
                      conditionalPanel(condition="input.tabs=='outputs'",
                                       br(),
                                       selectInput("output","",c("concentration (Cc)" = "Cc","amount (Ac)" = "Ac")),
                                       br(),
                                       sliderInput("range", "time range", min = -5, max = 50, value = c(0,20), step=5),
                                       br(),
                                       sliderInput("ngp", "grid size", min = 11, max = 501, value = 101, step=10),
                                       br()
                      ),
                      
                      conditionalPanel(condition="input.tabs=='settings'",
                                       sliderInput("level", "level (%)", min = 5, max = 95, value = 80, step=5),
                                       sliderInput("nband", "number of bands", min = 1, max = 20, value = 8, step=1),
                                       sliderInput("nbsim", "number of simulations", min = 500, max = 5000, value = 1000, step=500),
                                       br()
                      )
               ),
               column(9,
                      plotOutput("plot1",  height="500px"))
             )),
             #     tabPanel("Legend", plotOutput("plot2")),
             tabPanel("Table", tableOutput("table")),
             navbarMenu("Codes",
                        tabPanel("Mlxtran", pre(includeText("iiv1_model.txt"))),
                        tabPanel("Simulx", pre(includeText("iiv1_simulx.R"))),
                        tabPanel("ui.R", pre(includeText("ui.R"))),
                        tabPanel("server.R", pre(includeText("server.R"))
                        )
             ))
))
source("../../initMlxR.R")

shinyServer(function(input, output) {

  r <- reactive({  
    if (input$tinf>input$ii)
      stop("The infusion time should not exceed the interdose interval")

    param.value=c(input$V_pop,input$k_pop,input$omega_V,input$omega_k)
    t.value=seq(input$range[1],input$range[2],length.out=input$ngp)
    t1=input$tfd
    t2=input$ii*(input$nd-1)+t1
    if (t2>=t1){
      t.dose=seq(t1,t2,by=input$ii)
      adm <- list(time=t.dose, amount=input$amt, rate=input$amt/input$tinf)
    }else{
      adm <- list(time=t1, amount=0)
    }

    f  <- list(name=input$output,time=t.value)
    p   <- list(name=c('V_pop','k_pop','omega_V','omega_k'), value=param.value)
    g <- list(size=input$nbsim,level='individual')
    
    res <- simulx( model     = 'iiv1_model.txt',
                   treatment = adm, 
                   group = g,
                 parameter = p,
                 output    = f)
    ro <- res[[input$output]]
  })
  
  
  output$plot1 <- renderPlot({
    withProgress(message = 'Creating plot', detail='Wait...', value = 0.1, expr={
      r=r()
        qr <- prctilemlx(r,list(level=input$level,number=input$nband))
    print(qr)
    })
  })


  output$table <- renderTable({ 
    r=r()
    rq <- prctilemlx(r,list(level=input$level,number=input$nband),plot=FALSE)
  y=rq$y
    })

  
})