In the model below (built in R), I want to include 20% population variability on the parameter Rec_den_WT
and v
and then run Monte Carlo simulations for 100 individuals. So, I want to have a log-normal distribution of these parameters with standard deviation= 20%. In each simulation, the model picks up a random number from these distributions for each individual and run the simulation to give output Per_RO_WT
for each individual. Also then it plots the output for each individual. Can anyone guide how that may be done, if possible, while using the same code file. .
library(ggplot2)
library(deSolve)
v = 0.001
kon_WT = 1e-4
koff_WT = 1e-3
Rec_den_WT = 10367
Total_cells = 10000
R_WT = Rec_den_WT*Total_cells
Complex <- function (t,y,parms){
with(as.list(y,parms), {
dC_WT <- koff_WT*RL_WT -kon_WT*R_WT*C_WT
dRL_WT <- kon_WT*R_WT*C_WT - koff_WT*RL_WT #nM
dR_WT <- koff_WT*RL_WT -kon_WT*R_WT*C_WT
return(list(c(dC_WT, dRL_WT, dR_WT)))
})
}
## plotting for different initial values of C
resC_WT <- function(iC_WT) {
times <- seq(0,10000,100)
Out <- ode(y = c(C_WT = iC_WT, RL_WT = 0, R_WT= R_WT), times = times, func=Complex, parms=NULL)
Output <- data.frame(Out)
#return(Output)
return(Output[nrow(Output), ])
}
vectorC_WT <- c(0.001,0.01,0.1,0.2,0.5,1,2,5,10,50,100,200,500,1000,1500,2000,3000,5000,10000,20000,50000) #nM
table<- sapply(vectorC_WT, FUN=resC_WT); table
table <- as.data.frame(t(table)) ; table
Per_RO_WT <- as.numeric(table$RL_WT)/R_WT;
table <- cbind(table,vectorC_WT,Per_RO_WT);table