petab.parameter_mapping

Functions related to mapping parameter from model to parameter estimation problem

Functions

fill_in_nominal_values(mapping, Union[str, …) Replace non-estimated parameters in mapping list for a given condition by nominalValues provided in parameter table.
get_optimization_to_simulation_parameter_mapping(…) Create list of mapping dicts from PEtab-problem to SBML parameters.
get_optimization_to_simulation_scale_mapping(…) Get parameter scale mapping for all conditions
get_parameter_mapping_for_condition(…) Create dictionary of mappings from PEtab-problem to SBML parameters for the given condition.
get_scale_mapping_for_condition(…) Get parameter scale mapping for the given condition.
handle_missing_overrides(…) Find all observable parameters and noise parameters that were not mapped and set their mapping to np.nan.
merge_preeq_and_sim_pars_condition(…) Merge preequilibration and simulation parameters and scales while checking for compatibility.
perform_mapping_checks(measurement_df)
petab.parameter_mapping._apply_dynamic_parameter_overrides(mapping: Dict[str, Union[str, numbers.Number]], condition_id: str, condition_df: pandas.core.frame.DataFrame) → None

Apply dynamic parameter overrides from condition table (in-place).

Parameters:
  • par_sim_id_to_ix (mapping,) – see get_parameter_mapping_for_condition
  • condition_df – PEtab condition and parameter table
petab.parameter_mapping._apply_output_parameter_overrides(mapping: Dict[str, Union[str, numbers.Number]], cur_measurement_df: pandas.core.frame.DataFrame) → None

Apply output parameter overrides to the parameter mapping dict for a given condition as defined in the measurement table (observableParameter, noiseParameters).

Parameters:
  • mapping – parameter mapping dict
  • cur_measurement_df – Subset of the measurement table for the current condition
petab.parameter_mapping._apply_overrides_for_observable(mapping: Dict[str, Union[str, numbers.Number]], observable_id: str, override_type: str, overrides: list) → None

Apply parameter-overrides for observables and noises to mapping matrix.

Parameters:
  • mapping – mapping dict to which to apply overrides
  • observable_id – observable ID
  • override_type – ‘observable’ or ‘noise’
  • overrides – list of overrides for noise or observable parameters
petab.parameter_mapping.fill_in_nominal_values(mapping: Dict[str, Union[str, numbers.Number]], parameter_df: pandas.core.frame.DataFrame) → None

Replace non-estimated parameters in mapping list for a given condition by nominalValues provided in parameter table.

Parameters:
  • mapping – mapping dict obtained from get_parameter_mapping_for_condition
  • parameter_df – PEtab parameter table
petab.parameter_mapping.get_optimization_to_simulation_parameter_mapping(condition_df: pandas.core.frame.DataFrame, measurement_df: pandas.core.frame.DataFrame, parameter_df: pandas.core.frame.DataFrame = None, sbml_model: libsbml.Model = None, simulation_conditions=None, warn_unmapped: bool = True) → List[Tuple[Dict[str, Union[str, numbers.Number]], Dict[str, Union[str, numbers.Number]]]]

Create list of mapping dicts from PEtab-problem to SBML parameters.

Parameters:
  • measurement_df, parameter_df (condition_df,) –

    The dataframes in the PEtab format.

    parameter_df is optional if par_sim_ids is provided

  • sbml_model – The sbml model with observables and noise specified according to the petab format. Optional if par_sim_ids is provided.
  • simulation_conditions (pd.DataFrame) – Table of simulation conditions as created by petab.get_simulation_conditions.
  • warn_unmapped – If True, log warning regarding unmapped parameters
Returns:

  • The length of the returned array is n_conditions, each entry is a tuple of
  • two dicts of length n_par_sim, listing the optimization parameters or
  • constants to be mapped to the simulation parameters, first for
  • preequilibration (empty if no preequilibration condition is specified),
  • second for simulation. NaN is used where no mapping exists.

petab.parameter_mapping.get_optimization_to_simulation_scale_mapping(parameter_df: pandas.core.frame.DataFrame, mapping_par_opt_to_par_sim: List[Tuple[Dict[str, Union[str, numbers.Number]], Dict[str, Union[str, numbers.Number]]]], measurement_df: pandas.core.frame.DataFrame, simulation_conditions: Union[dict, pandas.core.frame.DataFrame] = None) → List[Tuple[Dict[str, str], Dict[str, str]]]

Get parameter scale mapping for all conditions

petab.parameter_mapping.get_parameter_mapping_for_condition(condition_id: str, is_preeq: bool, cur_measurement_df: pandas.core.frame.DataFrame, condition_df: pandas.core.frame.DataFrame, parameter_df: pandas.core.frame.DataFrame = None, sbml_model: libsbml.Model = None, warn_unmapped: bool = True) → Dict[str, Union[str, numbers.Number]]

Create dictionary of mappings from PEtab-problem to SBML parameters for the given condition.

Parameters:
  • condition_id (Condition ID for which to perform mapping) –
  • is_preeq (If true, output parameters will not be mapped) –
  • cur_measurement_df (Measurement sub-table for current condition) –
  • parameter_df (condition_df,) – The dataframes in the PEtab format. parameter_df is optional if par_sim_ids is provided
  • sbml_model – The sbml model with observables and noise specified according to the petab format. Optional if par_sim_ids is provided.
  • warn_unmapped – If True, log warning regarding unmapped parameters
Returns:

  • Dictionary of parameter IDs with mapped parameters IDs to be estimated or
  • filled in values in case of non-estimated parameters. NaN is used where no
  • mapping exists.

petab.parameter_mapping.get_scale_mapping_for_condition(parameter_df: pandas.core.frame.DataFrame, mapping_par_opt_to_par_sim: Dict[str, Union[str, numbers.Number]]) → Dict[str, str]

Get parameter scale mapping for the given condition.

Parameters:
  • parameter_df – PEtab parameter table
  • mapping_par_opt_to_par_sim – Mapping as obtained from get_parameter_mapping_for_condition
petab.parameter_mapping.handle_missing_overrides(mapping_par_opt_to_par_sim: Dict[str, Union[str, numbers.Number]], warn: bool = True, condition_id: str = None) → None

Find all observable parameters and noise parameters that were not mapped and set their mapping to np.nan.

Assumes that parameters matching “(noise|observable)Parameter[0-9]+_” were all supposed to be overwritten.

Parameters:
  • mapping_par_opt_to_par_sim – Output of get_parameter_mapping_for_condition
  • warn – If True, log warning regarding unmapped parameters
petab.parameter_mapping.merge_preeq_and_sim_pars_condition(condition_map_preeq: Dict[str, Union[str, numbers.Number]], condition_map_sim: Dict[str, Union[str, numbers.Number]], condition_scale_map_preeq: Dict[str, str], condition_scale_map_sim: Dict[str, str], condition: Any) → None

Merge preequilibration and simulation parameters and scales while checking for compatibility.

This function is meant for the case where we cannot have different parameters (and scales) for preequilibration and simulation. Therefore, merge both and ensure matching scales and parameters. condition_map_sim and condition_scale_map_sim will ne modified in place.

Parameters:
  • condition_map_sim (condition_map_preeq,) – Parameter mapping as obtained from get_parameter_mapping_for_condition
  • condition_scale_map_sim (condition_scale_map_preeq,) – Parameter scale mapping as obtained from get_get_scale_mapping_for_condition
  • condition – Condition identifier for more informative error messages