Skip to content

Commit

Permalink
fix: remove reject_non_steady flag (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
carrascomj authored Oct 18, 2023
1 parent 8a8be49 commit 152b460
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 18 deletions.
3 changes: 1 addition & 2 deletions docs/inputting.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ The file `config.toml` **must** contain these top-level fields:

The following optional fields can also be specified:

* `reject_non_steady` Boolean saying whether to reject draws that enter non-steady states
* `penalize_non_steady` Boolean saying whether to penalize steady state deviations in the likelihood. It cannot be `True` when `reject_non_steady` is `True`.
* `penalize_non_steady` Boolean saying whether to penalize steady state deviations in the likelihood.
* `ode_solver_config` Table of configuration options for Stan's ode solver
* `algebra_solver_config` Table of configuration options for Stan's algebra solver
* `cmdstanpy_config` Table of keyword arguments to the cmdstanpy method [`CmdStanModel.sample](https://cmdstanpy.readthedocs.io/en/v1.1.0/api.html#cmdstanpy.CmdStanModel.sample)
Expand Down
2 changes: 1 addition & 1 deletion maud/data/example_inputs/linear/expected_stan_input.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"N_mic": 4, "N_edge_sub": 3, "N_edge_prod": 3, "N_edge": 3, "N_unbalanced": 2, "N_enzyme": 3, "N_phosphorylation": 0, "N_pme": 0, "N_competitive_inhibition": 1, "N_allostery": 2, "N_allosteric_enzyme": 2, "N_drain": 0, "N_km": 5, "N_sub_km": 3, "N_prod_km": 2, "S": [[-1, 0, 0], [1, -1, 0], [0, 1, -1], [0, 0, 1]], "N_reaction": 3, "N_metabolite": 2, "balanced_mic_ix": [2, 3], "unbalanced_mic_ix": [1, 4], "ci_mic_ix": [2], "edge_type": [1, 2, 1], "edge_to_enzyme": [1, 2, 3], "edge_to_tc": [1, 2, 0], "edge_to_drain": [0, 0, 0], "edge_to_reaction": [1, 2, 3], "water_stoichiometry": [0.0, 0.0, 0.0], "transported_charge": [0.0, 0.0, 1.0], "mic_to_met": [1, 1, 2, 2], "subunits": [1, 1, 1], "sub_by_edge_long": [1, 2, 3], "sub_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "prod_by_edge_long": [2, 3, 4], "prod_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "sub_km_ix_by_edge_long": [1, 3, 4], "sub_km_ix_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "prod_km_ix_by_edge_long": [2, 5], "prod_km_ix_by_edge_bounds": [[1, 1], [2, 1], [2, 2]], "ci_ix_long": [1], "ci_ix_bounds": [[1, 0], [1, 1], [2, 1]], "allostery_ix_long": [1, 2], "allostery_ix_bounds": [[1, 1], [2, 2], [3, 2]], "allostery_type": [1, 2], "allostery_mic": [3, 2], "phosphorylation_ix_long": [], "phosphorylation_ix_bounds": [[1, 0], [1, 0], [1, 0]], "phosphorylation_type": [], "phosphorylation_pme": [], "priors_km": [[0.0, 0.0, 0.0, 0.0, 0.0], [0.6, 0.6, 0.6, 0.6, 0.6]], "priors_ki": [[0.0], [0.6]], "priors_kcat": [[0.0, 0.0, 0.0], [0.6, 0.6, 0.6]], "priors_dissociation_constant": [[0.0, 0.0], [0.6, 0.6]], "priors_transfer_constant": [[0.0, 0.0], [0.6, 0.6]], "priors_kcat_pme": [[], []], "priors_drain_train": [[[]], [[]]], "priors_conc_enzyme_train": [[[0.5, 0.5, 0.5], [0.5, 0.5, 0.5]], [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0]]], "priors_conc_unbalanced_train": [[[-2.3, -2.3], [-2.3, -2.3]], [[2.0, 2.0], [2.0, 2.0]]], "priors_conc_pme_train": [[[]], [[]]], "priors_psi_train": [[-0.95, -0.95], [0.2, 0.2]], "prior_loc_dgf": [-1.0, -2.0], "prior_cov_dgf": [[0.05, 0.0], [0.0, 0.05]], "N_experiment_train": 2, "N_flux_measurement_train": 2, "N_enzyme_measurement_train": 6, "N_conc_measurement_train": 7, "N_enzyme_knockout_train": 0, "N_pme_knockout_train": 0, "temperature_train": [299.0, 298.15], "enzyme_knockout_train_long": [], "enzyme_knockout_train_bounds": [[1, 0], [1, 0]], "pme_knockout_train_long": [], "pme_knockout_train_bounds": [[1, 0], [1, 0]], "yconc_train": [0.59, 1.09, 1.05, 0.54, 0.38, 1.12, 1.14], "sigma_yconc_train": [0.1, 0.05, 0.05, 0.1, 0.1, 0.05, 0.05], "experiment_yconc_train": [1, 1, 1, 2, 2, 2, 2], "mic_ix_yconc_train": [2, 1, 4, 2, 3, 1, 4], "yflux_train": [0.19, 0.39], "sigma_yflux_train": [0.1, 0.1], "experiment_yflux_train": [1, 2], "reaction_yflux_train": [3, 3], "yenz_train": [1.5, 1.5, 1.5, 1.5, 1.5, 1.5], "sigma_yenz_train": [0.1, 0.1, 0.1, 0.1, 0.1, 0.1], "experiment_yenz_train": [1, 1, 1, 2, 2, 2], "enzyme_yenz_train": [1, 2, 3, 1, 2, 3], "likelihood": 1, "drain_small_conc_corrector": 1e-06, "reject_non_steady": 1, "penalize_non_steady": 0, "steady_state_threshold_abs": 1e-06, "steady_state_threshold_rel": 0.001, "steady_state_penalty_rel": 1e-08, "rel_tol_ode": 1e-07, "abs_tol_ode": 1e-07, "max_num_steps_ode": 1000000, "rel_tol_alg": 1e-05, "abs_tol_alg": 1e-05, "max_num_steps_alg": 1000000, "conc_init": [[0.59, 0.38], [0.54, 0.38]]}
{"N_mic": 4, "N_edge_sub": 3, "N_edge_prod": 3, "N_edge": 3, "N_unbalanced": 2, "N_enzyme": 3, "N_phosphorylation": 0, "N_pme": 0, "N_competitive_inhibition": 1, "N_allostery": 2, "N_allosteric_enzyme": 2, "N_drain": 0, "N_km": 5, "N_sub_km": 3, "N_prod_km": 2, "S": [[-1, 0, 0], [1, -1, 0], [0, 1, -1], [0, 0, 1]], "N_reaction": 3, "N_metabolite": 2, "balanced_mic_ix": [2, 3], "unbalanced_mic_ix": [1, 4], "ci_mic_ix": [2], "edge_type": [1, 2, 1], "edge_to_enzyme": [1, 2, 3], "edge_to_tc": [1, 2, 0], "edge_to_drain": [0, 0, 0], "edge_to_reaction": [1, 2, 3], "water_stoichiometry": [0.0, 0.0, 0.0], "transported_charge": [0.0, 0.0, 1.0], "mic_to_met": [1, 1, 2, 2], "subunits": [1, 1, 1], "sub_by_edge_long": [1, 2, 3], "sub_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "prod_by_edge_long": [2, 3, 4], "prod_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "sub_km_ix_by_edge_long": [1, 3, 4], "sub_km_ix_by_edge_bounds": [[1, 1], [2, 2], [3, 3]], "prod_km_ix_by_edge_long": [2, 5], "prod_km_ix_by_edge_bounds": [[1, 1], [2, 1], [2, 2]], "ci_ix_long": [1], "ci_ix_bounds": [[1, 0], [1, 1], [2, 1]], "allostery_ix_long": [1, 2], "allostery_ix_bounds": [[1, 1], [2, 2], [3, 2]], "allostery_type": [1, 2], "allostery_mic": [3, 2], "phosphorylation_ix_long": [], "phosphorylation_ix_bounds": [[1, 0], [1, 0], [1, 0]], "phosphorylation_type": [], "phosphorylation_pme": [], "priors_km": [[0.0, 0.0, 0.0, 0.0, 0.0], [0.6, 0.6, 0.6, 0.6, 0.6]], "priors_ki": [[0.0], [0.6]], "priors_kcat": [[0.0, 0.0, 0.0], [0.6, 0.6, 0.6]], "priors_dissociation_constant": [[0.0, 0.0], [0.6, 0.6]], "priors_transfer_constant": [[0.0, 0.0], [0.6, 0.6]], "priors_kcat_pme": [[], []], "priors_drain_train": [[[]], [[]]], "priors_conc_enzyme_train": [[[0.5, 0.5, 0.5], [0.5, 0.5, 0.5]], [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0]]], "priors_conc_unbalanced_train": [[[-2.3, -2.3], [-2.3, -2.3]], [[2.0, 2.0], [2.0, 2.0]]], "priors_conc_pme_train": [[[]], [[]]], "priors_psi_train": [[-0.95, -0.95], [0.2, 0.2]], "prior_loc_dgf": [-1.0, -2.0], "prior_cov_dgf": [[0.05, 0.0], [0.0, 0.05]], "N_experiment_train": 2, "N_flux_measurement_train": 2, "N_enzyme_measurement_train": 6, "N_conc_measurement_train": 7, "N_enzyme_knockout_train": 0, "N_pme_knockout_train": 0, "temperature_train": [299.0, 298.15], "enzyme_knockout_train_long": [], "enzyme_knockout_train_bounds": [[1, 0], [1, 0]], "pme_knockout_train_long": [], "pme_knockout_train_bounds": [[1, 0], [1, 0]], "yconc_train": [0.59, 1.09, 1.05, 0.54, 0.38, 1.12, 1.14], "sigma_yconc_train": [0.1, 0.05, 0.05, 0.1, 0.1, 0.05, 0.05], "experiment_yconc_train": [1, 1, 1, 2, 2, 2, 2], "mic_ix_yconc_train": [2, 1, 4, 2, 3, 1, 4], "yflux_train": [0.19, 0.39], "sigma_yflux_train": [0.1, 0.1], "experiment_yflux_train": [1, 2], "reaction_yflux_train": [3, 3], "yenz_train": [1.5, 1.5, 1.5, 1.5, 1.5, 1.5], "sigma_yenz_train": [0.1, 0.1, 0.1, 0.1, 0.1, 0.1], "experiment_yenz_train": [1, 1, 1, 2, 2, 2], "enzyme_yenz_train": [1, 2, 3, 1, 2, 3], "likelihood": 1, "drain_small_conc_corrector": 1e-06, "penalize_non_steady": 0, "steady_state_threshold_abs": 1e-06, "steady_state_threshold_rel": 0.001, "steady_state_penalty_rel": 1e-08, "rel_tol_ode": 1e-07, "abs_tol_ode": 1e-07, "max_num_steps_ode": 1000000, "rel_tol_alg": 1e-05, "abs_tol_alg": 1e-05, "max_num_steps_alg": 1000000, "conc_init": [[0.59, 0.38], [0.54, 0.38]]}
1 change: 0 additions & 1 deletion maud/data/example_inputs/methionine/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ priors_file = "priors.toml"
experiments_file = "experiments.toml"
user_inits_file = "inits.toml"
likelihood = true
reject_non_steady = true

[cmdstanpy_config]
iter_warmup = 1000
Expand Down
13 changes: 1 addition & 12 deletions maud/data_model/maud_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Optional

from pydantic import BaseModel, ConfigDict, Field, model_validator
from pydantic import BaseModel, ConfigDict, Field


class ODESolverConfig(BaseModel):
Expand Down Expand Up @@ -32,7 +32,6 @@ class MaudConfig(BaseModel):
:param experiments_file: path to a valid experiments file.
:param likelihood: Whether or not to take measurements into account.
:param cmdstanpy_config: Arguments to cmdstanpy.CmdStanModel.sample.
:param reject_non_steady: Reject draws if a non-steady state is encountered.
:param penalize_non_steady: Penalize the deviation from steady state in the log likelihood.
:param ode_solver_config: Configuration for Stan's ode solver.
:param algebra_solver_config: Configuration for Stan's algebra solver.
Expand Down Expand Up @@ -67,7 +66,6 @@ class MaudConfig(BaseModel):
algebra_solver_config: AlgebraSolverConfig = Field(
default_factory=AlgebraSolverConfig
)
reject_non_steady: bool = True
penalize_non_steady: bool = False
steady_state_threshold_abs: float = 1e-8
steady_state_threshold_rel: float = 1e-3
Expand All @@ -76,12 +74,3 @@ class MaudConfig(BaseModel):
drain_small_conc_corrector: float = 1e-6
molecule_unit: str = "mmol"
volume_unit: str = "L"

@model_validator(mode="after")
def do_not_penalize_if_rejecting(self):
"""Check that locations are non-null."""
assert not self.penalize_non_steady and self.reject_non_steady, (
"Penalizing the non-steady state has no effect if the non-steady"
" state is rejected; set one of the two to false."
)
return self
1 change: 0 additions & 1 deletion maud/getting_stan_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ def get_config_input(config: MaudConfig):
return {
"likelihood": int(config.likelihood),
"drain_small_conc_corrector": config.drain_small_conc_corrector,
"reject_non_steady": int(config.reject_non_steady),
"penalize_non_steady": int(config.penalize_non_steady),
"steady_state_threshold_abs": config.steady_state_threshold_abs,
"steady_state_threshold_rel": config.steady_state_threshold_rel,
Expand Down
1 change: 0 additions & 1 deletion maud/stan/model.stan
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ data {
real steady_state_penalty_rel;
int<lower=0, upper=1> likelihood; // set to 0 for priors-only mode
real drain_small_conc_corrector;
int<lower=0, upper=1> reject_non_steady;
int<lower=0, upper=1> penalize_non_steady;
}
transformed data {
Expand Down

0 comments on commit 152b460

Please sign in to comment.