[R] deSolve, extracting variable values from inside ode function

Jim Maas j.maas at uea.ac.uk
Tue Aug 16 11:07:28 CEST 2011


I'm just getting to grips with using ode function and have used the 
examples and vignettes to produce a small model of a one-pool, 
michaelis-menten, enzyme kinetic reaction. The rate of flux of substrate 
into pool A is constant (fluxoa) however the rate of flux out of pool A 
is controlled by the HMM equation (v = Vmax/ ( 1 + (Km / Concentration A 
))     ).  This function works fine and gives correct answers for the 
size of the pool of quantity of substrate in pool A at all times, 
however if possible I'd like to also extract the values of interim 
variables at each time t.  Could anyone give me a clue of how to include 
the value of CA at each time t, along with QA in the results?

Thanks

Jim

R code
==================
parameters <- c(vola = 17.3629, vmax = 4.7, mmk = 0.5435, fluxoa =
                 2.389)
state <- c(QA=9.437)

MM <- function(t, state, parameters) {
   with(as.list(c(state, parameters)),{
     ## concentration of substrate in pool A, quantity
     ## divided by the volume of the solvent pool
     CA <- QA/vola
     ## output of substrate from pool A
     fluxao <- vmax / (1 + (mmk/CA))
     ## rate of change of quantity of substrate
     ## in pool A
     dA <- fluxoa - fluxao
     ## return the rate of change
     list(dA)
   })
}

times <- seq(0, 100, by = 5)
library(deSolve)
out1 <- ode(y = state, times = times, func = MM, parms = parameters)
head(out1)


-- 
Dr. Jim Maas
University of East Anglia



More information about the R-help mailing list