Skip to content

Commit

Permalink
update docs for fit_rate_equation
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis-Titov committed Feb 24, 2024
1 parent d1766ae commit 3c452f7
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/rate_equation_fitting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,30 @@ using CMAEvolutionStrategy, DataFrames, Statistics
n_iter = 20
)
Fit `rate_equation` to `data` and report the loss and best fit parameters.
Fit `rate_equation` to `data` and return loss and best fit parameters.
# Arguments
- `rate_equation::Function`: Function that takes a NamedTuple of metabolite concentrations (with `metab_names` keys) and parameters (with `param_names` keys) and returns an enzyme rate.
- `data::DataFrame`: DataFrame containing the data with column `Rate` and columns for each `metab_names` where each row is one measurement. It also needs to have a column `source` that contains a string that identifies the source of the data. This is used to calculate the weights for each figure in the publication.
- `metab_names::Tuple`: Tuple of metabolite names that correspond to the metabolites of `rate_equation` and column names in `data`.
- `param_names::Tuple`: Tuple of parameter names that correspond to the parameters of `rate_equation`.
- `n_iter::Int`: Number of iterations to run the fitting process.
# Returns
- `loss::Float64`: Loss of the best fit.
- `params::NamedTuple`: Best fit parameters with `param_names` keys
# Example
```julia
using DataFrames
data = DataFrame(
Rate = [1.0, 2.0, 3.0],
A = [1.0, 2.0, 3.0],
source = ["Figure 1", "Figure 1", "Figure 2"]
)
rate_equation(metabs, params) = params.Vmax * metabs.S / (1 + metabs.S / params.K_S)
fit_rate_equation(rate_equation, data, (:A,), (:Vmax, :K_S))
```
"""
function fit_rate_equation(
rate_equation::Function,
Expand All @@ -34,7 +57,6 @@ function fit_rate_equation(
return (loss = train_results[1], params = NamedTuple{param_names}(rescaled_params))
end


function train_rate_equation(
rate_equation::Function,
data::DataFrame,
Expand Down

0 comments on commit 3c452f7

Please sign in to comment.