-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #779 from LCSB-BioCore/develop
Develop → master merge for 1.5.0
- Loading branch information
Showing
6 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Build an [`ExpressionLimitedModel`](@ref). | ||
""" | ||
make_expression_limited_model( | ||
model::MetabolicModel; | ||
relative_expression::Dict{String,Float64}, | ||
bounding_function::Function = expression_probabilistic_bounds, | ||
) = ExpressionLimitedModel(; relative_expression, bounding_function, inner = model) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
""" | ||
$(TYPEDEF) | ||
[`ExpressionLimitedModel`](@ref) follows the methodology of the E-Flux algorithm to | ||
constraint the flux through the reactions in order to simulate the limited | ||
expression of genes (and thus the limited availability of the gene products). | ||
Use [`make_expression_limited_model`](@ref) or [`with_expression_limits`](@ref) | ||
to construct the models. | ||
E-Flux algorithm is closer described by: *Colijn, Caroline, Aaron Brandes, | ||
Jeremy Zucker, Desmond S. Lun, Brian Weiner, Maha R. Farhat, Tan-Yun Cheng, D. | ||
Branch Moody, Megan Murray, and James E. Galagan. "Interpreting expression data | ||
with metabolic flux models: predicting Mycobacterium tuberculosis mycolic acid | ||
production." PLoS computational biology 5, no. 8 (2009): e1000489*. | ||
# Fields | ||
$(TYPEDFIELDS) | ||
""" | ||
Base.@kwdef struct ExpressionLimitedModel <: ModelWrapper | ||
""" | ||
Relative gene expression w.r.t. to some chosen reference; the normalization | ||
and scale of the values should match the expectations of the | ||
`bounding_function`. | ||
""" | ||
relative_expression::Dict{String,Float64} | ||
|
||
"The wrapped model." | ||
inner::MetabolicModel | ||
|
||
""" | ||
Function used to calculate the new reaction bounds from expression. | ||
In [`make_expression_limited_model`](@ref) this defaults to | ||
[`expression_probabilistic_bounds`](@ref). | ||
""" | ||
bounding_function::Function | ||
end | ||
|
||
COBREXA.unwrap_model(m::ExpressionLimitedModel) = m.inner | ||
|
||
function COBREXA.bounds(m::ExpressionLimitedModel)::Tuple{Vector{Float64},Vector{Float64}} | ||
(lbs, ubs) = bounds(m.inner) | ||
lims = collect( | ||
m.bounding_function(m.relative_expression, reaction_gene_association(m.inner, rid)) for rid in reactions(m.inner) | ||
) | ||
(lbs .* lims, ubs .* lims) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Create E-Flux-like bounds for a reaction that requires gene products given by | ||
`grr`, with expression "choke" data given by relative probabilities (between 0 | ||
and 1) in `relative_expression`. | ||
""" | ||
function expression_probabilistic_bounds( | ||
relative_expression::Dict{String,Float64}, | ||
grr::Maybe{Vector{Vector{String}}}, | ||
)::Float64 | ||
isnothing(grr) && return 1.0 | ||
lup(g) = get(relative_expression, g, 1.0) | ||
1 - prod(1 - prod(lup.(gr)) for gr in grr) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
""" | ||
$(TYPEDSIGNATURES) | ||
Specifies a model variant which adds extra semantics of the | ||
[`ExpressionLimitedModel`](@ref), simulating the E-Flux algorithm. The | ||
arguments are forwarded to [`make_expression_limited_model`](@ref). Intended | ||
for usage with [`screen`](@ref). | ||
""" | ||
with_expression_limits(; kwargs...) = | ||
model -> make_expression_limited_model(model; kwargs...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
@testset "Expression-limited models" begin | ||
orig_model = load_model(model_paths["e_coli_core.json"]) | ||
|
||
model = | ||
orig_model |> | ||
with_expression_limits(relative_expression = Dict(genes(orig_model) .=> 0.5)) | ||
|
||
bs = Dict(reactions(model) .=> bounds(model)[1]) | ||
|
||
@test getindex.(Ref(bs), ["PFK", "ENO", "ACALD"]) == [0, -500, -750] | ||
|
||
fluxes = flux_balance_analysis_dict(model, Tulip.Optimizer) | ||
|
||
@test isapprox(fluxes["BIOMASS_Ecoli_core_w_GAM"], 0.21386, atol = TEST_TOLERANCE) | ||
end |
9cde7b4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
9cde7b4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/83092
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: