petab.v1.parameter_mapping
Functions related to mapping parameter from model to parameter estimation problem
Functions
Create list of mapping dicts from PEtab-problem to model parameters. |
|
|
Create dictionary of parameter value and parameter scale mappings from PEtab-problem to SBML parameters for the given condition. |
|
Find all observable parameters and noise parameters that were not mapped and set their mapping to np.nan. |
|
Merge preequilibration and simulation parameters and scales for a list of conditions while checking for compatibility. |
Merge preequilibration and simulation parameters and scales for a single condition while checking for compatibility. |
- petab.v1.parameter_mapping.ParMappingDictQuadruple
alias of
tuple
[dict
[str
,str
|Number
],dict
[str
,str
|Number
],dict
[str
,str
],dict
[str
,str
]]
- petab.v1.parameter_mapping.ParMappingDictTuple
alias of
tuple
[dict
[str
,str
|Number
],dict
[str
,str
|Number
]]
- petab.v1.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 parametersscaled_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 andpreequilibrationConditionId
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.v1.parameter_mapping.get_parameter_mapping_for_condition(condition_id: str, is_preeq: bool, cur_measurement_df: DataFrame | None = 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 mappedcur_measurement_df – Measurement sub-table for current condition, can be
None
if not relevant for parameter mappingcondition_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 parametersscaled_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.v1.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.v1.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:
parameter_mappings – As returned by
petab.get_optimization_to_simulation_parameter_mapping()
.scale_mappings – As returned by
petab.get_optimization_to_simulation_parameter_mapping()
.
- Returns:
The parameter and scale simulation mappings, modified and checked.
- petab.v1.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
andcondition_scale_map_sim
will be modified in place.- Parameters:
condition_map_preeq – Parameter mapping as obtained from
get_parameter_mapping_for_condition()
condition_map_sim – Parameter mapping as obtained from
get_parameter_mapping_for_condition()
condition_scale_map_preeq – Parameter scale mapping as obtained from
get_parameter_mapping_for_condition()
condition_scale_map_sim – Parameter scale mapping as obtained from
get_parameter_mapping_for_condition()
condition – Condition identifier for more informative error messages