Skip to content

Commit

Permalink
Merge pull request #2457 from dweindl/release_0.25.2
Browse files Browse the repository at this point in the history
Release 0.25.2
  • Loading branch information
dweindl authored Jun 16, 2024
2 parents 17d6e77 + 6da397a commit 88a5454
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 94 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

## v0.X Series

### v0.25.2 (2024-06-16)

**Fixes**

* Fixed a bug in PEtab import which led to incorrect gradients
*w.r.t. estimated initial values specified via the condition table*
**BREAKING CHANGE**:
`amici.petab.sbml_import.{import_model_sbml,import_model}` no longer supports
passing individual PEtab tables, but only the PEtab problem object.
This functionality was deprecated since v0.12.0 (2022-08-26).
* Fixes for numpy 2.0 compatibility
**NOTE**: As long as some amici dependencies don't support numpy 2.0 yet,
you may need to pin numpy to <2.0 in your requirements
(`pip install amici "numpy<2.0"`).

**Full Changelog**: https://github.com/AMICI-dev/AMICI/compare/v0.25.1...v0.25.2

### v0.25.1 (2024-05-16)

**Fixes**
Expand Down
46 changes: 36 additions & 10 deletions documentation/amici_refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -1196,16 +1196,6 @@ @Article{TunedalVio2023
url = {https://physoc.onlinelibrary.wiley.com/doi/abs/10.1113/JP284652},
}
@Unknown{HasenauerMer2023,
author = {Hasenauer, Jan and Merkt, Simon and Ali, Solomon and Gudina, Esayas and Adissu, Wondimagegn and Münchhoff, Maximilian and Graf, Alexander and Krebs, Stefan and Elsbernd, Kira and Kisch, Rebecca and Sirgu, Sisay and Fantahun, Bereket and Bekele, Delayehu and Rubio-Acero, Raquel and Gashaw, Mulatu and Girma, Eyob and Yilma, Daniel and Zeynudin, Ahmed and Paunovic, Ivana and Wieser, Andreas},
creationdate = {2023-09-19T09:21:01},
doi = {10.21203/rs.3.rs-3307821/v1},
modificationdate = {2023-09-19T09:21:01},
month = {09},
title = {Long-term monitoring of SARS-CoV-2 seroprevalence and variants in Ethiopia provides prediction for immunity and cross-immunity},
year = {2023},
}
@Article{RaimundezFed2023,
author = {Elba Raim{\'{u}}ndez and Michael Fedders and Jan Hasenauer},
journal = {{iScience}},
Expand Down Expand Up @@ -1306,6 +1296,42 @@ @Article{DoresicGre2024
url = {https://www.biorxiv.org/content/early/2024/01/30/2024.01.26.577371},
}
@Article{MerktAli2024,
author = {Merkt, Simon and Ali, Solomon and Gudina, Esayas Kebede and Adissu, Wondimagegn and Gize, Addisu and Muenchhoff, Maximilian and Graf, Alexander and Krebs, Stefan and Elsbernd, Kira and Kisch, Rebecca and Betizazu, Sisay Sirgu and Fantahun, Bereket and Bekele, Delayehu and Rubio-Acero, Raquel and Gashaw, Mulatu and Girma, Eyob and Yilma, Daniel and Zeynudin, Ahmed and Paunovic, Ivana and Hoelscher, Michael and Blum, Helmut and Hasenauer, Jan and Kroidl, Arne and Wieser, Andreas},
journal = {Nature Communications},
title = {Long-term monitoring of SARS-CoV-2 seroprevalence and variants in Ethiopia provides prediction for immunity and cross-immunity},
year = {2024},
issn = {2041-1723},
month = apr,
number = {1},
volume = {15},
creationdate = {2024-04-29T08:30:06},
doi = {10.1038/s41467-024-47556-2},
modificationdate = {2024-04-29T08:30:06},
publisher = {Springer Science and Business Media LLC},
}
@Misc{LakrisenkoPat2024,
author = {Polina Lakrisenko and Dilan Pathirana and Daniel Weindl and Jan Hasenauer},
title = {Exploration of methods for computing sensitivities in ODE models at dynamic and steady states},
year = {2024},
archiveprefix = {arXiv},
creationdate = {2024-05-30T09:48:00},
eprint = {2405.16524},
modificationdate = {2024-05-30T09:48:00},
primaryclass = {q-bio.QM},
}
@PhdThesis{Mutsuddy2024,
author = {Mutsuddy, Arnab},
school = {Clemson University},
title = {Single cell pharmacodynamic modeling of cancer cell lines},
year = {2024},
creationdate = {2024-05-30T09:51:58},
modificationdate = {2024-05-30T09:53:40},
url = {https://tigerprints.clemson.edu/all_dissertations/3572},
}
@Comment{jabref-meta: databaseType:bibtex;}
@Comment{jabref-meta: grouping:
Expand Down
10 changes: 6 additions & 4 deletions documentation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,19 @@ def install_mtocpp():

def install_doxygen():
"""Get a more recent doxygen"""
version = "1.9.7"
version = "1.11.0"
release = f"Release_{version.replace('.', '_')}"
filename = f"doxygen-{version}.linux.bin.tar.gz"
doxygen_exe = os.path.join(
amici_dir, "ThirdParty", f"doxygen-{version}", "bin", "doxygen"
)
# to create a symlink to doxygen in a location that is already on PATH
some_dir_on_path = os.environ["PATH"].split(os.pathsep)[0]
cmd = (
f"cd '{os.path.join(amici_dir, 'ThirdParty')}' "
f"&& wget 'https://www.doxygen.nl/files/"
f"doxygen-{version}.linux.bin.tar.gz' "
f"&& tar -xzf doxygen-{version}.linux.bin.tar.gz "
f"&& wget 'https://github.com/doxygen/doxygen/releases/download/"
f"{release}/{filename}' "
f"&& tar -xzf '{filename}' "
f"&& ln -sf '{doxygen_exe}' '{some_dir_on_path}'"
)
subprocess.run(cmd, shell=True, check=True)
Expand Down
28 changes: 20 additions & 8 deletions documentation/references.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# References

List of publications using AMICI. Total number is 85.
List of publications using AMICI. Total number is 87.

If you applied AMICI in your work and your publication is missing, please let us know via a new GitHub issue.

Expand Down Expand Up @@ -29,13 +29,32 @@ complex</span>.”</span> <em>Nucleic Acids Research</em>, February,
gkae123. <a
href="https://doi.org/10.1093/nar/gkae123">https://doi.org/10.1093/nar/gkae123</a>.
</div>
<div id="ref-LakrisenkoPat2024" class="csl-entry" role="listitem">
Lakrisenko, Polina, Dilan Pathirana, Daniel Weindl, and Jan Hasenauer.
2024. <span>“Exploration of Methods for Computing Sensitivities in ODE
Models at Dynamic and Steady States.”</span> <a
href="https://arxiv.org/abs/2405.16524">https://arxiv.org/abs/2405.16524</a>.
</div>
<div id="ref-LangPen2024" class="csl-entry" role="listitem">
Lang, Paul F., David R. Penas, Julio R. Banga, Daniel Weindl, and Bela
Novak. 2024. <span>“Reusable Rule-Based Cell Cycle Model Explains
Compartment-Resolved Dynamics of 16 Observables in RPE-1 Cells.”</span>
<em>PLOS Computational Biology</em> 20 (1): 1–24. <a
href="https://doi.org/10.1371/journal.pcbi.1011151">https://doi.org/10.1371/journal.pcbi.1011151</a>.
</div>
<div id="ref-MerktAli2024" class="csl-entry" role="listitem">
Merkt, Simon, Solomon Ali, Esayas Kebede Gudina, Wondimagegn Adissu,
Addisu Gize, Maximilian Muenchhoff, Alexander Graf, et al. 2024.
<span>“Long-Term Monitoring of SARS-CoV-2 Seroprevalence and Variants in
Ethiopia Provides Prediction for Immunity and Cross-Immunity.”</span>
<em>Nature Communications</em> 15 (1). <a
href="https://doi.org/10.1038/s41467-024-47556-2">https://doi.org/10.1038/s41467-024-47556-2</a>.
</div>
<div id="ref-Mutsuddy2024" class="csl-entry" role="listitem">
Mutsuddy, Arnab. 2024. <span>“Single Cell Pharmacodynamic Modeling of
Cancer Cell Lines.”</span> PhD thesis, Clemson University. <a
href="https://tigerprints.clemson.edu/all_dissertations/3572">https://tigerprints.clemson.edu/all_dissertations/3572</a>.
</div>
<div id="ref-SluijsZho2024" class="csl-entry" role="listitem">
Sluijs, Bob van, Tao Zhou, Britta Helwig, Mathieu G. Baltussen, Frank H.
T. Nelissen, Hans A. Heus, and Wilhelm T. S. Huck. 2024.
Expand Down Expand Up @@ -84,13 +103,6 @@ Rewiring Contribute to Drug Resistance.”</span> <em>Molecular Systems
Biology</em> 19 (2): e10988. <a
href="https://doi.org/10.15252/msb.202210988">https://doi.org/10.15252/msb.202210988</a>.
</div>
<div id="ref-HasenauerMer2023" class="csl-entry" role="listitem">
Hasenauer, Jan, Simon Merkt, Solomon Ali, Esayas Gudina, Wondimagegn
Adissu, Maximilian Münchhoff, Alexander Graf, et al. 2023.
<span>“Long-Term Monitoring of SARS-CoV-2 Seroprevalence and Variants in
Ethiopia Provides Prediction for Immunity and Cross-Immunity.”</span> <a
href="https://doi.org/10.21203/rs.3.rs-3307821/v1">https://doi.org/10.21203/rs.3.rs-3307821/v1</a>.
</div>
<div id="ref-HuckBal2023" class="csl-entry" role="listitem">
Huck, Wilhelm, Mathieu Baltussen, Thijs de Jong, Quentin Duez, and
William Robinson. 2023. <span>“Chemical Reservoir Computation in a
Expand Down
1 change: 1 addition & 0 deletions documentation/rtd_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ git+https://github.com/readthedocs/readthedocs-sphinx-ext
ipykernel
-e git+https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab.git@master#subdirectory=src/python&egg=benchmark_models_petab
-e python/sdist/
numpy<2.0
5 changes: 1 addition & 4 deletions python/sdist/amici/petab/cli/import_petab.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ def _main():

import_model_sbml(
model_name=args.model_name,
sbml_model=pp.sbml_model,
condition_table=pp.condition_df,
observable_table=pp.observable_df,
measurement_table=pp.measurement_df,
petab_problem=pp,
model_output_dir=args.model_output_dir,
compile=args.compile,
generate_sensitivity_code=args.generate_sensitivity_code,
Expand Down
3 changes: 2 additions & 1 deletion python/sdist/amici/petab/import_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,10 @@ def get_fixed_parameters(
# check global parameters
if not petab_problem.model.has_entity_with_id(fixed_parameter):
# TODO: could still exist as an output parameter?
# TODO: or in the parameters table
logger.warning(
f"Column '{fixed_parameter}' used in condition "
"table but not entity with the corresponding ID "
"table but no entity with the corresponding ID "
"exists. Ignoring."
)
fixed_parameters.remove(fixed_parameter)
Expand Down
112 changes: 60 additions & 52 deletions python/sdist/amici/petab/sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
from itertools import chain
from pathlib import Path
from typing import Union
from warnings import warn

import amici
import libsbml
import pandas as pd
import petab
import sympy as sp
from _collections import OrderedDict
Expand All @@ -31,9 +29,6 @@
@log_execution_time("Importing PEtab model", logger)
def import_model_sbml(
sbml_model: Union[str, Path, "libsbml.Model"] = None,
condition_table: str | Path | pd.DataFrame | None = None,
observable_table: str | Path | pd.DataFrame | None = None,
measurement_table: str | Path | pd.DataFrame | None = None,
petab_problem: petab.Problem = None,
model_name: str | None = None,
model_output_dir: str | Path | None = None,
Expand All @@ -52,18 +47,6 @@ def import_model_sbml(
PEtab SBML model or SBML file name.
Deprecated, pass ``petab_problem`` instead.
:param condition_table:
PEtab condition table. If provided, parameters from there will be
turned into AMICI constant parameters (i.e. parameters w.r.t. which
no sensitivities will be computed).
Deprecated, pass ``petab_problem`` instead.
:param observable_table:
PEtab observable table. Deprecated, pass ``petab_problem`` instead.
:param measurement_table:
PEtab measurement table. Deprecated, pass ``petab_problem`` instead.
:param petab_problem:
PEtab problem.
Expand Down Expand Up @@ -113,30 +96,6 @@ def import_model_sbml(

logger.info("Importing model ...")

if any([sbml_model, condition_table, observable_table, measurement_table]):
warn(
"The `sbml_model`, `condition_table`, `observable_table`, and "
"`measurement_table` arguments are deprecated and will be "
"removed in a future version. Use `petab_problem` instead.",
DeprecationWarning,
stacklevel=2,
)
if petab_problem:
raise ValueError(
"Must not pass a `petab_problem` argument in "
"combination with any of `sbml_model`, "
"`condition_table`, `observable_table`, or "
"`measurement_table`."
)

petab_problem = petab.Problem(
model=SbmlModel(sbml_model)
if isinstance(sbml_model, libsbml.Model)
else SbmlModel.from_file(sbml_model),
condition_df=petab.get_condition_df(condition_table),
observable_df=petab.get_observable_df(observable_table),
)

if petab_problem.observable_df is None:
raise NotImplementedError(
"PEtab import without observables table "
Expand Down Expand Up @@ -264,12 +223,50 @@ def import_model_sbml(
# feels dirty and should be changed (see also #924)
# <BeginWorkAround>

# state variable IDs and initial values specified via the conditions' table
initial_states = get_states_in_condition_table(petab_problem)
# is there any condition that involves preequilibration?
requires_preequilibration = (
petab_problem.measurement_df is not None
and petab.PREEQUILIBRATION_CONDITION_ID in petab_problem.measurement_df
and petab_problem.measurement_df[petab.PREEQUILIBRATION_CONDITION_ID]
.notnull()
.any()
)
estimated_parameters_ids = petab_problem.get_x_ids(free=True, fixed=False)
# any initial states overridden to be estimated via the conditions table?
has_estimated_initial_states = any(
par_id in petab_problem.condition_df[initial_states.keys()].values
for par_id in estimated_parameters_ids
)

if (
has_estimated_initial_states
and requires_preequilibration
and kwargs.setdefault("generate_sensitivity_code", True)
):
# To support reinitialization of initial conditions after
# preequilibration we need fixed parameters for the initial
# conditions. If we need sensitivities w.r.t. to initial conditions,
# we need to create non-fixed parameters for the initial conditions.
# We can't have both for the same state variable.
# (We could handle it via separate amici models if pre-equilibration
# and estimation of initial values for a given state variable are
# used in separate PEtab conditions.)
# We currently assume that we do need sensitivities w.r.t. initial
# conditions if sensitivities are needed at all.
# TODO: check this state by state, then we can support some additional
# cases
raise NotImplementedError(
"PEtab problems that have both, estimated initial conditions "
"specified in the condition table, and preequilibration with "
"initial conditions specified in the condition table are not "
"supported."
)

fixed_parameters = []
if initial_states:
if initial_states and requires_preequilibration:
# add preequilibration indicator variable
# NOTE: would only be required if we actually have preequilibration
# adding it anyways. can be optimized-out later
if sbml_model.getParameter(PREEQ_INDICATOR_ID) is not None:
raise AssertionError(
"Model already has a parameter with ID "
Expand All @@ -286,11 +283,15 @@ def import_model_sbml(
"Adding preequilibration indicator "
f"constant {PREEQ_INDICATOR_ID}"
)
logger.debug(f"Adding initial assignments for {initial_states.keys()}")
logger.debug(
f"Adding initial assignments for {list(initial_states.keys())}"
)
for assignee_id in initial_states:
init_par_id_preeq = f"initial_{assignee_id}_preeq"
init_par_id_sim = f"initial_{assignee_id}_sim"
for init_par_id in [init_par_id_preeq, init_par_id_sim]:
for init_par_id in (
[init_par_id_preeq] if requires_preequilibration else []
) + [init_par_id_sim]:
if sbml_model.getElementBySId(init_par_id) is not None:
raise ValueError(
"Cannot create parameter for initial assignment "
Expand All @@ -300,8 +301,12 @@ def import_model_sbml(
init_par = sbml_model.createParameter()
init_par.setId(init_par_id)
init_par.setName(init_par_id)
# must be a fixed parameter in any case to allow reinitialization
fixed_parameters.append(init_par_id)
if requires_preequilibration:
# must be a fixed parameter to allow reinitialization
# TODO: also add other initial condition parameters that are
# not estimated
fixed_parameters.append(init_par_id)

assignment = sbml_model.getInitialAssignment(assignee_id)
if assignment is None:
assignment = sbml_model.createInitialAssignment()
Expand All @@ -315,10 +320,13 @@ def import_model_sbml(
"be overwritten to handle preequilibration and "
"initial values specified by the PEtab problem."
)
formula = (
f"{PREEQ_INDICATOR_ID} * {init_par_id_preeq} "
f"+ (1 - {PREEQ_INDICATOR_ID}) * {init_par_id_sim}"
)
if requires_preequilibration:
formula = (
f"{PREEQ_INDICATOR_ID} * {init_par_id_preeq} "
f"+ (1 - {PREEQ_INDICATOR_ID}) * {init_par_id_sim}"
)
else:
formula = init_par_id_sim
math_ast = libsbml.parseL3Formula(formula)
assignment.setMath(math_ast)
# <EndWorkAround>
Expand Down
8 changes: 1 addition & 7 deletions python/sdist/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
requires = [
"setuptools>=61",
"wheel",
# oldest-supported-numpy helps us to pin numpy here to the lowest supported
# version to have ABI-compatibility with the numpy version in the runtime
# environment. The undesirable alternative would be pinning the setup.py
# numpy requirement to the same version as here, which we want to avoid.
# cf. discussion at https://github.com/numpy/numpy/issues/5888
# (https://github.com/scipy/oldest-supported-numpy/)
"oldest-supported-numpy",
"numpy>=2.0",
"cmake-build-extension==0.6.0",
]
build-backend = "setuptools.build_meta"
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_preequilibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def preeq_fixture(pysb_example_presimulation_module):

edata_preeq = amici.ExpData(edata)
edata_preeq.t_presim = 0
edata_preeq.setTimepoints([np.infty])
edata_preeq.setTimepoints([np.inf])
edata_preeq.fixedParameters = edata.fixedParametersPreequilibration
edata_preeq.fixedParametersPresimulation = ()
edata_preeq.fixedParametersPreequilibration = ()
Expand Down
Loading

0 comments on commit 88a5454

Please sign in to comment.