petab.core¶
PEtab core functions
Functions
create_condition_df (parameter_ids, condition_ids) |
Create empty condition dataframe |
create_measurement_df () |
Create empty measurement dataframe |
create_parameter_df (sbml_model, …) |
Create a new PEtab parameter table |
flatten_timepoint_specific_output_overrides (…) |
If the PEtab problem definition has timepoint-specific observableParameters or noiseParameters for the same observable, replace those by replicating the respective observable. |
get_condition_df (condition_file_name) |
Read the provided condition file into a pandas.Dataframe |
get_default_condition_file_name (model_name, …) |
Get file name according to proposed convention |
get_default_measurement_file_name (…) |
Get file name according to proposed convention |
get_default_parameter_file_name (model_name, …) |
Get file name according to proposed convention |
get_default_sbml_file_name (model_name, folder) |
Get file name according to proposed convention |
get_measurement_df (measurement_file_name) |
Read the provided measurement file into a pandas.Dataframe. |
get_measurement_parameter_ids (measurement_df) |
Return list of ID of parameters which occur in measurement table as observable or noise parameter overrides. |
get_model_parameters (sbml_model) |
Return list of SBML model parameter IDs which are not AssignmentRule targets for observables or sigmas |
get_noise_distributions (measurement_df) |
Returns dictionary of cost definitions per observable, if specified. |
get_notnull_columns (df, candidates) |
Return list of df-columns in candidates which are not all null/nan. |
get_observable_id (parameter_id) |
Get observable id from sigma or observable parameter_id |
get_observables (sbml_model, remove) |
Returns dictionary of observable definitions. |
get_optimization_parameters (parameter_df) |
Get list of optimization parameter ids from parameter dataframe. |
get_parameter_df (parameter_file_name) |
Read the provided parameter file into a pandas.Dataframe. |
get_placeholders (formula_string, …) |
Get placeholder variables in noise or observable definition for the given observable ID. |
get_priors_from_df (parameter_df) |
Create list with information about the parameter priors |
get_required_parameters_for_parameter_table (…) |
Get set of parameters which need to go into the parameter table |
get_rows_for_condition (measurement_df, …) |
Extract rows in measurement_df for condition according to ‘preequilibrationConditionId’ and ‘simulationConditionId’ in condition. |
get_sigmas (sbml_model, remove) |
Returns dictionary of sigma definitions. |
get_simulation_conditions (measurement_df) |
Create a table of separate simulation conditions. |
measurements_have_replicates (measurement_df) |
Tests whether the measurements come with replicates |
parameter_is_offset_parameter (parameter, formula) |
Returns true if parameter parameter is an offset parameter with positive sign in formula formula. |
parameter_is_scaling_parameter (parameter, …) |
Returns true if parameter parameter is a scaling parameter in formula formula. |
sample_from_prior (prior, n_starts) |
Creates samples based on prior |
sample_parameter_startpoints (parameter_df, …) |
Create numpy.array with starting points for an optimization |
sbml_parameter_is_observable (sbml_parameter) |
Returns whether the libsbml.Parameter sbml_parameter matches the defined observable format. |
sbml_parameter_is_sigma (sbml_parameter) |
Returns whether the libsbml.Parameter sbml_parameter matches the defined sigma format. |
split_parameter_replacement_list (…) |
Split values in observableParameters and noiseParameters in measurement table. |
Classes
Problem (sbml_model, sbml_reader, …) |
PEtab parameter estimation problem as defined by - SBML model - condition table - measurement table - parameter table [optional] |
-
class
petab.core.
Problem
(sbml_model: libsbml.Model = None, sbml_reader: libsbml.SBMLReader = None, sbml_document: libsbml.SBMLDocument = None, condition_df: pandas.core.frame.DataFrame = None, measurement_df: pandas.core.frame.DataFrame = None, parameter_df: pandas.core.frame.DataFrame = None)¶ Bases:
object
PEtab parameter estimation problem as defined by - SBML model - condition table - measurement table - parameter table [optional]
-
condition_df
¶ @type pandas.DataFrame
-
measurement_df
¶ @type pandas.DataFrame
-
parameter_df
¶ @type pandas.DataFrame
-
sbml_reader
¶ @type libsbml.SBMLReader Stored to keep object alive.
-
sbml_document
¶ @type libsbml.Document Stored to keep object alive.
-
sbml_model
¶ @type libsbml.Model
-
create_parameter_df
(*args, **kwargs)¶ Create a new PEtab parameter table
See create_parameter_df
-
static
from_files
(sbml_file: str = None, condition_file: str = None, measurement_file: str = None, parameter_file: str = None) → petab.core.Problem¶ Factory method to load model and tables from files.
Parameters: - sbml_file – PEtab SBML model
- condition_file – PEtab condition table
- measurement_file – PEtab measurement table
- parameter_file – PEtab parameter table
-
static
from_folder
(folder: str, model_name: str = None) → petab.core.Problem¶ Factory method to use the standard folder structure and file names, i.e.
- ${model_name}/
- +– experimentalCondition_${model_name}.tsv +– measurementData_${model_name}.tsv +– model_${model_name}.xml +– parameters_${model_name}.tsv
Parameters: - folder – Path to the directory in which the files are located.
- model_name – If specified, overrides the model component in the file names. Defaults to the last component of folder.
-
get_constant_parameters
()¶ Provide list of IDs of parameters which are fixed (i.e. not subject to optimization, no sensitivities w.r.t. these parameters are required).
-
get_dynamic_simulation_parameters
()¶ See get_model_parameters
-
get_noise_distributions
()¶ See get_noise_distributions.
-
get_observables
(remove: bool = False)¶ Returns dictionary of observables definitions See assignment_rules_to_dict for details.
-
get_optimization_parameters
()¶ Return list of optimization parameter IDs.
See get_optimization_parameters.
-
get_optimization_to_simulation_parameter_mapping
(warn_unmapped: bool = True)¶ See get_simulation_to_optimization_parameter_mapping.
-
get_sigmas
(remove: bool = False)¶ Return dictionary of observableId => sigma as defined in the SBML model. This does not include parameter mappings defined in the measurement table.
-
get_simulation_conditions_from_measurement_df
()¶ See petab.get_simulation_conditions
-
lb
¶ Parameter table lower bounds
-
sample_parameter_startpoints
(n_starts: int = 100)¶ Create starting points for optimization
See sample_parameter_startpoints
-
ub
¶ Parameter table upper bounds
-
x_fixed_indices
¶ Parameter table non-estimated parameter indices
-
x_fixed_vals
¶ Nominal values for parameter table non-estimated parameters
-
x_ids
¶ Parameter table parameter IDs
-
x_nominal
¶ Parameter table nominal values
-
-
petab.core.
create_condition_df
(parameter_ids: Iterable[str], condition_ids: Iterable[str] = None) → pandas.core.frame.DataFrame¶ Create empty condition dataframe
Parameters: - parameter_ids – the columns
- condition_ids – the rows
Returns: An pandas.DataFrame with empty given rows and columns and all nan values
-
petab.core.
create_measurement_df
() → pandas.core.frame.DataFrame¶ Create empty measurement dataframe
-
petab.core.
create_parameter_df
(sbml_model: libsbml.Model, condition_df: pandas.core.frame.DataFrame, measurement_df: pandas.core.frame.DataFrame, parameter_scale: str = 'log10', lower_bound: Iterable[T_co] = None, upper_bound: Iterable[T_co] = None) → pandas.core.frame.DataFrame¶ Create a new PEtab parameter table
All table entries can be provided as string or list-like with length matching the number of parameters
Parameters: - sbml_model – @type libsbml.Model
- condition_df – @type pandas.DataFrame
- measurement_df – @type pandas.DataFrame
- parameter_scale – parameter scaling
- lower_bound – lower bound for parameter value
- upper_bound – upper bound for parameter value
-
petab.core.
flatten_timepoint_specific_output_overrides
(petab_problem: petab.core.Problem) → None¶ If the PEtab problem definition has timepoint-specific observableParameters or noiseParameters for the same observable, replace those by replicating the respective observable.
This is a helper function for some tools which may not support such timepoint-specific mappings.
Parameters: petab_problem – PEtab problem to work on
-
petab.core.
get_condition_df
(condition_file_name: str) → pandas.core.frame.DataFrame¶ Read the provided condition file into a pandas.Dataframe
Conditions are rows, parameters are columns, conditionId is index.
-
petab.core.
get_default_condition_file_name
(model_name: str, folder: str = '')¶ Get file name according to proposed convention
-
petab.core.
get_default_measurement_file_name
(model_name: str, folder: str = '')¶ Get file name according to proposed convention
-
petab.core.
get_default_parameter_file_name
(model_name: str, folder: str = '')¶ Get file name according to proposed convention
-
petab.core.
get_default_sbml_file_name
(model_name: str, folder: str = '')¶ Get file name according to proposed convention
-
petab.core.
get_measurement_df
(measurement_file_name: str) → pandas.core.frame.DataFrame¶ Read the provided measurement file into a pandas.Dataframe.
-
petab.core.
get_measurement_parameter_ids
(measurement_df: pandas.core.frame.DataFrame) → list¶ Return list of ID of parameters which occur in measurement table as observable or noise parameter overrides.
-
petab.core.
get_model_parameters
(sbml_model: libsbml.Model) → List[str]¶ Return list of SBML model parameter IDs which are not AssignmentRule targets for observables or sigmas
-
petab.core.
get_noise_distributions
(measurement_df: pandas.core.frame.DataFrame) → dict¶ Returns dictionary of cost definitions per observable, if specified.
Looks through all parameters satisfying sbml_parameter_is_cost and return as dictionary.
Parameters: measurement_df – PEtab measurement table Returns: cost definition} Return type: {observableId
-
petab.core.
get_notnull_columns
(df: pandas.core.frame.DataFrame, candidates: Iterable[T_co])¶ Return list of df-columns in candidates which are not all null/nan. The output can e.g. be used as input for pandas.DataFrame.groupby.
-
petab.core.
get_observable_id
(parameter_id: str) → str¶ Get observable id from sigma or observable parameter_id
- e.g. for observable_obs1 -> obs1
- sigma_obs1 -> obs1
-
petab.core.
get_observables
(sbml_model: libsbml.Model, remove: bool = False) → dict¶ Returns dictionary of observable definitions. See assignment_rules_to_dict for details.
-
petab.core.
get_optimization_parameters
(parameter_df: pandas.core.frame.DataFrame) → List[str]¶ Get list of optimization parameter ids from parameter dataframe.
-
petab.core.
get_parameter_df
(parameter_file_name: str) → pandas.core.frame.DataFrame¶ Read the provided parameter file into a pandas.Dataframe.
-
petab.core.
get_placeholders
(formula_string: str, observable_id: str, override_type: str) → set¶ Get placeholder variables in noise or observable definition for the given observable ID.
Parameters: - formula_string – observable formula (typically from SBML model)
- observable_id – ID of current observable
- override_type – ‘observable’ or ‘noise’, depending on whether formula is for observable or for noise model
Returns: (Un-ordered) set of placeholder parameter IDs
-
petab.core.
get_priors_from_df
(parameter_df: pandas.core.frame.DataFrame)¶ Create list with information about the parameter priors
Parameters: parameter_df – @type pandas.DataFrame
-
petab.core.
get_required_parameters_for_parameter_table
(sbml_model: libsbml.Model, condition_df: pandas.core.frame.DataFrame, measurement_df: pandas.core.frame.DataFrame) → Set[str]¶ Get set of parameters which need to go into the parameter table
-
petab.core.
get_rows_for_condition
(measurement_df: pandas.core.frame.DataFrame, condition: Union[pandas.core.frame.DataFrame, dict]) → pandas.core.frame.DataFrame¶ Extract rows in measurement_df for condition according to ‘preequilibrationConditionId’ and ‘simulationConditionId’ in condition.
Returns: cur_measurement_df – The subselection of rows in measurement_df for the condition condition. Return type: pd.DataFrame
-
petab.core.
get_sigmas
(sbml_model: libsbml.Model, remove: bool = False) → dict¶ Returns dictionary of sigma definitions.
Keys are observable IDs, for values see assignment_rules_to_dict for details.
-
petab.core.
get_simulation_conditions
(measurement_df: pandas.core.frame.DataFrame) → pandas.core.frame.DataFrame¶ Create a table of separate simulation conditions. A simulation condition is a specific combination of simulationConditionId and preequilibrationConditionId.
Parameters: measurement_df – PEtab measurement table Returns: Dataframe with columns ‘simulationConditionId’ and ‘preequilibrationConditionId’. All-NULL columns will be omitted.
-
petab.core.
measurements_have_replicates
(measurement_df: pandas.core.frame.DataFrame) → bool¶ Tests whether the measurements come with replicates
Parameters: measurement_df – Measurement table Returns: True if there are replicates, False otherwise
-
petab.core.
parameter_is_offset_parameter
(parameter: str, formula: str) → bool¶ Returns true if parameter parameter is an offset parameter with positive sign in formula formula.
-
petab.core.
parameter_is_scaling_parameter
(parameter: str, formula: str) → bool¶ Returns true if parameter parameter is a scaling parameter in formula formula.
-
petab.core.
sample_from_prior
(prior: tuple, n_starts: int)¶ Creates samples based on prior
Parameters: - prior – @type tuple
- n_starts – @type int
-
petab.core.
sample_parameter_startpoints
(parameter_df: pandas.core.frame.DataFrame, n_starts: int = 100)¶ Create numpy.array with starting points for an optimization
Dimension of output: n_optimization_parameters x n_startpoints
Parameters: - parameter_df – @type pandas.DataFrame
- n_starts – @type int
-
petab.core.
sbml_parameter_is_observable
(sbml_parameter: libsbml.Parameter) → bool¶ Returns whether the libsbml.Parameter sbml_parameter matches the defined observable format.
-
petab.core.
sbml_parameter_is_sigma
(sbml_parameter: libsbml.Parameter) → bool¶ Returns whether the libsbml.Parameter sbml_parameter matches the defined sigma format.
-
petab.core.
split_parameter_replacement_list
(list_string: Union[str, numbers.Number], delim: str = ';') → List[T]¶ Split values in observableParameters and noiseParameters in measurement table. Convert numeric values to float.
Parameters: - delim – delimiter
- list_string – delim-separated stringified list