amici.petab

PEtab import related code.

amici.petab.import_petab_problem(petab_problem, model_output_dir=None, model_name=None, compile_=None, non_estimated_parameters_as_constants=True, **kwargs)[source]

Create an AMICI model for a PEtab problem.

Parameters:
  • petab_problem (petab.problem.Problem) – A petab problem containing all relevant information on the model.

  • model_output_dir (typing.Union[str, pathlib.Path, None]) – Directory to write the model code to. It will be created if it doesn’t exist. Defaults to current directory.

  • model_name (str) – Name of the generated model module. Defaults to the ID of the model or the model file name without the extension.

  • compile – If True, the model will be compiled. If False, the model will not be compiled. If None, the model will be compiled if it cannot be imported.

  • non_estimated_parameters_as_constants – Whether parameters marked as non-estimated in PEtab should be considered constant in AMICI. Setting this to True will reduce model size and simulation times. If sensitivities with respect to those parameters are required, this should be set to False.

  • kwargs – Additional keyword arguments to be passed to amici.sbml_import.SbmlImporter.sbml2amici() or amici.pysb_import.pysb2amici(), depending on the model type.

Return type:

amici.amici.Model

Returns:

The imported model.

amici.petab.rdatas_to_measurement_df(rdatas, model, measurement_df)[source]

Create a measurement dataframe in the PEtab format from the passed rdatas and own information.

Parameters:
Return type:

pandas.core.frame.DataFrame

Returns:

A dataframe built from the rdatas in the format of measurement_df.

amici.petab.rdatas_to_simulation_df(rdatas, model, measurement_df)[source]

Create a PEtab simulation dataframe from amici.amici.ReturnData s.

See rdatas_to_measurement_df() for details, only that model outputs will appear in column simulation instead of measurement.

Return type:

pandas.core.frame.DataFrame

amici.petab.simulate_petab(petab_problem, amici_model, solver=None, problem_parameters=None, simulation_conditions=None, edatas=None, parameter_mapping=None, scaled_parameters=False, log_level=30, num_threads=1, failfast=True, scaled_gradients=False)[source]

Simulate PEtab model.

Note

Regardless of scaled_parameters, unscaled sensitivities are returned, unless scaled_gradients=True.

Parameters:
  • petab_problem (petab.problem.Problem) – PEtab problem to work on.

  • amici_model (typing.Union[amici.amici.Model, amici.amici.ModelPtr]) – AMICI Model assumed to be compatible with petab_problem.

  • solver (typing.Optional[amici.amici.Solver]) – An AMICI solver. Will use default options if None.

  • problem_parameters (typing.Optional[dict[str, float]]) – Run simulation with these parameters. If None, PEtab nominalValues will be used. To be provided as dict, mapping PEtab problem parameters to SBML IDs.

  • simulation_conditions (typing.Union[pandas.core.frame.DataFrame, dict]) – Result of petab.get_simulation_conditions(). Can be provided to save time if this has be obtained before. Not required if edatas and parameter_mapping are provided.

  • edatas (list[typing.Union[amici.swig_wrappers.ExpData, amici.amici.ExpDataPtr]]) – Experimental data. Parameters are inserted in-place for simulation.

  • parameter_mapping (amici.petab.parameter_mapping.ParameterMapping) – Optional precomputed PEtab parameter mapping for efficiency, as generated by create_parameter_mapping() with scaled_parameters=True.

  • scaled_parameters (typing.Optional[bool]) – If True, problem_parameters are assumed to be on the scale provided in the PEtab parameter table and will be unscaled. If False, they are assumed to be in linear scale. If parameter_mapping is provided, this must match the value of scaled_parameters used to generate the mapping.

  • log_level (int) – Log level, see amici.logging module.

  • num_threads (int) – Number of threads to use for simulating multiple conditions (only used if compiled with OpenMP).

  • failfast (bool) – Returns as soon as an integration failure is encountered, skipping any remaining simulations.

  • scaled_gradients (bool) – Whether to compute gradients on parameter scale (True) or not (False).

Return type:

dict[str, typing.Any]

Returns:

Dictionary of

corresponding to the different simulation conditions. For ordering of simulation conditions, see petab.Problem.get_simulation_conditions_from_measurement_df().