Skip to content

Commit

Permalink
Merge branch 'main' into conserved_moieties
Browse files Browse the repository at this point in the history
  • Loading branch information
carrascomj committed Jun 21, 2024
2 parents 836cf33 + 9747fe6 commit 1203fd2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion maud/data/example_inputs/example_ode/input_data_train.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"N_mic": 9, "N_pool": 1, "N_edge_sub": 10, "N_edge_prod": 9, "N_edge": 8, "N_unbalanced": 3, "N_independent": 5, "N_dependent": 1, "N_enzyme": 8, "N_er": 8, "N_phosphorylation": 0, "N_pme": 0, "N_competitive_inhibition": 1, "N_allostery": 2, "N_allosteric_enzyme": 2, "N_drain": 0, "N_km": 19, "N_sub_km": 10, "N_prod_km": 9, "S": [[1, 0, -1, -1, -1, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, -1, 0, 0], [0, 0, 0, 1, 1, 0, -1, 0], [0, -1, 0, 0, 0, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1, 0, 1], [0, 0, 0, 0, 0, 1, 0, -1], [0, 0, 0, 0, 0, 0, 0, -1]], "left_nullspace_independent": [[0.0, 0.0, 0.0, 0.0, 1.0]], "N_reaction": 7, "N_metabolite": 7, "independent_bal_ix": [1, 3, 4, 5, 7], "dependent_bal_ix": [8], "unbalanced_mic_ix": [2, 6, 9], "ci_mic_ix": [5], "edge_type": [1, 1, 1, 1, 1, 1, 1, 1], "edge_to_enzyme": [1, 2, 4, 5, 6, 7, 8, 3], "edge_to_er": [1, 2, 3, 4, 5, 6, 7, 8], "edge_to_tc": [0, 0, 0, 1, 2, 0, 0, 0], "edge_to_drain": [0, 0, 0, 0, 0, 0, 0, 0], "edge_to_reaction": [1, 2, 4, 5, 5, 6, 7, 3], "water_stoichiometry": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "transported_charge": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "mic_to_met": [1, 1, 2, 3, 4, 4, 5, 6, 7], "subunits": [1, 1, 1, 1, 1, 1, 1, 1], "sub_by_edge_long": [2, 5, 1, 1, 1, 7, 3, 4, 9, 8], "sub_by_edge_bounds": [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 7], [8, 8], [9, 10]], "prod_by_edge_long": [1, 6, 3, 4, 4, 5, 8, 5, 7], "prod_by_edge_bounds": [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 7], [8, 8], [9, 9]], "sub_km_ix_by_edge_long": [1, 3, 5, 7, 9, 11, 12, 15, 17, 18], "sub_km_ix_by_edge_bounds": [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 7], [8, 8], [9, 10]], "prod_km_ix_by_edge_long": [2, 4, 6, 8, 10, 13, 14, 16, 19], "prod_km_ix_by_edge_bounds": [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 7], [8, 8], [9, 9]], "ci_ix_long": [1], "ci_ix_bounds": [[1, 0], [1, 0], [1, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1]], "allostery_ix_long": [1, 2], "allostery_ix_bounds": [[1, 0], [1, 0], [1, 0], [1, 1], [2, 2], [3, 2], [3, 2], [3, 2]], "allostery_type": [1, 2], "allostery_mic": [4, 4], "phosphorylation_ix_long": [], "phosphorylation_ix_bounds": [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]], "phosphorylation_type": [], "phosphorylation_pme": [], "N_dgf_fixed": 0, "dgf_fixed": [], "ix_dgf_free": [1, 2, 3, 4, 5, 6, 7], "ix_dgf_fixed": [], "priors_km": [[0.0, 0.0, 0.0, 0.0, -0.6931471805599453, 0.0, 0.6931471805599453, -0.6931471805599453, 0.0, 0.6931471805599453, -4.605170185988091, -0.6931471805599453, 0.6931471805599453, -0.6931471805599453, 0.0, 1.0986122886681098, -2.3025850929940455, -4.605170185988091, 0.0], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]], "priors_ki": [[0.0], [1.0]], "priors_kcat": [[-0.6931471805599453, 0.6931471805599453, -0.6931471805599453, 0.6931471805599453, 0.0, 0.6931471805599453, 0.0, 1.3862943611198906], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]], "priors_dissociation_constant": [[-1.2039728043259361, -0.10536051565782628], [1.0, 1.0]], "priors_transfer_constant": [[0.0, 0.0], [1.0, 1.0]], "priors_kcat_pme": [[], []], "priors_drain_train": [[[]], [[]]], "priors_conc_enzyme_train": [[[0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.6931471805599453, -0.6931471805599453, 1.3862943611198906, 0.6931471805599453], [0.0, 0.0, 0.0, -0.916290731874155, -1.2039728043259361, 0.4054651081081644, -1.6094379124341003, -0.35667494393873245], [0.0, 0.0, 0.0, 0.7419373447293773, 0.26236426446749106, -0.6931471805599453, 0.6931471805599453, 0.0], [0.0, 0.0, 0.0, 0.09531017980432493, 0.8754687373538999, 0.1823215567939546, 1.9459101490553132, -0.6931471805599453]], [[1.0, 1.0, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]]], "priors_conc_moiety_pool_train": [[[0.6931471805599453], [0.6931471805599453], [0.6931471805599453], [0.6931471805599453], [0.6931471805599453]], [[0.1], [0.1], [0.1], [0.1], [0.1]]], "priors_conc_unbalanced_train": [[[1.6094379124341003, -0.6931471805599453, -2.3], [1.6094379124341003, -0.6931471805599453, -2.3], [1.6094379124341003, -0.6931471805599453, -2.3], [1.6094379124341003, -0.6931471805599453, -2.3], [1.6094379124341003, -0.6931471805599453, -2.3]], [[0.1, 0.1, 2.0], [0.1, 0.1, 2.0], [0.1, 0.1, 2.0], [0.1, 0.1, 2.0], [0.1, 0.1, 2.0]]], "priors_conc_pme_train": [[[]], [[]]], "priors_psi_train": [[0.0, 0.0, 0.0, 0.0, 0.0], [2.0, 2.0, 2.0, 2.0, 2.0]], "prior_loc_dgf": [10.0, 2.0, 5.0, 0.0, 1.0, 0.0, 5.0], "prior_cov_dgf": [[0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.2, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.2, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2]], "N_experiment_train": 5, "N_flux_measurement_train": 10, "N_enzyme_measurement_train": 0, "N_conc_measurement_train": 10, "N_enzyme_knockout_train": 0, "N_pme_knockout_train": 0, "temperature_train": [298.0, 298.0, 298.0, 298.0, 298.0], "enzyme_knockout_train_long": [], "enzyme_knockout_train_bounds": [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0]], "pme_knockout_train_long": [], "pme_knockout_train_bounds": [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0]], "yconc_train": [0.447, 3.76, 0.271, 2.44, 0.798, 4.69, 0.461, 3.5, 0.252, 12.0], "sigma_yconc_train": [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], "experiment_yconc_train": [1, 1, 2, 2, 3, 3, 4, 4, 5, 5], "mic_ix_yconc_train": [3, 4, 3, 4, 3, 4, 3, 4, 3, 4], "yflux_train": [0.417, 0.75, 0.423, 1.31, 0.161, 0.553, 0.875, 0.736, 0.467, 0.453], "sigma_yflux_train": [0.042, 0.075, 0.042, 0.13, 0.016, 0.055, 0.088, 0.074, 0.047, 0.045], "experiment_yflux_train": [1, 1, 2, 2, 3, 3, 4, 4, 5, 5], "reaction_yflux_train": [6, 7, 6, 7, 6, 7, 6, 7, 6, 7], "yenz_train": [], "sigma_yenz_train": [], "experiment_yenz_train": [], "enzyme_yenz_train": [], "likelihood": 1, "drain_small_conc_corrector": 1e-06, "penalize_non_steady": 0, "steady_state_threshold_abs": 1e-08, "steady_state_threshold_rel": 0.001, "steady_state_penalty_abs": 1e-12, "rel_tol_ode": 1e-09, "abs_tol_ode": 1e-09, "timepoint": 10000.0, "max_num_steps_ode": 10000000, "rel_tol_alg": 1e-07, "abs_tol_alg": 1e-07, "max_num_steps_alg": 1000000, "conc_init": [[0.01, 0.47275786614291254, 3.6276714294434105, 0.01, 0.5], [0.01, 0.28513154858766504, 2.4698178070456938, 0.01, 0.5], [0.01, 0.7989993742175272, 4.694997337592429, 0.01, 0.5], [0.01, 0.48010415536631224, 3.5, 0.01, 0.5], [0.01, 0.2749545416973504, 12.0, 0.01, 0.5]]}
com
6 changes: 6 additions & 0 deletions maud/data/example_inputs/linear/expected_stan_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"N_edge": 3,
"N_unbalanced": 2,
"N_enzyme": 3,
"N_er": 3,
"N_phosphorylation": 0,
"N_pme": 0,
"N_competitive_inhibition": 1,
Expand Down Expand Up @@ -59,6 +60,11 @@
2,
3
],
"edge_to_er": [
1,
2,
3
],
"edge_to_tc": [
1,
2,
Expand Down
4 changes: 2 additions & 2 deletions maud/getting_stan_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def get_network_properties_input(
enzyme_codes[er.enzyme_id] if isinstance(er, EnzymeReaction) else 0
for er in edges
]
edge_er_code = [
edge_er_codes = [
er_codes[er.id] if isinstance(er, EnzymeReaction) else 0 for er in edges
]
edge_drain_code = [
Expand Down Expand Up @@ -383,7 +383,7 @@ def get_network_properties_input(
"ci_mic_ix": ci_mic_codes,
"edge_type": edge_mechanism_code,
"edge_to_enzyme": edge_enzyme_code,
"edge_to_er": edge_er_code,
"edge_to_er": edge_er_codes,
"edge_to_tc": edge_tc_code,
"edge_to_drain": edge_drain_code,
"edge_to_reaction": edge_reaction_code,
Expand Down
9 changes: 5 additions & 4 deletions maud/stan/functions.stan
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ functions {
array[] int phosphorylation_type,
array[] int phosphorylation_pme) {
int N_edge = cols(S);
vector[N_edge] vmax = get_vmax_by_edge(enzyme, kcat, edge_to_enzyme, edge_to_er,
edge_type);
vector[N_edge] vmax = get_vmax_by_edge(enzyme, kcat, edge_to_enzyme,
edge_to_er, edge_type);
vector[N_edge] reversibility = get_reversibility(dgr, temperature, S,
conc, edge_type);
vector[N_edge] free_enzyme_ratio = get_free_enzyme_ratio(conc, S, km, ki,
Expand Down Expand Up @@ -514,7 +514,8 @@ functions {
}

complex_vector get_complex_vmax_by_edge(complex_vector enzyme, vector kcat,
array[] int edge_to_enzyme, array[] int edge_to_er,
array[] int edge_to_enzyme,
array[] int edge_to_er,
array[] int edge_type) {
int N_edge = size(edge_to_enzyme);
complex_vector[N_edge] out = rep_vector(1, N_edge);
Expand Down Expand Up @@ -817,7 +818,7 @@ vector maud_ae_system(vector conc_ind,
vector conc_pme, vector drain, real temperature,
real drain_small_conc_corrector, matrix S,
vector subunits, array[] int edge_type,
array[] int edge_to_enzyme, array[] into edge_to_er, array[] int edge_to_drain,
array[] int edge_to_enzyme, array[] int edge_to_er, array[] int edge_to_drain,
array[] int ci_mic_ix,
array[] int sub_km_ix_by_edge_long,
array[,] int sub_km_ix_by_edge_bounds,
Expand Down
3 changes: 2 additions & 1 deletion maud/stan/model.stan
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data {
array[N_competitive_inhibition] int<lower=1, upper=N_mic> ci_mic_ix;
array[N_edge] int<lower=1, upper=3> edge_type; // 1 = reversible modular rate law, 2 = drain
array[N_edge] int<lower=0, upper=N_enzyme> edge_to_enzyme; // 0 if drain
array[N_edge] int<lower=0, upper=N_enzyme> edge_to_er; // 0 if drain
array[N_edge] int<lower=0, upper=N_er> edge_to_er; // 0 if drain
array[N_edge] int<lower=0, upper=N_allostery> edge_to_tc; // 0 if non-allosteric
array[N_edge] int<lower=0, upper=N_drain> edge_to_drain; // 0 if enzyme
array[N_edge] int<lower=0, upper=N_reaction> edge_to_reaction;
Expand Down Expand Up @@ -242,6 +242,7 @@ transformed parameters {
conc_train[e, independent_bal_ix] = conc_independent_balanced_experiment;
conc_train[e, dependent_bal_ix] = conc_moiety_pool_experiment - left_nullspace_independent * conc_independent_balanced_experiment;
conc_train[e, unbalanced_mic_ix] = conc_unbalanced_experiment;

{
vector[N_edge] edge_flux = get_edge_flux(conc_train[e],
conc_enzyme_experiment,
Expand Down
2 changes: 1 addition & 1 deletion maud/stan/out_of_sample_model.stan
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ data {
int<lower=1> N_sub_km;
int<lower=1> N_prod_km;
int<lower=1> N_reaction;
int<lower=1> N_er; // enzyme reactions
int<lower=1> N_enzyme;
int<lower=1> N_er;
int<lower=0> N_drain;
int<lower=1> N_edge;
int<lower=0> N_allostery;
Expand Down

0 comments on commit 1203fd2

Please sign in to comment.