[R] Creating symbolic expressions in R

Erin shellman at umich.edu
Fri Jul 16 20:57:11 CEST 2010


Hello,

I'm trying to do some differential equation modeling in R using the
package 'deSolve.'  Briefly, I'm trying to use the law of mass action
(the details of which aren't really important) to structure a vector
of rate equation which will be passed into an ODE function and solved
with associated functions from 'deSolve.'  Roughly what this entails
is scanning through a very large stoichiometric matrix containing
integers which map metabolites to reactions and then assembling a
series of monomials that describe the rates of the reactions.  I'm
running into trouble because R does not like doing numerical
operations on characters, but I need the rate to be in symbolic form.
Below I've described an example.

The input is a matrix like this one, but a lot bigger:

          rxn1 rxn2 rxn3
met1   -2       0       2
met2   -1      -1       0
met3    0       -1     -1

and the goal is to generate a vector of monomials representing the
rate of each reaction 1 - 3:

rateRxn1 = (met1)^2 * (met2)^1
rateRxn2 = (met2)^1 * (met3)^1
rateRxn3 = (met3)^1

The rates need to be represented symbolically for me to pass into the
ODE solver where the metabolites will be assigned starting values.  I
tried using the functions "quote" and "substitute" but unfortunately
they are tough to use within a loop because if I pass in a metabolite
label generated from a loop (e.g. metaboliteNames[i]) it's taken
verbatim in "quote()," so I get "metaboliteNames[i]^-stoich[i, j]"
instead of "met1^2."

My goal is to make a package of functions for modeling and simulation
of chemical kinetics and I want to make sure that they are open-source
and freely available to all researchers, so any advice on how to
proceed would be greatly appreciated!

Erin

-- 
Erin Rachael Shellman
The University of Michigan
Bioinformatics PhD Candidate
http://www.erinshellman.com
shellman at umich.edu
(937) 321.1129



More information about the R-help mailing list