Skip to content

Commit 6c3d267

Browse files
author
Hiroaki Imoto
authored
Merge pull request #33 from himoto/develop
Release v0.4.1
2 parents d73326a + b559436 commit 6c3d267

File tree

12 files changed

+172
-104
lines changed

12 files changed

+172
-104
lines changed

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BioMASS"
22
uuid = "324734c7-f323-4536-9335-775d9be9d101"
33
authors = ["Hiroaki Imoto <himoto@protein.osaka-u.ac.jp>"]
4-
version = "0.4.0"
4+
version = "0.4.1"
55

66
[deps]
77
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ This module provides a Julia interface to the [BioMASS](https://github.com/okada
1515

1616
BioMASS.jl supports:
1717

18-
- Parameter Estimation of ODE/DDE models
19-
- Bifurcation Analysis
18+
- parameter estimation of ODE/DDE models
19+
- visualization of simulation results
20+
- bifurcation analysis
2021

2122
## Usage
2223

@@ -32,7 +33,7 @@ optimize(model, 1, max_generation=20000, allowable_error=0.5)
3233
visualize(model, viz_type="best", show_all=true)
3334
```
3435

35-
## Convert optimized parameters into BioMASS format
36+
## Convert optimized parameters to BioMASS format
3637

3738
![](docs/src/assets/conversion.png)
3839

docs/src/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This module provides a Julia interface to the [BioMASS](https://github.com/okada
99
## Features
1010

1111
- Parameter estimation
12+
- Visualization of simulation results
1213
- Bifurcation analysis
1314

1415
## Installation

docs/src/usage/parameter_estimation.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ Find a parameter set that reproduces experimental observations.
5353

5454
- The maximum number of generations over which the entire population is evolved.
5555

56+
- `initial_threshold`::Float64 (default: 1e12)
57+
58+
- Allowable error used to generate initial population. Default is 1e12 (numerically solvable).
59+
5660
- `allowable_error`::Float64 (default: 0.0)
5761

5862
- Optimization stops when Best Fitness <= allowable_error.
@@ -92,9 +96,13 @@ Save simulation results with optimized parameter values.
9296
- Whether to show all simulation results.
9397

9498
- `stdev`::Bool (default: `false`)
99+
95100
- If True, the standard deviation of simulated values will be shown
96101
(only available for `"average"` visualization type).
97102

103+
- `save_format`::String (default: `"pdf"`)
104+
- Either "png" or "pdf", indicating whether to save figures as png or pdf format.
105+
98106
---
99107

100108
**param2biomass**(`path_to_model`::String)

examples/fos_model/set_search_param.jl

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,18 @@ function get_search_region()::Matrix{Float64}
9595
search_idx::Tuple{Array{Int64,1},Array{Int64,1}} = get_search_index()
9696
search_param::Vector{Float64} = init_search_param(search_idx, p, u0)
9797

98-
search_rgn::Matrix{Float64} = zeros(2, length(p)+length(u0))
98+
search_rgn::Matrix{Float64} = zeros(2, length(p) + length(u0))
9999

100100
# Default: 0.1 ~ 10x
101-
for (i,j) in enumerate(search_idx[1])
102-
search_rgn[1,j] = search_param[i]*0.1 # lower bound
103-
search_rgn[2,j] = search_param[i]*10.0 # upper bound
101+
for (i, j) in enumerate(search_idx[1])
102+
search_rgn[1,j] = search_param[i] * 0.1 # lower bound
103+
search_rgn[2,j] = search_param[i] * 10.0 # upper bound
104104
end
105105

106106
# Default: 0.5 ~ 2x
107-
for (i,j) in enumerate(search_idx[2])
108-
search_rgn[1,j+length(p)] = search_param[i+length(search_idx[1])]*0.5 # lower bound
109-
search_rgn[2,j+length(p)] = search_param[i+length(search_idx[1])]*2.0 # upper bound
107+
for (i, j) in enumerate(search_idx[2])
108+
search_rgn[1,j + length(p)] = search_param[i + length(search_idx[1])] * 0.5 # lower bound
109+
search_rgn[2,j + length(p)] = search_param[i + length(search_idx[1])] * 2.0 # upper bound
110110
end
111111

112112
# search_rgn[:, C.param_name] = [lower_bound, upper_bound]
@@ -200,11 +200,11 @@ function update_param(indiv::Vector{Float64})::Tuple{Array{Float64,1},Array{Floa
200200

201201
search_idx::Tuple{Array{Int64,1},Array{Int64,1}} = get_search_index()
202202

203-
for (i,j) in enumerate(search_idx[1])
203+
for (i, j) in enumerate(search_idx[1])
204204
@inbounds p[j] = indiv[i]
205205
end
206-
for (i,j) in enumerate(search_idx[2])
207-
@inbounds u0[j] = indiv[i+length(search_idx[1])]
206+
for (i, j) in enumerate(search_idx[2])
207+
@inbounds u0[j] = indiv[i + length(search_idx[1])]
208208
end
209209

210210
# constraints --------------------------------------------------------------
@@ -240,7 +240,7 @@ function decode_gene2val(indiv_gene::Vector{Float64})::Vector{Float64}
240240
)
241241
end
242242

243-
return round.(indiv,sigdigits=7)
243+
return round.(indiv, sigdigits=7)
244244
end
245245

246246

@@ -261,18 +261,18 @@ end
261261

262262

263263
function encode_bestIndivVal2randGene(
264-
idx::Int64,
264+
gene_idx::Int64,
265265
best_indiv::Vector{Float64},
266266
p0_bounds::Vector{Float64})::Float64
267267
search_rgn::Matrix{Float64} = get_search_region()
268268
rand_gene::Float64 = (
269269
log10(
270-
best_indiv[idx]*10^(
271-
rand() * log10(p0_bounds[2]/p0_bounds[1]) + log10(p0_bounds[1])
270+
best_indiv[gene_idx] * 10^(
271+
rand() * log10(p0_bounds[2] / p0_bounds[1]) + log10(p0_bounds[1])
272272
)
273-
) - search_rgn[1,idx]
273+
) - search_rgn[1,gene_idx]
274274
) / (
275-
search_rgn[2,idx] - search_rgn[1,idx]
275+
search_rgn[2,gene_idx] - search_rgn[1,gene_idx]
276276
)
277277
return rand_gene
278278
end
@@ -284,15 +284,15 @@ function init_search_param(
284284
u0::Vector{Float64})::Vector{Float64}
285285
duplicate::Vector{String} = []
286286
if length(search_idx[1]) != length(unique(search_idx[1]))
287-
for idx in findall([count(x->x==i,search_idx[1])
287+
for idx in findall([count(x -> x == i, search_idx[1])
288288
for i in unique(search_idx[1])] .!= 1)
289289
push!(duplicate, C.NAMES[search_idx[1][idx]])
290290
end
291291
error(
292292
"Duplicate parameters (C.): $duplicate"
293293
)
294294
elseif length(search_idx[2]) != length(unique(search_idx[2]))
295-
for idx in findall([count(x->x==i,search_idx[2])
295+
for idx in findall([count(x -> x == i, search_idx[2])
296296
for i in unique(search_idx[2])] .!= 1)
297297
push!(duplicate, V.NAMES[search_idx[2][idx]])
298298
end
@@ -303,11 +303,11 @@ function init_search_param(
303303
search_param = zeros(
304304
length(search_idx[1]) + length(search_idx[2])
305305
)
306-
for (i,j) in enumerate(search_idx[1])
306+
for (i, j) in enumerate(search_idx[1])
307307
@inbounds search_param[i] = p[j]
308308
end
309-
for (i,j) in enumerate(search_idx[2])
310-
@inbounds search_param[i+length(search_idx[1])] = u0[j]
309+
for (i, j) in enumerate(search_idx[2])
310+
@inbounds search_param[i + length(search_idx[1])] = u0[j]
311311
end
312312

313313
if any(x -> x == 0.0, search_param)
@@ -339,35 +339,35 @@ end
339339
function conv_lin2log!(
340340
search_rgn::Matrix{Float64},
341341
search_idx::Tuple{Array{Int64,1},Array{Int64,1}})::Matrix{Float64}
342-
for i=1:size(search_rgn,2)
342+
for i = 1:size(search_rgn, 2)
343343
if minimum(search_rgn[:,i]) < 0.0
344344
msg = "search_rgn[lower_bound,upper_bound] must be positive.\n"
345345
if i <= C.NUM
346346
error(@sprintf("`C.%s` ", C.NAMES[i]) * msg)
347347
else
348-
error(@sprintf("`V.%s` ", V.NAMES[i-C.NUM]) * msg)
348+
error(@sprintf("`V.%s` ", V.NAMES[i - C.NUM]) * msg)
349349
end
350350
elseif minimum(search_rgn[:,i]) == 0.0 && maximum(search_rgn[:,i]) != 0.0
351351
msg = "lower_bound must be larger than 0.\n"
352352
if i <= C.NUM
353353
error(@sprintf("`C.%s` ", C.NAMES[i]) * msg)
354354
else
355-
error(@sprintf("`V.%s` ", V.NAMES[i-C.NUM]) * msg)
355+
error(@sprintf("`V.%s` ", V.NAMES[i - C.NUM]) * msg)
356356
end
357357
elseif search_rgn[2,i] - search_rgn[1,i] < 0.0
358358
msg = "lower_bound must be smaller than upper_bound.\n"
359359
if i <= C.NUM
360360
error(@sprintf("`C.%s` ", C.NAMES[i]) * msg)
361361
else
362-
error(@sprintf("`V.%s` ", V.NAMES[i-C.NUM]) * msg)
362+
error(@sprintf("`V.%s` ", V.NAMES[i - C.NUM]) * msg)
363363
end
364364
end
365365
end
366366

367367
nonzero_idx::Vector{Int} = []
368-
for i=1:size(search_rgn,2)
368+
for i = 1:size(search_rgn, 2)
369369
if search_rgn[:,i] != [0.0,0.0]
370-
push!(nonzero_idx,i)
370+
push!(nonzero_idx, i)
371371
end
372372
end
373373
difference::Vector{Int} = collect(
@@ -381,7 +381,7 @@ function conv_lin2log!(
381381
if idx <= C.NUM
382382
println(@sprintf("`C.%s`", C.NAMES[Int(idx)]))
383383
else
384-
println(@sprintf("`V.%s`", V.NAMES[Int(idx)-C.NUM]))
384+
println(@sprintf("`V.%s`", V.NAMES[Int(idx) - C.NUM]))
385385
end
386386
end
387387
error(

examples/fos_model/simulation.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ for observable in observables
2323
end
2424

2525
const dt = 1.0
26-
t = collect(0.0:dt:5400.0) # 0, 1, 2, ..., 5400 [sec.]
26+
const t = collect(0.0:dt:5400.0) # 0, 1, 2, ..., 5400 [sec.]
2727

2828
const conditions = ["EGF", "HRG"]
2929

@@ -42,7 +42,11 @@ function solveode(
4242
prob = ODEProblem(f, u0, (t[1], t[end]), p)
4343
sol = solve(
4444
prob,CVODE_BDF(),
45-
abstol=ABSTOL,reltol=RELTOL,saveat=dt,verbose=false
45+
abstol=ABSTOL,
46+
reltol=RELTOL,
47+
saveat=dt,
48+
dtmin=eps(),
49+
verbose=false
4650
)
4751
is_successful = ifelse(sol.retcode === :Success, true, false)
4852
catch
@@ -67,9 +71,13 @@ function get_steady_state(
6771
sol = solve(
6872
prob,
6973
DynamicSS(
70-
CVODE_BDF();abstol=ABSTOL,reltol=RELTOL
74+
CVODE_BDF();
75+
abstol=ABSTOL,
76+
reltol=RELTOL
7177
),
72-
dt=dt,verbose=false
78+
dt=dt,
79+
dtmin=eps(),
80+
verbose=false
7381
)
7482
is_successful = ifelse(sol.retcode === :Success, true, false)
7583
catch

0 commit comments

Comments
 (0)