R/genShinyApp.template.R
genShinyApp.template.Rd
Create a complete shiny application for exploring dosing regimens given a (hardcoded) PK/PD model.
genShinyApp.template(
appDir = "shinyExample",
verbose = TRUE,
ODE.config = list(ode = "model", params = c(KA = 0.294), inits = c(eff = 1), method =
"lsoda", atol = 1e-08, rtol = 1e-06)
)
write.template.server(appDir)
write.template.ui(appDir, statevars)
appDir | a string with a directory where to store the shiny
app, by default is |
---|---|
verbose | logical specifying whether to write messages as the
shiny app is generated. Defaults to |
ODE.config | model name compiled and list of parameters sent to |
statevars | List of statevars passed to to the A PK/PD model is defined using The function evaluates the following PK/PD model by default:
This can be changed by the To launch the shiny app, simply issue the |
None, these functions are used for their side effects.
These functions create a simple, but working example of a
dosing regimen simulation web application. Users may want to
modify the code to experiment creating shiny applications for
their specific RxODE
models.
RxODE()
,eventTable()
, and the package shiny (https://shiny.rstudio.com).
# \donttest{
# create the shiny app example (template)
genShinyApp.template(appDir = "myapp")
#>
#> Generating an example (template) for a dosing regimen shiny app
#>
#> Using the following PK/PD model:
#> C2 = centr/V2;
#> C3 = peri/V3;
#> d/dt(depot) =-KA*depot;
#> d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3;
#> d/dt(peri) = Q*C2 - Q*C3;
#> d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff;
#>
#> Translating the PK/PD ODE model into C, compiling, etc.
#>
#>
#>
#> Parameters and their values:
#> KA CL V2 Q V3 Kin Kout EC50
#> 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000
#>
#> Initial values in each compartment:
#> depot centr pari eff
#> 0 0 0 1
#>
#> Warning: 2 arguments not used by format '
#> #
#> # Dosing regimen template generated by RxODE::genShinyApp.template()
#> #
#>
#> debug = TRUE
#> #wd = sprintf("%%s/../", getwd())
#> #setwd(wd)
#>
#> # Server inputs: Dose, dosing regimen, dosing frequency,
#> # dosing cycle definition, number of dosing cycles
#>
#> library(shiny)
#> library(RxODE)
#>
#> # read objects from "rx_shiny_data.rda" in the AppDir folder,
#> # objects include, mod1, params, inits, method, atol, rtol.]
#>
#> load("./rx_shiny_data.rda")
#> if (!rxDynLoad(mod1)) mod1 <- RxODE(mod1, modName="mod1")
#> # Define server logic
#> shinyServer(function(input, output) {
#>
#> get.cp <- reactive({
#> ds <- input$Dose
#> reg <- switch(input$regimen, "QD"=1, "BID"=2)
#> cyc <- switch(input$cycle,
#> "continous"=c(7,0),
#> "1wkon 1wkoff"=c(7,7),
#> "2wkon 1wkoff"=c(14,7),
#> "3wkon 1wkoff"=c(21,7)
#> )
#> cyc <- re [... truncated]
#> Shiny files (ui.R, server.R) plus R data saved.
#>
#> To launch the Shiny app, type the following two R commands:
#>
#> library(shiny)
#> runApp("myapp")
#>
# run the shiny app
library(shiny)
# runApp("myapp") # Won't launch in environments without browsers
unlink("myapp", recursive = TRUE, force = TRUE) # remove myapp
# }