amici.petab_objective
Evaluate a PEtab objective function.
Deprecated since version 0.21.0: Use amici.petab.simulations
instead.
- amici.petab_objective.aggregate_sllh(amici_model, rdatas, parameter_mapping, edatas, petab_scale=True, petab_problem=None)[source]
Aggregate likelihood gradient for all conditions, according to PEtab parameter mapping.
- Parameters:
amici_model (
typing.Union
[amici.amici.Model
,amici.amici.ModelPtr
]) – AMICI model from whichrdatas
were obtained.rdatas (
collections.abc.Sequence
[amici.numpy.ReturnDataView
]) – Simulation results.parameter_mapping (
typing.Optional
[amici.petab.parameter_mapping.ParameterMapping
]) – PEtab parameter mapping to condition-specific simulation parameters.edatas (
list
[typing.Union
[amici.swig_wrappers.ExpData
,amici.amici.ExpDataPtr
]]) – Experimental data used for simulation.petab_scale (
bool
) – Whether to check that sensitivities were computed with parameters on the scales provided in the PEtab parameters table.petab_problem (
petab.problem.Problem
) – The PEtab problem that defines the parameter scales.
- Return type:
- Returns:
Aggregated likelihood sensitivities.
- amici.petab_objective.create_edatas(amici_model, petab_problem, simulation_conditions=None)[source]
Create list of
amici.amici.ExpData
objects for PEtab problem.- Parameters:
amici_model (
typing.Union
[amici.amici.Model
,amici.amici.ModelPtr
]) – AMICI model.petab_problem (
petab.problem.Problem
) – Underlying PEtab problem.simulation_conditions (
typing.Union
[pandas.core.frame.DataFrame
,dict
]) – Result ofpetab.get_simulation_conditions()
. Can be provided to save time if this has be obtained before.
- Return type:
list
[amici.swig_wrappers.ExpData
]- Returns:
List with one
amici.amici.ExpData
per simulation condition, with filled in timepoints and data.
- amici.petab_objective.create_parameter_mapping(petab_problem, simulation_conditions, scaled_parameters, amici_model, **parameter_mapping_kwargs)[source]
Generate AMICI specific parameter mapping.
- Parameters:
petab_problem (
petab.problem.Problem
) – PEtab problemsimulation_conditions (
pandas.core.frame.DataFrame
|list
[dict
]) – Result ofpetab.get_simulation_conditions()
. Can be provided to save time if this has been obtained before.scaled_parameters (
bool
) – IfTrue
, problem_parameters are assumed to be on the scale provided in the PEtab parameter table and will be unscaled. IfFalse
, they are assumed to be in linear scale.amici_model (
typing.Union
[amici.amici.Model
,amici.amici.ModelPtr
]) – AMICI model.parameter_mapping_kwargs – Optional keyword arguments passed to
petab.get_optimization_to_simulation_parameter_mapping()
. To allow changing fixed PEtab problem parameters (estimate=0
), usefill_fixed_parameters=False
.
- Return type:
- Returns:
List of the parameter mappings.
- amici.petab_objective.fill_in_parameters(edatas, problem_parameters, scaled_parameters, parameter_mapping, amici_model)[source]
Fill fixed and dynamic parameters into the edatas (in-place).
- Parameters:
edatas (
list
[amici.swig_wrappers.ExpData
]) – List of experimental datasamici.amici.ExpData
with everything except parameters filled.problem_parameters (
dict
[str
,numbers.Number
]) – Problem parameters as parameterId=>value dict. Only parameters included here will be set. Remaining parameters will be used as currently set in amici_model.scaled_parameters (
bool
) – If True, problem_parameters are assumed to be on the scale provided in the parameter mapping. If False, they are assumed to be in linear scale.parameter_mapping (
amici.petab.parameter_mapping.ParameterMapping
) – Parameter mapping for all conditions.amici_model (
typing.Union
[amici.amici.Model
,amici.amici.ModelPtr
]) – AMICI model.
- Return type:
- amici.petab_objective.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:
rdatas (
collections.abc.Sequence
[amici.amici.ReturnData
]) – A sequence of rdatas with the ordering ofpetab.get_simulation_conditions()
.model (
typing.Union
[amici.amici.Model
,amici.amici.ModelPtr
]) – AMICI model used to generaterdatas
.measurement_df (
pandas.core.frame.DataFrame
) – PEtab measurement table used to generaterdatas
.
- Return type:
- Returns:
A dataframe built from the rdatas in the format of
measurement_df
.
- amici.petab_objective.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 columnsimulation
instead ofmeasurement
.- Return type:
- amici.petab_objective.rescale_sensitivity(sensitivity, parameter_value, old_scale, new_scale)[source]
Rescale a sensitivity between parameter scales.
- Parameters:
- Return type:
- Returns:
The rescaled sensitivity.
- amici.petab_objective.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 withpetab_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. IfNone
, PEtabnominalValues
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 ofpetab.get_simulation_conditions()
. Can be provided to save time if this has be obtained before. Not required ifedatas
andparameter_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 bycreate_parameter_mapping()
withscaled_parameters=True
.scaled_parameters (
typing.Optional
[bool
]) – IfTrue
,problem_parameters
are assumed to be on the scale provided in the PEtab parameter table and will be unscaled. IfFalse
, 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, seeamici.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:
- Returns:
Dictionary of
cost function value (
LLH
),list of
amici.amici.ReturnData
(RDATAS
),list of
amici.amici.ExpData
(EDATAS
),
corresponding to the different simulation conditions. For ordering of simulation conditions, see
petab.Problem.get_simulation_conditions_from_measurement_df()
.