pypesto.petab

PEtab

pyPESTO support for the PEtab data format.

class pypesto.petab.PetabImporter[source]

Bases: object

Importer for PEtab files.

Create an amici.amici.Model, an pypesto.objective.AmiciObjective or a pypesto.problem.Problem from PEtab files. The created objective function is a negative log-likelihood function and can thus be negative. The actual form of the likelihood depends on the noise model specified in the provided PEtab problem. For more information, see the PEtab documentation.

MODEL_BASE_DIR = 'amici_models/1.0.0'
__init__(petab_problem, output_folder=None, model_name=None, validate_petab=True, validate_petab_hierarchical=True, hierarchical=False, inner_options=None, simulator_type='amici', simulator=None, rr=None)[source]

Initialize importer.

Parameters:
  • petab_problem (Problem) – Managing access to the model and data.

  • output_folder (str | None) – Folder to contain the amici model. Defaults to ‘./amici_models/{model_name}’.

  • model_name (str | None) – Name of the model, which will in particular be the name of the compiled model python module.

  • validate_petab (bool) – Flag indicating if the PEtab problem shall be validated.

  • validate_petab_hierarchical (bool) – Flag indicating if the PEtab problem shall be validated in terms of pyPESTO’s hierarchical optimization implementation.

  • hierarchical (bool) – Whether to use hierarchical optimization or not, in case the underlying PEtab problem has parameters marked for hierarchical optimization (non-empty parameterType column in the PEtab parameter table). Required for ordinal, censored and semiquantitative data.

  • inner_options (dict | None) – Options for the inner problems and solvers. If not provided, default options will be used.

  • simulator_type (str) – The type of simulator to use. Depending on this different kinds of objectives will be created. Allowed types are ‘amici’, ‘petab’, and ‘roadrunner’.

  • simulator (Simulator | None) – In case of a simulator_type == 'petab', the simulator object has to be provided. Otherwise, the argument is not used.

  • rr (RoadRunner | None)

check_gradients(*args, rtol=0.01, atol=0.001, mode=None, multi_eps=None, **kwargs)[source]

Check if gradients match finite differences (FDs).

Parameters:
  • rtol (relative error tolerance)

  • atol (absolute error tolerance)

  • mode (function values or residuals)

  • objAbsoluteTolerance (absolute tolerance in sensitivity calculation)

  • objRelativeTolerance (relative tolerance in sensitivity calculation)

  • multi_eps (multiple test step width for FDs)

Return type:

bool

Returns:

match (Whether gradients match FDs (True) or not (False))

create_model(force_compile=False, verbose=True, **kwargs)[source]

See AmiciObjectiveCreator.create_model().

Parameters:
Return type:

amici.Model

create_objective(model=None, solver=None, edatas=None, force_compile=False, verbose=True, **kwargs)[source]

See AmiciObjectiveCreator.create_objective().

Parameters:
  • model (amici.Model)

  • solver (amici.Solver)

  • edatas (Sequence[amici.ExpData])

  • force_compile (bool)

  • verbose (bool)

Return type:

ObjectiveBase

create_objective_creator(simulator_type='amici', simulator=None)[source]

Choose ObjectiveCreator depending on the simulator type.

Parameters:
  • simulator_type (str) – The type of simulator to use. Depending on this different kinds of objectives will be created. Allowed types are ‘amici’, ‘petab’, and ‘roadrunner’.

  • simulator (Simulator | None) – In case of a simulator_type == 'petab', the simulator object has to be provided. Otherwise the argument is not used.

Return type:

ObjectiveCreator

create_predictor(objective=None, amici_output_fields=None, post_processor=None, post_processor_sensi=None, post_processor_time=None, max_chunk_size=None, output_ids=None, condition_ids=None)[source]

See AmiciObjectiveCreator.create_predictor().

Return type:

AmiciPredictor

Parameters:
create_prior()[source]

Create a prior from the parameter table.

Returns None, if no priors are defined.

Return type:

NegLogParameterPriors | None

create_problem(objective=None, x_guesses=None, problem_kwargs=None, startpoint_kwargs=None, **kwargs)[source]

Create a pypesto.problem.Problem.

Parameters:
Return type:

Problem

Returns:

A pypesto.problem.Problem for the objective.

create_startpoint_method(**kwargs)[source]

Create a startpoint method.

Parameters:

**kwargs – Additional keyword arguments passed on to pypesto.startpoint.FunctionStartpoints.__init__().

Return type:

StartpointMethod

static from_yaml(yaml_config, output_folder=None, model_name=None, simulator_type='amici')[source]

Simplified constructor using a petab yaml file.

Return type:

PetabImporter

Parameters:
  • yaml_config (dict | str)

  • output_folder (str)

  • model_name (str)

  • simulator_type (str)

prediction_to_petab_measurement_df(prediction, predictor=None)[source]

Cast prediction into a dataframe.

If a PEtab problem is simulated without post-processing, then the result can be cast into a PEtab measurement or simulation dataframe

Parameters:
Return type:

DataFrame

Returns:

  • A dataframe built from the rdatas in the format as in

  • self.petab_problem.measurement_df.

prediction_to_petab_simulation_df(prediction, predictor=None)[source]

See prediction_to_petab_measurement_df().

Except a PEtab simulation dataframe is created, i.e. the measurement column label is adjusted.

Return type:

DataFrame

Parameters:
rdatas_to_measurement_df(rdatas, model=None, verbose=True)[source]

See AmiciObjectiveCreator.rdatas_to_measurement_df().

Parameters:
  • rdatas (Sequence[amici.ReturnData])

  • model (amici.Model)

  • verbose (bool)

Return type:

pd.DataFrame

rdatas_to_simulation_df(rdatas, model=None)[source]

See rdatas_to_measurement_df().

Except a petab simulation dataframe is created, i.e. the measurement column label is adjusted.

Parameters:
  • rdatas (Sequence[amici.ReturnData])

  • model (amici.Model)

Return type:

pd.DataFrame

validate_inner_options()[source]

Validate the inner options.