Skip to content

Commit 8e636de

Browse files
committed
add simulation figures
1 parent 1fb33cf commit 8e636de

File tree

4 files changed

+196
-42
lines changed

4 files changed

+196
-42
lines changed

README.md

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
[![Join the chat at https://julialang.zulipchat.com #sciml-bridged](https://img.shields.io/static/v1?label=Zulip&message=chat&color=9558b2&labelColor=389826)](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
44
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://docs.sciml.ai/Catalyst/stable/)
55
[![API Stable](https://img.shields.io/badge/API-stable-blue.svg)](https://docs.sciml.ai/Catalyst/stable/api/catalyst_api/)
6-
<!--- [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://docs.sciml.ai/Catalyst/dev/)
7-
[![API Dev](https://img.shields.io/badge/API-dev-blue.svg)](https://docs.sciml.ai/Catalyst/dev/api/catalyst_api/) -->
6+
[![Join the chat at https://julialang.zulipchat.com #sciml-bridged](https://img.shields.io/static/v1?label=Zulip&message=chat&color=9558b2&labelColor=389826)](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
87

98
[![Build Status](https://github.com/SciML/Catalyst.jl/workflows/CI/badge.svg)](https://github.com/SciML/Catalyst.jl/actions?query=workflow%3ACI)
109
[![codecov.io](https://codecov.io/gh/SciML/Catalyst.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/SciML/Catalyst.jl)
@@ -22,7 +21,7 @@ specified using Catalyst's domain-specific language (DSL). Leveraging
2221
[Symbolics.jl](https://github.com/JuliaSymbolics/Symbolics.jl), Catalyst enables
2322
large-scale simulations through auto-vectorization and parallelism. Symbolic
2423
`ReactionSystem`s can be used to generate ModelingToolkit-based models, allowing
25-
the easy simulation and parameter estimation of mass action ODE models, Chemical
24+
the easy simulation and parameter estimation of mass action ODE models, chemical
2625
Langevin SDE models, stochastic chemical kinetics jump process models, and more.
2726
Generated models can be used with solvers throughout the broader
2827
[SciML](https://sciml.ai) ecosystem, including higher-level SciML packages (e.g.
@@ -37,27 +36,12 @@ Breaking changes and new functionality are summarized in the [HISTORY.md](HISTOR
3736

3837
## Tutorials and documentation
3938

40-
The latest tutorials and information on using the package are available in the [stable
39+
The latest tutorials and information on using Catalyst are available in the [stable
4140
documentation](https://docs.sciml.ai/Catalyst/stable/). The [in-development
4241
documentation](https://docs.sciml.ai/Catalyst/dev/) describes unreleased features in
4342
the current master branch.
4443

45-
Several YouTube video tutorials and overviews are also available (however, these use older versions of Catalyst, and some notation may be out-of-date):
46-
- From JuliaCon 2023: A short 15-minute overview of Catalyst (version 13) is
47-
available in the talk [Catalyst.jl, Modeling Chemical Reaction Networks](https://www.youtube.com/watch?v=yreW94n98eM&ab_channel=TheJuliaProgrammingLanguage).
48-
- From JuliaCon 2022: A 3-hour tutorial workshop overviewing how to use
49-
Catalyst (version 12.1) and its more advanced features. [Workshop
50-
video](https://youtu.be/tVfxT09AtWQ), [Workshop Pluto.jl
51-
Notebooks](https://github.com/SciML/JuliaCon2022_Catalyst_Workshop).
52-
- From SIAM CSE 2021: A short 15-minute overview of Catalyst (version 6) is
53-
available in the talk [Modeling Biochemical Systems with
54-
Catalyst.jl](https://www.youtube.com/watch?v=5p1PJE5A5Jw).
55-
- From JuliaCon 2018: A short 13-minute overview of Catalyst (when it was known
56-
as DiffEqBiological) is available in the talk [Efficient
57-
Modelling of Biochemical Reaction
58-
Networks](https://www.youtube.com/watch?v=s1e72k5XD6s)
59-
60-
Finally, an overview of the package and its features (as of version 13) can also be found in its corresponding research paper, [Catalyst: Fast and flexible modeling of reaction networks](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1011530).
44+
An overview of the package and its features (as of version 13) can also be found in its corresponding research paper, [Catalyst: Fast and flexible modeling of reaction networks](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1011530).
6145

6246
## Features
6347

@@ -71,7 +55,7 @@ Finally, an overview of the package and its features (as of version 13) can also
7155
- The [Catalyst.jl API](http://docs.sciml.ai/Catalyst/stable/api/catalyst_api) provides functionality
7256
for extending networks, building networks programmatically, and for composing
7357
multiple networks together.
74-
- Generated systems can be simulated using any
58+
- Generated models can be simulated using any
7559
[DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/)
7660
[ODE/SDE/jump solver](@ref ref), and can be used within `EnsembleProblem`s for carrying
7761
out [parallelized parameter sweeps and statistical sampling](@ref ref). Plot recipes
@@ -157,13 +141,13 @@ an ordinary differential equation.
157141

158142
```julia
159143
# Fetch required packages.
160-
using Catalyst, DifferentialEquations, Plots
144+
using Catalyst, OrdinaryDiffEq, Plots
161145

162146
# Create model.
163147
model = @reaction_network begin
164-
kB, S + E --> SE
165-
kD, SE --> S + E
166-
kP, SE --> P + E
148+
kB, S + E --> SE
149+
kD, SE --> S + E
150+
kP, SE --> P + E
167151
end
168152

169153
# Create an ODE that can be simulated.
@@ -176,53 +160,65 @@ ode = ODEProblem(model, u0, tspan, ps)
176160
sol = solve(ode)
177161
plot(sol; lw = 5)
178162
```
179-
180-
![](https://user-images.githubusercontent.com/1814174/87864114-3bf9dd00-c932-11ea-83a0-58f38aee8bfb.png)
163+
![ODE simulation](docs/src/assets/readme_ode_plot.svg)
181164

182165
#### Stochastic jump simulations
183166
The same model can be used as input to other types of simulations. E.g. here we instead perform a
184167
jump simulation
185168
```julia
186169
# Create and simulate a jump process (here using Gillespie's direct algorithm).
170+
using JumpProcesses
187171
dprob = DiscreteProblem(model, u0, tspan, ps)
188172
jprob = JumpProblem(model, dprob, Direct())
189173
jump_sol = solve(jprob, SSAStepper())
190174
plot(jump_sol; lw = 2)
191175
```
176+
![Jump simulation](docs/src/assets/readme_jump_plot.svg)
192177

193178

194179
## Elaborate example
195180

196-
In the above example, we used basic Catalyst-based workflows to simulate a simple model. Here we instead show how various Catalyst features can compose to create a much more advanced model. Our model describes how the volume of a cell ($V$) is affected by a growth factor ($G$). Typically the growth factor is inactive ($Gi$), but it is activated ($Ga$) by the presence of sunlight (modeled as the cyclic sinusoid $kA*(sin(t)+1)$). When the cell reaches a critical volume ($V$) it goes through cell division. First, we declare our model:
181+
In the above example, we used basic Catalyst-based workflows to simulate a simple model. Here we instead show how various Catalyst features can compose to create a much more advanced model. Our model describes how the volume of a cell ($V$) is affected by a growth factor ($G$). The growth factor only promotes growth while in its phosphorylated form ($Gᴾ$). The phosphorylation of $G$ ($G \to Gᴾ$) is promoted by sunlight (modelled as the cyclic sinusoid $kₐ*(sin(t)+1)$) phosphorylates the growth factor (producing $Gᴾ$). When the cell reaches a critical volume ($V$) it goes through cell division. First, we declare our model:
197182
```julia
183+
using Catalyst
198184
cell_model = @reaction_network begin
199-
@parameters V_thres g
200-
@equations begin
201-
D(V) ~ g*Ga
202-
end
203-
@continuous_events begin
204-
[V ~ V_thres] => [V ~ V/2]
205-
end
206-
(kA*(sin(t)+1), kI), Gi <--> Ga
185+
@parameters Vₘₐₓ g Ω
186+
@default_noise_scaling Ω
187+
@equations begin
188+
D(V) ~ g*Gᴾ
189+
end
190+
@continuous_events begin
191+
[V ~ Vₘₐₓ] => [V ~ V/2]
192+
end
193+
kₚ*(sin(t)+1)/V, G --> Gᴾ
194+
kᵢ/V, Gᴾ --> G
207195
end
208196
```
209197
Next, we can use [Latexify.jl](https://korsbo.github.io/Latexify.jl/stable/) to show the ordinary differential equations associated with this model:
210198
```julia
211199
using Latexify
212200
latexify(cell_model; form = :ode)
213201
```
214-
In this case we would like to perform stochastic simulations, so we transform our model to an SDE:
202+
In this case, we would instead like to perform stochastic simulations, so we transform our model to an SDE:
215203
```julia
216-
u0 = [:V => 0.5, :Gi => 1.0, :Ga => 0.0]
217-
tspan = (0.0, 10.0)
218-
ps = [:V_thres => 1.0, :g => 0.5, :kA => 5.0, :kI => 2.0]
204+
u0 = [:V => 0.5, :G => 1.0, :Gᴾ => 0.0]
205+
tspan = (0.0, 20.0)
206+
ps = [:Vₘₐₓ => 1.0, :g => 0.2, :kₚ => 5.0, :kᵢ => 2.0, => 0.1]
219207
sprob = SDEProblem(cell_model, u0, tspan, ps)
220208
```
221209
Finally, we simulate it and plot the result.
222210
```julia
223-
sol = solve(oprob, Tsit5())
224-
plot(sol)
211+
using StochasticDiffEq
212+
sol = solve(sprob, STrapezoid())
213+
plot(sol; xguide = "Time (au)", lw = 2)
225214
```
215+
![Elaborate SDE simulation](docs/src/assets/readme_elaborate_sde_plot.svg)
216+
217+
Some features we used here:
218+
- The SDE was [simulated using StochasticDiffEq.jl], where we [scaled the SDE noise terms](@ref ref).
219+
- The cell volume was [modelled as a differential equation, which was coupled to the reaction network model](@ref ref).
220+
- The cell divisions were created by [incorporating events into the model](@ref ref).
221+
- The model equations were [displayed using Latexify.jl](@ref ref), and the simulation [plotted using Plots.jl](@ref ref).
226222

227223
## Getting help or getting involved
228224
Catalyst developers are active on the [Julia Discourse](https://discourse.julialang.org/),

0 commit comments

Comments
 (0)