Catalyst.jl icon indicating copy to clipboard operation
Catalyst.jl copied to clipboard

Volumes in `ReactionSystem`

Open paulflang opened this issue 4 years ago • 8 comments

Is there a way we can store volumes in ReactionSystem (i.e. every species is associated with a volume/compartment it resides in)? This would allow us to optionally divide any simulation result by the volume, in case users are more interested in concentrations than absolute quantities.

paulflang avatar Jul 19 '21 15:07 paulflang

Oh sorry, I thought #312 was closed and wanted to start a cleaner discussion here. But it isn't so this and #312 are kind of duplicates.

paulflang avatar Jul 19 '21 15:07 paulflang

I thought the resolution of the other issue is that this is better handled in SBML through generating rate constants within the ReactionSystem that are scaled appropriately by the volumes to have the desired units?

How do you want the volumes to be handled internally? (i.e. are you looking for a specific assumed choice of units in each model, which I'd prefer to avoid, or for general units to be supported and volumes automatically handled in some way?)

isaacsas avatar Jul 28 '21 18:07 isaacsas

At the moment SBMLToolkit converts everything that is not already an absolute quantity to an absolute quantity. So in the resulting ReactionSystem contains species in absolute quantities and rate_rules of dimension 1/time.

There is not yet a notion of units SBMLToolkit atm (states are absolute quantities in arbitrary units, and time also is in arbitrary units), but @giordano is starting to implement them in SBML.jl. Perhaps he can comment on them.

paulflang avatar Jul 28 '21 22:07 paulflang

So are you just looking for a place to store information like symbols for (compartment,volume)?

isaacsas avatar Jul 28 '21 23:07 isaacsas

With https://github.com/LCSB-BioCore/SBML.jl/pull/109 we've got basic support for units: units defined in an SBML file are translated to Unitful.jl units

giordano avatar Jul 28 '21 23:07 giordano

@isaacsas : Yes. Just to divide the solution for a species by the volume it resides in in case the user is more interested in concentrations than absolute numbers.

paulflang avatar Jul 28 '21 23:07 paulflang

The concentration equations can just be included as observed variables, if we can come up with a good naming scheme for them. Then the user could just index them and get the solutions in the other variables, and that would all work in through a standard system.

ChrisRackauckas avatar Jul 28 '21 23:07 ChrisRackauckas

We could use the variable [A](t) built as follows

CAsym = Symbol("[","A","]")
Aconcen = (@variables t, $CASym(t))[1]

I just checked and this works fine in plotting an ODE solution, giving [A](t) in the legend, and also works to index into a solution object. We'd probably want to make a function to generate the variable for a user given A(t), brackets(A) or concen(A) or such.

One issue with having a distinct volume field within ReactionSystems is that in a compartmental model there might be different volumes for different compartments (which will all end up in a single flattened system eventually). This seems hard for us to reason about at the ReactionSystem level, unless we make a rule like each ReactionSystem in a user-built model corresponds to only one volume except when flattened (so we can identify the appropriate volume variable for each species via namespacing or such). Alternatively, I guess we could use metadata to tag species with compartments in some way, or we add a field that maps each species in a ReactionSystem to a compartment that users would have to initialize.

isaacsas avatar Oct 14 '21 19:10 isaacsas