amici.petab_objective¶
PEtab Objective¶
Functionality related to running simulations or evaluating the objective function as defined by a PEtab problem
Functions Summary
|
Aggregate likelihood gradient for all conditions, according to PEtab parameter mapping. |
|
Get |
|
Create list of |
|
Generate AMICI specific parameter mapping. |
Generate AMICI specific parameter mapping for condition. |
|
|
Create list of :class:amici.ExpData objects with parameters filled in. |
|
Create a measurement dataframe in the PEtab format from the passed rdatas and own information. |
|
Create a PEtab simulation dataframe from amici.ReturnDatas. |
|
Simulate PEtab model. |
|
Get subset of dictionary based on provided keys |
Functions
-
amici.petab_objective.
aggregate_sllh
(amici_model, rdatas, parameter_mapping)[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 (
typing.Sequence
[amici.numpy.ReturnDataView
]) – Simulation results.parameter_mapping (
typing.Optional
[amici.parameter_mapping.ParameterMapping
]) –- PEtab parameter mapping to condition-specific
simulation parameters
- Return type
- Returns
aggregated sllh
-
amici.petab_objective.
create_edata_for_condition
(condition, amici_model, petab_problem, observable_ids)[source]¶ Get
amici.amici.ExpData
for the given PEtab condition.Sets timepoints, observed data and sigmas.
- Parameters
condition (
typing.Union
[typing.Dict
,pandas.core.series.Series
]) – pandas.DataFrame row with preequilibrationConditionId and simulationConditionId.amici_model (
typing.Union
[amici.amici.Model
,amici.amici.ModelPtr
]) – AMICI modelpetab_problem (
petab.problem.Problem
) – Underlying PEtab problemobservable_ids (
typing.List
[str
]) – List of observable IDs
- Return type
- Returns
ExpData instance.
-
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
,typing.Dict
,None
]) – Result of petab.get_simulation_conditions. Can be provided to save time if this has be obtained before.
- Return type
- 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)[source]¶ Generate AMICI specific parameter mapping.
- Parameters
petab_problem (
petab.problem.Problem
) – PEtab problemsimulation_conditions (
typing.Union
[pandas.core.frame.DataFrame
,typing.Dict
]) – Result of petab.get_simulation_conditions. Can be provided to save time if this has been obtained before.scaled_parameters (
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.amici_model (
typing.Union
[amici.amici.Model
,amici.amici.ModelPtr
]) – AMICI model.
- Return type
- Returns
List of the parameter mappings.
-
amici.petab_objective.
create_parameter_mapping_for_condition
(parameter_mapping_for_condition, condition, petab_problem, amici_model)[source]¶ Generate AMICI specific parameter mapping for condition.
- Parameters
parameter_mapping_for_condition (
typing.Tuple
[typing.Dict
[str
,typing.Union
[str
,numbers.Number
]],typing.Dict
[str
,typing.Union
[str
,numbers.Number
]],typing.Dict
[str
,str
],typing.Dict
[str
,str
]]) – Preliminary parameter mapping for condition.condition (
typing.Union
[pandas.core.series.Series
,typing.Dict
]) – pandas.DataFrame row with preequilibrationConditionId and simulationConditionId.petab_problem (
petab.problem.Problem
) – Underlying PEtab problem.amici_model (
typing.Union
[amici.amici.Model
,amici.amici.ModelPtr
]) – AMICI model.
- Return type
- Returns
The parameter and parameter scale mappings, for fixed preequilibration, fixed simulation, and variable simulation parameters, and then the respective scalings.
-
amici.petab_objective.
create_parameterized_edatas
(amici_model, petab_problem, problem_parameters, scaled_parameters=False, parameter_mapping=None, simulation_conditions=None)[source]¶ Create list of :class:amici.ExpData objects with parameters filled in.
- Parameters
amici_model (
typing.Union
[amici.amici.Model
,amici.amici.ModelPtr
]) – AMICI Model assumed to be compatible withpetab_problem
.petab_problem (
petab.problem.Problem
) – PEtab problem to work on.problem_parameters (
typing.Dict
[str
,numbers.Number
]) – Run simulation with these parameters. If None, PEtab nominalValues will be used). To be provided as dict, mapping PEtab problem parameters to SBML IDs.scaled_parameters (
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.parameter_mapping (
typing.Optional
[amici.parameter_mapping.ParameterMapping
]) – Optional precomputed PEtab parameter mapping for efficiency, as generated by create_parameter_mapping.simulation_conditions (
typing.Union
[pandas.core.frame.DataFrame
,typing.Dict
,None
]) – Result of petab.get_simulation_conditions. Can be provided to save time if this has been obtained before.
- Return type
- Returns
List with one
amici.amici.ExpData
per simulation condition, with filled in timepoints, data and parameters.
-
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 (
typing.Sequence
[amici.amici.ReturnData
]) – A sequence of rdatas with the ordering of petab.get_simulation_conditions.model (
typing.Union
[amici.amici.Model
,amici.amici.ModelPtr
]) – AMICI model used to generate rdatas.measurement_df (
pandas.core.frame.DataFrame
) – PEtab measurement table used to generate rdatas.
- Return type
pandas.core.frame.DataFrame
- 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.ReturnDatas.
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_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)[source]¶ Simulate PEtab model.
- 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
[typing.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
,typing.Dict
,None
]) – 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 (
typing.Optional
[typing.List
[typing.Union
[amici.amici.ExpData
,amici.amici.ExpDataPtr
]]]) – Experimental data. Parameters are inserted in-place for simulation.parameter_mapping (
typing.Optional
[amici.parameter_mapping.ParameterMapping
]) – Optional precomputed PEtab parameter mapping for efficiency, as generated by create_parameter_mapping.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.log_level (
int
) – Log level, seeamici.logging
module.
- Return type
- Returns
Dictionary of
cost function value (LLH),
const function sensitivity w.r.t. parameters (SLLH), (NOTE: Sensitivities are computed for the scaled parameters)
list of ReturnData (RDATAS),
corresponding to the different simulation conditions. For ordering of simulation conditions, see
petab.Problem.get_simulation_conditions_from_measurement_df()
.
-
amici.petab_objective.
subset_dict
(full, *args)[source]¶ Get subset of dictionary based on provided keys
- Parameters
full (
typing.Dict
[typing.Any
,typing.Any
]) – Dictionary to subsetargs (
typing.Collection
[typing.Any
]) – Collections of keys to be contained in the different subsets
- Return type
- Returns
subsetted dictionary