-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Hi!
I'm following up on a discussion from slim-discuss on solving ODEs in SLiM (https://groups.google.com/g/slim-discuss/c/9KrBreuMW6A). My use case is for evolving gene regulatory networks in SLiM (see https://doi.org/10.1371/journal.pgen.1011289), but I imagine that an ODE solver would be helpful for a variety of use cases. I'm happy to contribute towards this if you can include the appropriate GSL code.
There is a problem I foresee that might throw a spanner in the works: ODE solvers solve functions defined at compile-time. One option might be to allow for only particular "forms" of ODE and have the Eidos API dynamically construct the ODE in the solver function itself. This would be quite limited though, and only allow for certain types of ODE to be modelled (e.g. you could use this approach to model gene networks by constructing combinations of Hill functions based on an input adjacency matrix and a vector of parameters, but you are making strong assumptions about how each node interacts with each other in that case). There is also the overhead of constructing the ODE every iteration of the solver, but that might not be too much of a problem (apart from being ugly).
I think the more flexible approach is to code-generate based on a user-defined ODE and runtime compile it. There will likely be problems around cross-platform support, but I think it might still be worth the headache considering the limitations of the other approach. Further, this functionality might be useful for #431 and/or #581 in the future. Happy to hear any other ideas though!
Another question is what sort of syntax do we want for defining the ODE? An intuitive choice might be to define an ODE function in Eidos script. However, a very helpful alternative to include would also be SBML parsing (https://sbml.org/documents/what-is-sbml/). SBML is used in systems biology for storing data on biological networks (e.g. reactants, species, concentrations, kinetic equations/ODEs). It would be very convenient to load a SBML document into SLiM and have it construct an ODE on the fly without needing to predefine it in Eidos script. Another library which parses SBML is roadrunner (this was the frontrunner for me to include in my fork if I had to do it that way).
Regarding evolving the network, there are other considerations. In my model/approach, I treat the coefficients/parameters of the ODE as quantitative traits and solve the ODE for each individual based on their parameter values. Then I apply selection to some measurement of the ODE solution (e.g. in the paper above, the total expression/the AUC). But there are many different measurements you could take - e.g. the time it takes to reach an equilibrium, whether it oscillates or not, maximum expression, etc. So I think the Eidos API should return a dataframe of time points and solution values, so that users can do with that data what they wish in Eidos for flexibility.
I also haven't modelled gene duplications or deletions, which would add or remove nodes from the network and adjust the ODEs. If we go for the code-generation route, that sort of behaviour would be possible.
Anyway, I think that we need to think carefully about this - seems like it isn't a trivial add, but I think it would be quite useful. Keen to hear your thoughts.
Cheers,
Nick