Skip to content

Commit b92002c

Browse files
committed
up
1 parent 2222f90 commit b92002c

File tree

2 files changed

+96
-7
lines changed

2 files changed

+96
-7
lines changed

ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Creates a ODE system of the form used within the StructuralIdentifiability.jl pa
88
99
Arguments:
1010
- `rs::ReactionSystem`; The reaction system we wish to convert to an ODE.
11-
- `measured_quantities=[]`: The quantities of the system we can measure. May either be equations (e.g. `x1 + x2`), or single species (e.g. the symbolic `x`, `rs.s`, or the symbol `:x`). Defaults to the system's observables.
11+
- `measured_quantities=[]`: The quantities of the system we can measure. May either be equations (e.g. `x1 + x2`), or single species (e.g. the symbolic `x`, `rs.s`, or the symbol `:x`).
1212
- `known_p = Num[]`: List of parameters which values are known.
1313
- `ignore_no_measured_warn = false`: If set to `true`, no warning is provided when the `measured_quantities` vector is empty.
1414
- `remove_conserved = true`: Whether to eliminate conservation laws when computing the ode (this can reduce runtime of identifiability analysis significantly).
@@ -25,20 +25,43 @@ make_si_ode(rs; measured_quantities = [:X], known_p = [:p])
2525
Notes:
2626
- This function is part of the StructuralIdentifiability.jl extension. StructuralIdentifiability.jl must be imported to access it.
2727
- `measured_quantities` and `known_p` input may also be symbolic (e.g. measured_quantities = [rs.X])
28-
```
2928
"""
3029
function Catalyst.make_si_ode(rs::ReactionSystem; measured_quantities = [], known_p = [],
3130
ignore_no_measured_warn = false, remove_conserved = true)
3231
# Creates a MTK ODESystem, and a list of measured quantities (there are equations).
3332
# Gives these to SI to create an SI ode model of its preferred form.
3433
osys, conseqs, _ = make_osys(rs; remove_conserved)
3534
measured_quantities = make_measured_quantities(rs, measured_quantities, known_p, conseqs; ignore_no_measured_warn)
36-
return SI.preprocess_ode(osys, measured_quantities)[1]
35+
return SI.mtk_to_si(osys, measured_quantities)[1]
3736
end
3837

3938
### Structural Identifiability Wrappers ###
4039

41-
# Creates dispatch for SI's local identifiability analysis function.
40+
"""
41+
assess_local_identifiability(rs::ReactionSystem, args...; measured_quantities = Num[], known_p = Num[],, remove_conserved = true, ignore_no_measured_warn=false, kwargs...)
42+
43+
Applies StructuralIdentifiability.jl's `assess_local_identifiability` function to a Catalyst `ReactionSystem`. Internally it is converted ot a `ODESystem`, for which structural identifiability is computed.
44+
45+
Arguments:
46+
- `rs::ReactionSystem`; The reaction system we wish to compute structural identifiability for.
47+
- `measured_quantities=[]`: The quantities of the system we can measure. May either be equations (e.g. `x1 + x2`), or single species (e.g. the symbolic `x`, `rs.s`, or the symbol `:x`).
48+
- `known_p = Num[]`: List of parameters which values are known.
49+
- `ignore_no_measured_warn = false`: If set to `true`, no warning is provided when the `measured_quantities` vector is empty.
50+
- `remove_conserved = true`: Whether to eliminate conservation laws when computing the ode (this can reduce runtime of identifiability analysis significantly).
51+
52+
Example:
53+
```julia
54+
using Catalyst, StructuralIdentifiability
55+
rs = @reaction_network begin
56+
(p,d), 0 <--> X
57+
end
58+
assess_local_identifiability(rs; measured_quantities = [:X], known_p = [:p])
59+
```
60+
61+
Notes:
62+
- This function is part of the StructuralIdentifiability.jl extension. StructuralIdentifiability.jl must be imported to access it.
63+
- `measured_quantities` and `known_p` input may also be symbolic (e.g. measured_quantities = [rs.X])
64+
"""
4265
function SI.assess_local_identifiability(rs::ReactionSystem, args...; measured_quantities = Num[],
4366
known_p = Num[], funcs_to_check = Vector(), remove_conserved = true,
4467
ignore_no_measured_warn=false, kwargs...)
@@ -52,7 +75,31 @@ function SI.assess_local_identifiability(rs::ReactionSystem, args...; measured_q
5275
return make_output(out, funcs_to_check, reverse.(conseqs))
5376
end
5477

55-
# Creates dispatch for SI's global identifiability analysis function.
78+
"""
79+
assess_identifiability(rs::ReactionSystem, args...; measured_quantities = Num[], known_p = Num[],, remove_conserved = true, ignore_no_measured_warn=false, kwargs...)
80+
81+
Applies StructuralIdentifiability.jl's `assess_identifiability` function to a Catalyst `ReactionSystem`. Internally it is converted ot a `ODESystem`, for which structural identifiability is computed.
82+
83+
Arguments:
84+
- `rs::ReactionSystem`; The reaction system we wish to compute structural identifiability for.
85+
- `measured_quantities=[]`: The quantities of the system we can measure. May either be equations (e.g. `x1 + x2`), or single species (e.g. the symbolic `x`, `rs.s`, or the symbol `:x`).
86+
- `known_p = Num[]`: List of parameters which values are known.
87+
- `ignore_no_measured_warn = false`: If set to `true`, no warning is provided when the `measured_quantities` vector is empty.
88+
- `remove_conserved = true`: Whether to eliminate conservation laws when computing the ode (this can reduce runtime of identifiability analysis significantly).
89+
90+
Example:
91+
```julia
92+
using Catalyst, StructuralIdentifiability
93+
rs = @reaction_network begin
94+
(p,d), 0 <--> X
95+
end
96+
assess_identifiability(rs; measured_quantities = [:X], known_p = [:p])
97+
```
98+
99+
Notes:
100+
- This function is part of the StructuralIdentifiability.jl extension. StructuralIdentifiability.jl must be imported to access it.
101+
- `measured_quantities` and `known_p` input may also be symbolic (e.g. measured_quantities = [rs.X])
102+
"""
56103
function SI.assess_identifiability(rs::ReactionSystem, args...; measured_quantities = Num[], known_p = Num[],
57104
funcs_to_check = Vector(), remove_conserved = true, ignore_no_measured_warn=false,
58105
kwargs...)
@@ -66,7 +113,31 @@ function SI.assess_identifiability(rs::ReactionSystem, args...; measured_quantit
66113
return make_output(out, funcs_to_check, reverse.(conseqs))
67114
end
68115

69-
# Creates dispatch for SI's function to find all identifiable functions.
116+
"""
117+
find_identifiable_functions(rs::ReactionSystem, args...; measured_quantities = Num[], known_p = Num[],, remove_conserved = true, ignore_no_measured_warn=false, kwargs...)
118+
119+
Applies StructuralIdentifiability.jl's `find_identifiable_functions` function to a Catalyst `ReactionSystem`. Internally it is converted ot a `ODESystem`, for which structurally identifiable functions are computed.
120+
121+
Arguments:
122+
- `rs::ReactionSystem`; The reaction system we wish to compute structural identifiability for.
123+
- `measured_quantities=[]`: The quantities of the system we can measure. May either be equations (e.g. `x1 + x2`), or single species (e.g. the symbolic `x`, `rs.s`, or the symbol `:x`).
124+
- `known_p = Num[]`: List of parameters which values are known.
125+
- `ignore_no_measured_warn = false`: If set to `true`, no warning is provided when the `measured_quantities` vector is empty.
126+
- `remove_conserved = true`: Whether to eliminate conservation laws when computing the ode (this can reduce runtime of identifiability analysis significantly).
127+
128+
Example:
129+
```julia
130+
using Catalyst, StructuralIdentifiability
131+
rs = @reaction_network begin
132+
(p,d), 0 <--> X
133+
end
134+
find_identifiable_functions(rs; measured_quantities = [:X], known_p = [:p])
135+
```
136+
137+
Notes:
138+
- This function is part of the StructuralIdentifiability.jl extension. StructuralIdentifiability.jl must be imported to access it.
139+
- `measured_quantities` and `known_p` input may also be symbolic (e.g. measured_quantities = [rs.X])
140+
"""
70141
function SI.find_identifiable_functions(rs::ReactionSystem, args...; measured_quantities = Num[],
71142
known_p = Num[], remove_conserved = true, ignore_no_measured_warn=false,
72143
kwargs...)

test/extensions/structural_identifiability.jl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ let
5555
@test sym_dict(gi_1) == sym_dict(gi_2) == sym_dict(gi_3)
5656
@test sym_dict(li_1) == sym_dict(li_2) == sym_dict(li_3)
5757
@test length(ifs_1) == length(ifs_2) == length(ifs_3)
58+
59+
# Checks output to manually checked correct answers.
60+
@test isequal(collect(keys(gi_1)), [states(goodwind_oscillator_catalyst); parameters(goodwind_oscillator_catalyst)])
61+
@test isequal(collect(values(gi_1)), [:globally, :nonidentifiable, :globally, :globally, :globally, :nonidentifiable, :locally, :nonidentifiable, :locally])
62+
@test isequal(collect(keys(li_1)), [states(goodwind_oscillator_catalyst); parameters(goodwind_oscillator_catalyst)])
63+
@test isequal(collect(values(li_1)), [1, 0, 1, 1, 1, 0, 1, 0, 1])
5864
end
5965

6066
# Tests on a made-up reaction network with mix of identifiable and non-identifiable components.
@@ -97,7 +103,13 @@ let
97103
# Check outputs.
98104
@test sym_dict(gi_1) == sym_dict(gi_2) == sym_dict(gi_3)
99105
@test sym_dict(li_1) == sym_dict(li_2) == sym_dict(li_3)
100-
@test length(ifs_1) == length(ifs_2) == length(ifs_3)
106+
@test length(ifs_1) == length(ifs_2) == length(ifs_3)
107+
108+
# Checks output to manually checked correct answers.
109+
@test isequal(collect(keys(gi_1)),[states(rs_catalyst); parameters(rs_catalyst)])
110+
@test isequal(collect(values(gi_1)),[:nonidentifiable, :globally, :globally, :nonidentifiable, :nonidentifiable, :nonidentifiable, :nonidentifiable, :globally, :globally, :globally])
111+
@test isequal(collect(keys(li_1)),[states(rs_catalyst); parameters(rs_catalyst)])
112+
@test isequal(collect(values(li_1)),[0, 1, 1, 0, 0, 0, 0, 1, 1, 1])
101113
end
102114

103115
# Tests on a made-up reaction network with mix of identifiable and non-identifiable components.
@@ -148,6 +160,12 @@ let
148160
@test sym_dict(gi_1) == sym_dict(gi_2) == sym_dict(gi_3)
149161
@test sym_dict(li_1) == sym_dict(li_2) == sym_dict(li_3)
150162
@test length(ifs_1[2:end]) == length(ifs_2) == length(ifs_3) # In the first case, the conservation law parameter is also identifiable.
163+
164+
# Checks output to manually checked correct answers.
165+
@test isequal(collect(keys(gi_1)),[states(rs_catalyst); parameters(rs_catalyst)])
166+
@test isequal(collect(values(gi_1)),[:globally, :locally, :locally, :nonidentifiable, :nonidentifiable, :globally, :globally, :globally, :globally, :locally, :locally, :nonidentifiable, :locally, :globally])
167+
@test isequal(collect(keys(li_1)),[states(rs_catalyst); parameters(rs_catalyst)])
168+
@test isequal(collect(values(li_1)),[1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1])
151169
end
152170

153171
# Tests that various inputs types work.

0 commit comments

Comments
 (0)