pypesto.petab
PEtab
pyPESTO support for the PEtab data format.
- class pypesto.petab.PetabImporter[source]
Bases:
objectImporter for PEtab files.
Create an
amici.amici.Model, anpypesto.objective.AmiciObjectiveor apypesto.problem.Problemfrom 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 asimulator_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:
- Returns:
match (Whether gradients match FDs (True) or not (False))
- create_model(force_compile=False, verbose=True, **kwargs)[source]
See
AmiciObjectiveCreator.create_model().
- create_objective(model=None, solver=None, edatas=None, force_compile=False, verbose=True, **kwargs)[source]
See
AmiciObjectiveCreator.create_objective().- Parameters:
- Return type:
- create_objective_creator(simulator_type='amici', simulator=None)[source]
Choose
ObjectiveCreatordepending 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 asimulator_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().
- create_prior()[source]
Create a prior from the parameter table.
Returns None, if no priors are defined.
- Return type:
- create_problem(objective=None, x_guesses=None, problem_kwargs=None, startpoint_kwargs=None, **kwargs)[source]
Create a
pypesto.problem.Problem.- Parameters:
objective (
ObjectiveBase) – Objective as created bycreate_objective().x_guesses (
Iterable[float] |None) – Guesses for the parameter values, shape (g, dim), where g denotes the number of guesses. These are used as start points in the optimization.problem_kwargs (
dict[str,Any]) – Passed topypesto.problem.Problem.__init__().startpoint_kwargs (
dict[str,Any]) – Keyword arguments forwarded toPetabImporter.create_startpoint_method().**kwargs – Additional key word arguments passed on to the objective, if not provided.
- Return type:
- Returns:
A
pypesto.problem.Problemfor 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:
- static from_yaml(yaml_config, output_folder=None, model_name=None, simulator_type='amici')[source]
Simplified constructor using a petab yaml file.
- 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:
prediction (
PredictionResult) – A prediction result as produced by anpypesto.predict.AmiciPredictor.predictor (
AmiciPredictor) – Thepypesto.predict.AmiciPredictorinstance.
- 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:
prediction (PredictionResult)
predictor (AmiciPredictor)
- 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