User:James Chappell /R RK4 Modeling: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
mNo edit summary
mNo edit summary
Line 22: Line 22:
'''Example 1 : Simple Constitutive Expression'''
'''Example 1 : Simple Constitutive Expression'''


constitutiveexpression <- function(t, x, parms) {
(constitutiveexpression <- function(t, x, parms) {


Define the name of the model
#Define the name of the model


mRNA <- x[1]  
mRNA <- x[1]  
Line 30: Line 30:
protein <- x[2]  
protein <- x[2]  


Name the response variables – these are the outputs of our model  
#Name the response variables – these are the outputs of our model  


with(as.list(parms),{
with(as.list(parms),{
Line 44: Line 44:
})}
})}


Combine these vectors into a list called res
#Combine these vectors into a list called res


times <-seq(0, 1000, length=1001)
times <-seq(0, 1000, length=1001)
Line 50: Line 50:
parms <-c(k1=0.69 , k2=f ,d1=0.23 ,d2=0.012)
parms <-c(k1=0.69 , k2=f ,d1=0.23 ,d2=0.012)


Generate a time series over which to solve the equations (1000 in steps of 1)
#Generate a time series over which to solve the equations (1000 in steps of 1)


Set the parameter values in parms
#Set the parameter values in parms


y <- xstart <-c (mRNA=1, protein=1)
y <- xstart <-c (mRNA=1, protein=1)


Set the starting value for response variables
#Set the starting value for response variables


output <- as.data.frame(rk4(xstart, times, constitutiveexpression, parms))  
output <- as.data.frame(rk4(xstart, times, constitutiveexpression, parms))  
Line 62: Line 62:
plot(output$time, output$protein, ylim=c(0,2000), ylab="protein (molecules)",xlab="time (min)",type="n")  
plot(output$time, output$protein, ylim=c(0,2000), ylab="protein (molecules)",xlab="time (min)",type="n")  
}
}




</div>
</div>

Revision as of 08:19, 8 July 2009

<html> <style type="text/css"> .firstHeading {display: none;} </style> </html>


James Chappell

Imperial College London Synthetic Biology Lab


RK4

The RK4 tool is a tool that can be used to model ordinary differential equations (ODE). Like other ODE solvers you can output the results of a simulation into graph or tables.

Example 1 : Simple Constitutive Expression

(constitutiveexpression <- function(t, x, parms) {

  1. Define the name of the model

mRNA <- x[1]

protein <- x[2]

  1. Name the response variables – these are the outputs of our model

with(as.list(parms),{

dmRNA <- k1 - d1*mRNA

dprotein <- k2*mRNA - d2*protein

res<-c(dmRNA, dprotein)

list(res)

})}

  1. Combine these vectors into a list called res

times <-seq(0, 1000, length=1001)

parms <-c(k1=0.69 , k2=f ,d1=0.23 ,d2=0.012)

  1. Generate a time series over which to solve the equations (1000 in steps of 1)
  1. Set the parameter values in parms

y <- xstart <-c (mRNA=1, protein=1)

  1. Set the starting value for response variables

output <- as.data.frame(rk4(xstart, times, constitutiveexpression, parms))

plot(output$time, output$protein, ylim=c(0,2000), ylab="protein (molecules)",xlab="time (min)",type="n") }