pypesto.visualize.model_fit

Visualization of the model fit after optimization.

Currently only for PEtab problems.

Functions

time_trajectory_model(result[, problem, ...])

Visualize the time trajectory of the model with given timepoints.

visualize_optimized_model_fit(petab_problem, ...)

Visualize the optimized model fit of a PEtab problem.

pypesto.visualize.model_fit.time_trajectory_model(result: Result | Sequence[Result], problem: Problem | None = None, timepoints: ndarray | Sequence[ndarray] | None = None, n_timepoints: int = 1000, start_index: int = 0, state_ids: str | Sequence[str] | None = None, state_names: str | Sequence[str] | None = None, observable_ids: str | Sequence[str] | None = None) Axes | None[source]

Visualize the time trajectory of the model with given timepoints.

It does this by calling the amici plotting routines.

Parameters:
  • result – The result object from optimization.

  • problem – A pypesto problem. Default is ‘None’ in which case result.problem is used. Needed in case the result is loaded from hdf5.

  • timepoints – Array of timepoints, at which the trajectory will be plotted.

  • n_timepoints – Number of timepoints to be plotted between 0 and last measurement of the model. Only used when timepoints==None.

  • start_index – Index of Optimization run to be plotted. Default is best start.

  • state_ids – Ids of the states to be plotted.

  • state_names – Names of the states to be plotted.

  • observable_ids – Ids of the observables to be plotted.

Returns:

matplotlib.axes.Axes object of the plot.

Return type:

axes

pypesto.visualize.model_fit.visualize_optimized_model_fit(petab_problem: Problem, result: Result | Sequence[Result], pypesto_problem: Problem, start_index: int = 0, return_dict: bool = False, unflattened_petab_problem: Problem | None = None, **kwargs) Axes | None[source]

Visualize the optimized model fit of a PEtab problem.

Function calls the PEtab visualization file of the petab_problem and visualizes the fit of the optimized parameter. Common additional argument is subplot_dir to specify the directory each subplot is saved to. Further keyword arguments are delegated to petab.visualize.plot_with_vis_spec(), see there for more information.

Parameters:
  • petab_problem – The petab.Problem that was optimized.

  • result – The result object from optimization.

  • start_index – The index of the optimization run in result.optimize_result.list. Ignored if problem_parameters is provided.

  • pypesto_problem – The pyPESTO problem.

  • return_dict – Return plot and simulation results as a dictionary.

  • unflattened_petab_problem – If the original PEtab problem is flattened, this can be passed to plot with the original unflattened problem.

  • kwargs – Passed to petab.visualize.plot_problem().

Returns:

  • axes (matplotlib.axes.Axes object of the created plot.)

  • None (In case subplots are saved to file)