#----- Dosing regimen ------------------------------
adm <- list(time=seq(0, 45, by= 9), amount=1)
#----- Parameter values ----------------------------
psi <- list( name = c('K','KDE','KPQ','KQPP','LAMBDAP','GAMMA','DELTAQP'),
value = c(100, 0.3, 0.025, 0.004, 0.12, 1, 0.01))
#----- Predicted tumor size ------------------------
of <- list(name='PSTAR', time=seq(-50,100,by=1))
res <- simulx(model="tgi_model.txt",parameter=psi,output=of,treatment=adm)
#----- Plot the predicted tumor size --
plot1=ggplot() + geom_line(data=res$PSTAR, aes(x=time, y=PSTAR))
print(plot1)
shinyUI(fluidPage(
titlePanel("tumor growth inhibition model",windowTitle="tumor growth"),
fluidRow(
column(2, offset=1,
h5("dosage regimen 1"),
sliderInput("nd1", "Number of doses:", value=6, min=0, max = 20, step=1),
sliderInput("ii1", "Interdose interval:", value = 12, min = 1, max = 20, step=1),
sliderInput("amt1", "Amount:", value = 1, min = 0, max = 5, step=0.25)
),
column(2,
h5("dosage regimen 2"),
sliderInput("nd2", "Number of doses:", value=6, min=0, max = 20, step=1),
sliderInput("ii2", "Interdose interval:", value = 4, min = 1, max = 20, step=1),
sliderInput("amt2", "Amount:", value = 1, min = 0, max = 5, step=0.25)
),
column(2, offset=1,
h5("parameters"),
sliderInput("GAMMA", "GAMMA:", value = 1, min = 0, max = 4, step=0.1),
sliderInput("K", "K:", value = 100, min = 0, max = 200, step=5),
sliderInput("KDE", "KDE:", value = 0.3, min = 0, max = 1, step=0.05)
),
column(2,
br(),
sliderInput("LAMBDAP", "LAMBDAP:", value = 0.12, min = 0, max = 0.5, step=0.025) ,
sliderInput("DELTAQP", "DELTAQP:", value = 0.01, min = 0, max = 0.05, step=0.0025),
sliderInput("KPQ", "KPQ:", value = 0.025, min = 0, max = 0.1, step=0.005),
sliderInput("KQPP", "KQPP:", value = 0.004, min = 0, max = 0.01, step=0.0005)
)
),
tabsetPanel(
tabPanel("Plot",
fluidRow(
column(10, plotOutput("plot")),
column(2,
checkboxGroupInput("checkGroup", label = h4("id"),
choices = list("1" = 1, "2" = 2),
selected = c(1,2)),
sliderInput("range", "time range", min = -100, max = 500, value = c(-50,200), step=10),
sliderInput("ngp", "grid size", min = 10, max = 1000, value = 200, step=10),
sliderInput("lsize", "line size", min = 0, max = 3, value = 0.75, step=0.25)
)
)),
tabPanel("Table", tableOutput("table")),
tabPanel("Mlxtran", pre(includeText("tgi_model.txt"))),
tabPanel("Simulx", pre(includeText("tgi_compute.R"))),
tabPanel("ui.R", pre(includeText("ui.R"))),
tabPanel("server.R", pre(includeText("server.R")))
)
))
my.dir=getwd()
source("../initMlxR.R")
setwd(my.dir)
shinyServer(function(input, output) {
r <- reactive({
param.value=c(input$K,input$KDE,input$KPQ,input$KQPP,input$LAMBDAP,input$GAMMA,input$DELTAQP)
t.value=seq(input$range[1],input$range[2],length.out=input$ngp)
t11=0
t12=input$ii1*(input$nd1-1)+t11
if (t12>=t11){
t1.dose=seq(t11,t12,by=input$ii1)
adm1 <- list(time=t1.dose, amount=input$amt1)
}else{
adm1 <- list(time=t11, amount=0, type=1)
}
t21=0
t22=input$ii2*(input$nd2-1)+t21
if (t22>=t21){
t2.dose=seq(t21,t22,by=input$ii2)
adm2 <- list(time=t2.dose, amount=input$amt2)
}else{
adm2 <- list(time=t21, amount=0, type=2)
}
g <- list(list(treatment=adm1),list(treatment=adm2))
f <- list(name='PSTAR',time=t.value)
p <- list(name=c('K','KDE','KPQ','KQPP','LAMBDAP','GAMMA','DELTAQP'), value=param.value)
res <- simulx( model = 'tgi_model.txt',
group = g,
parameter = p,
output = f)
res$PSTAR
})
output$plot <- renderPlot({
palette=c("#000000", "#CC79A7")
id <- as.numeric(input$checkGroup)
if (length(id>0)){
palette <- palette[id]
r=r()
r=r[(r$id %in% id),]
# palette[as.numeric(input$checkGroup)]="#FFFFFF"
pl=ggplot(data=r, aes(x=time, y=PSTAR, colour=id)) + geom_line(size=1) +
scale_colour_manual(values=palette)
print(pl)
}
})
output$table <- renderTable({ r() })
})