Closed deepika060193 closed 1 year ago
This is a bit tricky. Maybe you can create a function to generate the simulation file (instead of creat by yourself) to change the dose in the R interface. Here is an example R function of creating a input file,
generate_infile <- function(infile.name = NULL,
rtol = 1e-6, atol = 1e-6,
outvars = c("A", "B"),
dose = 1, times = c(0.5, 1)){
if(is.null(infile.name)) infile.name <- "sim.in"
cat("#---------------------------------------- \n#",
" ", infile.name , "\n#",
" (Created by generate_infile)\n#",
"----------------------------------------", "\n\n",
file = infile.name, sep = "")
cat("Integrate (Lsodes, ", rtol, ", ", atol, " , 1);", "\n\n",
file=infile.name, append=TRUE, sep="")
cat("Dose = ", dose, ";\n\n",
file=infile.name,append = TRUE, sep="")
cat("Print (", paste(outvars, collapse = ", "), ", ",
paste(times, collapse=", "), ");\n", file = infile.name,
append=TRUE, sep = "")
cat("END.\n", file = infile.name, append = TRUE)
message(paste('* Created input file "', infile.name, '".', sep =""))
}
After that, you can use it to your shiny app.
Thank you for a fast reply. I will try this and inform you.
Have a nice day!
The code is working fine now. Thank you!
Hi, I made a pbpk model using MCSIM under R. Now I want to publish it in Rshiny directly using MCSIM_under_R rather than converting all the code from MCSIM to Rstudio and solve ode using packages like rxode etc. I tried it and see that the file is running perfectly fine but i am not understanding how i can vary the dose without entering into simulation file directly. I am sending you the rshinycode for clarification.
library(shiny)
Define UI for application
ui <- fluidPage(
Application Panel
Application title
titlePanel("PBPK Model for TDCIPP"),
Sidebar with a slider input for number of bins
sidebarLayout( sidebarPanel( h4("Dosing details"), numericInput("dosing", label='Dose', value = 10,min=0, max=100) ),
) )
Define server logic required to draw a histogram
server <- function(input, output) { output$v1 <- renderPlot({
Server logic goes here
clear()
getwd() setwd("C:/MCSim_under_R-master") source(file = "MCSim/function.R") set_PATH(PATH = "c:/Useres/Rtools/mingw_32/bin")
this is where the problem is I want the dosing to be not in the simulation file, but rather I want the simulation file to take the dose directly from here (which means R).
##############dosing=input$dosing #this dosing I want to integrate in the simulation file which is "tdcipp_2_forward_1_f1_reverse_1.in.r"
v1<- mcsim(model="tdcipp_3_non-linear_elimination_f_6_reverse.model.r", input="tdcipp_2_forward_1_f1_reverse_1.in.r",dir="modeling/rshiny/FR",parallel = "F")
v1=read.delim("tdcipp_ftest.out",skip=1)
plot(v1$Time,v1$cplasma_2, type="l")
}) }
Run the application
shinyApp(ui = ui, server = server)