Skip to content

Commit b258102

Browse files
author
Kevin Cazelles
committed
🎨 reproduce SI figures too
1 parent 19e08bb commit b258102

7 files changed

Lines changed: 68 additions & 32 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#
2-
figs*/*.svg
1+
# project specific files
2+
fig/*.svg
33
src/figs/*.svg
44
src/res
55
*.zip

src/basic_omnivory_module.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function plot_sa_unit_rev(rg, res, id, leg = false, xlb = "", ylb = "")
181181
end
182182

183183

184-
# helper function to check out degree of omnivory
184+
# Helper function to check out degree of omnivory
185185
function check_doo(res, rgs)
186186
type = ["Fixed" "Responsive"]
187187
phase = ["Equilibrium", "Pulse", "Transient", "New Equilibrium"]

src/fig_press.jl

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,33 @@ include("basic_omnivory_module.jl")
22
include("press.jl")
33
using PyPlot
44

5-
# PRESS SIMULATION
6-
par = ModelPar()
7-
# NB: for FigS4, use
8-
# par = ModelPar(e_CP = 0.5, e_RC = 0.5, e_RP = 0.5)
5+
# PRESS SIMULATIONS
6+
# returns dynamics and metrics in different panels, we actually dispatch the
7+
# different pannels between figure 3 and 4 with Inkscape (we did the same
8+
# for figures S3 and S4).
9+
10+
# we pass "true" to this ARGS for supplementary figures
11+
if isempty(ARGS) || ARGS[1] != "true"
12+
# default for main figures 3 and 4
13+
par = ModelPar()
14+
fl_fig = "fig/fig_press.svg"
15+
else
16+
# parameters for SI figures S3 and S4
17+
par = ModelPar(e_CP = 0.5, e_RC = 0.5, e_RP = 0.5)
18+
fl_fig = "fig/fig_press_si.svg"
19+
end
20+
21+
# run the simulation
922
res = press(par, 0.1, 1.2)
10-
# check equilibria
23+
24+
# temporal ranges of the different phases
1125
rgs = [
1226
280:0.01:299,
1327
300:0.01:320,
1428
320:0.01:550,
1529
880:0.01:900
1630
]
31+
# check degree of omnivory for the different phases
1732
check_doo(res, rgs)
1833

1934
# plot helper
@@ -108,5 +123,4 @@ ylabel("Max - Min")
108123
plt.legend()
109124

110125
tight_layout()
111-
savefig("fig/fig_3.svg")
112-
# savefig("fig/fig_S3.svg")
126+
savefig(fl_fig)

src/fig_pulse.jl

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,35 @@ include("pulse.jl")
33
using PyPlot
44
pygui(true)
55

6+
# PULSE SIMULATIONS
7+
# returns dynamics and metrics in different panels, we actually dispatch the
8+
# different pannels between figure 3 and 4 with Inkscape (we did the same
9+
# for figures S3 and S4).
610

7-
# PULSE SIMULATION
8-
par = ModelPar()
9-
# NB: for FigS3, use
10-
# par = ModelPar(e_CP = 0.5, e_RC = 0.5, e_RP = 0.5)
11-
# this returns all the results required for figure 3
11+
# we pass "true" to this ARGS for supplementary figures
12+
if isempty(ARGS) || ARGS[1] != "true"
13+
# default for main figures 3 and 4
14+
par = ModelPar()
15+
fl_fig = "fig/fig_pulse.svg"
16+
else
17+
# parameters for SI figures S3 and S4
18+
par = ModelPar(e_CP = 0.5, e_RC = 0.5, e_RP = 0.5)
19+
fl_fig = "fig/fig_pulse_si.svg"
20+
end
21+
22+
# run pulse simulation
1223
res = pulse(par, 0.1, 2.0, 2.0)
13-
# check equilibria (NB the par should affetc the 2 last ranges if going back to equilibrium takes more time)
24+
25+
# temporal ranges of the different phases
1426
rgs = [
1527
180:0.01:199,
1628
200:0.01:205,
1729
205:0.01:325,
1830
325:0.01:350
1931
]
32+
# check degree of omnivory for the different phases
2033
check_doo(res, rgs)
34+
2135
# plot helper
2236
function plot_illustration(sol, eq, ttl_id, leg = true, y_max = 5)
2337
RCP_cols = ["#1f77b4", "#ff7f0e", "#2ca02c"]
@@ -107,6 +121,5 @@ ylabel("Max - Min")
107121
plt.legend()
108122

109123
tight_layout()
110-
savefig("fig/fig_4.svg")
111-
# savefig("fig/fig_S3.svg")
124+
savefig(fl_fig)
112125

src/pipeline.jl

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,42 @@
22
printstyled("1. Installing packages\n", color = :blue)
33
include("install_packages.jl")
44

5-
## Pulse main
5+
6+
# Main
7+
## Pulse
68
printstyled("2. Runing pulse analysis\n", color = :blue)
79
include("fig_pulse.jl")
810
printstyled("Done! fig_pulse.jl created\n\n", color = :green)
9-
10-
## Press main
11+
## Press
1112
printstyled("3. Runing press analysis\n", color = :blue)
1213
include("fig_press.jl")
1314
printstyled("Done! fig_pulse.jl created\n", color = :green)
1415

15-
## Pulse main
16+
17+
# Supplementary Information
18+
19+
# The line below is used to run the SI version of the figure: when the 1st
20+
# argument of 'ARGS' is true, then the parameters used are the one for the SI
21+
# figure. Note that we actually use `ARGS` because this is specifically
22+
# the vector that captures external arguments. Thus using it allows us to use
23+
# arguments in the command line. So here, to run the SI version of fig_pulse,
24+
# I'd use `julia fig_pulse.jl true`. To mimic this we simply add "true" to
25+
# ARGS here rather than via an external argument
26+
push!(ARGS, "true")
27+
28+
## Pulse
1629
printstyled("4. Runing pulse analysis for SI\n", color = :blue)
17-
include("fig_pulse.jl", ARGS = ["true"])
30+
include("fig_pulse.jl")
1831
printstyled("Done! fig_pulse_si.jl created\n\n", color = :green)
1932

20-
## Press main
33+
## Press
2134
printstyled("5. Runing press analysis for SI\n", color = :blue)
22-
include("fig_press.jl", ARGS = ["true"])
35+
include("fig_press.jl")
2336
printstyled("Done! fig_press_si.jl created\n\n", color = :green)
2437

2538
# Figures S2 and S3 takes ~2hours each and basically call the same functions
2639
# as previous analyses so we skipped them on GitHub Actions
27-
printstyled("Fig S1 and S2 are skipped\n\n", color = :red)
40+
printstyled("NB: Fig. S1 and S2 are skipped because they are time/energy-consuming\n\n", color = :red)
2841

2942
# Figure S2 takes ~2hours
3043
# printstyled("Runing simulations for FigS1\n", color = :blue)

src/press.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using DifferentialEquations, NLsolve
22

3+
# analysis for one press simulation (1 system)
34
function press_unit(par, p_strength)
45
# Parameters
56
u0 = [1.0, 1.5, 1.5]

src/pulse.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
# Simulation for pulse experiment
22
using DifferentialEquations, NLsolve
33

4-
function find_time_hit_res_max(res)
5-
max_res = findmax(res[1,:])
6-
return res.t[max_res[2]]
7-
end
8-
9-
4+
# analysis for one pulse simulation (1 system)
105
function pulse_unit(par, p_length, p_strength)
116
# Parameters
127
u0 = [1.0, 1.5, 1.5]

0 commit comments

Comments
 (0)