petab.parameter_mapping

Functions related to mapping parameter from model to parameter estimation problem

Functions

get_optimization_to_simulation_parameter_mapping(...)

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

get_parameter_mapping_for_condition(...[, ...])

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

handle_missing_overrides(...[, warn, ...])

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

merge_preeq_and_sim_pars(parameter_mappings, ...)

Merge preequilibration and simulation parameters and scales for a list of conditions while checking for compatibility.

merge_preeq_and_sim_pars_condition(...)

Merge preequilibration and simulation parameters and scales for a single condition while checking for compatibility.

petab.parameter_mapping.get_optimization_to_simulation_parameter_mapping(condition_df: DataFrame, measurement_df: DataFrame, parameter_df: DataFrame | None = None, observable_df: DataFrame | None = None, mapping_df: DataFrame | None = None, sbml_model: Model | None = None, simulation_conditions: DataFrame | None = None, warn_unmapped: bool | None = True, scaled_parameters: bool = False, fill_fixed_parameters: bool = True, allow_timepoint_specific_numeric_noise_parameters: bool = False, model: Model | None = None) List[Tuple[Dict[str, str | Number], Dict[str, str | Number], Dict[str, str], Dict[str, str]]][source]

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

Mapping can be performed in parallel. The number of threads is controlled by the environment variable with the name of petab.ENV_NUM_THREADS.

Parameters:
  • condition_df – The dataframes in the PEtab format.

  • measurement_df – The dataframes in the PEtab format.

  • parameter_df – The dataframes in the PEtab format.

  • observable_df – The dataframes in the PEtab format.

  • sbml_model – The SBML model (deprecated)

  • model – The model.

  • simulation_conditions – Table of simulation conditions as created by petab.get_simulation_conditions.

  • warn_unmapped – If True, log warning regarding unmapped parameters

  • scaled_parameters – Whether parameter values should be scaled.

  • fill_fixed_parameters – Whether to fill in nominal values for fixed parameters (estimate=0 in parameters table).

  • allow_timepoint_specific_numeric_noise_parameters – Mapping of timepoint-specific parameters overrides is generally not supported. If this option is set to True, this function will not fail in case of timepoint-specific fixed noise parameters, if the noise formula consists only of one single parameter. It is expected that the respective mapping is performed elsewhere. The value mapped to the respective parameter here is undefined.

Returns:

Parameter value and parameter scale mapping for all conditions.

The length of the returned array is the number of unique combinations of simulationConditionId s and preequilibrationConditionId s from the measurement table. Each entry is a tuple of four dicts of length equal to the number of model parameters. The first two dicts map simulation parameter IDs to optimization parameter IDs or values (where values are fixed) for preequilibration and simulation condition, respectively. The last two dicts map simulation parameter IDs to the parameter scale of the respective parameter, again for preequilibration and simulation condition. If no preequilibration condition is defined, the respective dicts will be empty. NaN is used where no mapping exists.

petab.parameter_mapping.get_parameter_mapping_for_condition(condition_id: str, is_preeq: bool, cur_measurement_df: DataFrame | None, sbml_model: Model | None = None, condition_df: DataFrame | None = None, parameter_df: DataFrame | None = None, mapping_df: DataFrame | None = None, simulation_parameters: Dict[str, str] | None = None, warn_unmapped: bool = True, scaled_parameters: bool = False, fill_fixed_parameters: bool = True, allow_timepoint_specific_numeric_noise_parameters: bool = False, model: Model | None = None) Tuple[Dict[str, str | Number], Dict[str, str]][source]

Create dictionary of parameter value and parameter scale 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, can be None if not relevant for parameter mapping

  • condition_df – PEtab condition DataFrame

  • parameter_df – PEtab parameter DataFrame

  • mapping_df – PEtab mapping DataFrame

  • sbml_model – The SBML model (deprecated)

  • model – The model.

  • simulation_parameters – Model simulation parameter IDs mapped to parameter values (output of petab.sbml.get_model_parameters(.., with_values=True)). Optional, saves time if precomputed.

  • warn_unmapped – If True, log warning regarding unmapped parameters

  • scaled_parameters – Whether parameter values should be scaled.

  • fill_fixed_parameters – Whether to fill in nominal values for fixed parameters (estimate=0 in parameters table).

  • allow_timepoint_specific_numeric_noise_parameters – Mapping of timepoint-specific parameters overrides is generally not supported. If this option is set to True, this function will not fail in case of timepoint-specific fixed noise parameters, if the noise formula consists only of one single parameter. It is expected that the respective mapping is performed elsewhere. The value mapped to the respective parameter here is undefined.

Returns:

Tuple of two dictionaries. First dictionary mapping model parameter IDs to mapped parameters IDs to be estimated or to filled-in values in case of non-estimated parameters. Second dictionary mapping model parameter IDs to their scale. NaN is used where no mapping exists.

petab.parameter_mapping.handle_missing_overrides(mapping_par_opt_to_par_sim: Dict[str, str | Number], warn: bool = True, condition_id: str | None = None) None[source]

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

Assumes that parameters matching the regular expression (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

  • condition_id – Optional condition ID for more informative output

petab.parameter_mapping.merge_preeq_and_sim_pars(parameter_mappings: Iterable[Tuple[Dict[str, str | Number], Dict[str, str | Number]]], scale_mappings: Iterable[Tuple[Dict[str, str], Dict[str, str]]]) Tuple[List[Tuple[Dict[str, str | Number], Dict[str, str | Number]]], List[Tuple[Dict[str, str], Dict[str, str]]]][source]

Merge preequilibration and simulation parameters and scales for a list of conditions while checking for compatibility.

Parameters:
Returns:

The parameter and scale simulation mappings, modified and checked.

petab.parameter_mapping.merge_preeq_and_sim_pars_condition(condition_map_preeq: Dict[str, str | Number], condition_map_sim: Dict[str, str | Number], condition_scale_map_preeq: Dict[str, str], condition_scale_map_sim: Dict[str, str], condition: Any) None[source]

Merge preequilibration and simulation parameters and scales for a single condition 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 be modified in place.

Parameters: