petab.visualize.plot_data_and_simulation

Functions for plotting PEtab measurement files and simulation results in the same format.

Functions

plot_data_and_simulation(exp_data, ...[, ...])

Main function for plotting data and simulations.

plot_measurements_by_observable(...[, ...])

plot measurement data grouped by observable ID.

plot_petab_problem(petab_problem[, ...])

Visualization using petab problem.

plot_problem(petab_problem[, ...])

Visualization using petab problem.

plot_with_vis_spec(vis_spec_df, conditions_df)

Plot measurements and/or simulations.

plot_without_vis_spec(conditions_df[, ...])

Plot measurements and/or simulations.

save_vis_spec(exp_data, exp_conditions[, ...])

Generate and save visualization specification to a file.

petab.visualize.plot_data_and_simulation.plot_data_and_simulation(exp_data: Union[str, pandas.core.frame.DataFrame], exp_conditions: Union[str, pandas.core.frame.DataFrame], vis_spec: Optional[Union[str, pandas.core.frame.DataFrame]] = None, sim_data: Optional[Union[str, pandas.core.frame.DataFrame]] = None, dataset_id_list: Optional[List[List[str]]] = None, sim_cond_id_list: Optional[List[List[str]]] = None, sim_cond_num_list: Optional[List[List[int]]] = None, observable_id_list: Optional[List[List[str]]] = None, observable_num_list: Optional[List[List[int]]] = None, plotted_noise: Optional[str] = 'MeanAndSD', subplot_file_path: str = '') Optional[Union[Dict[str, matplotlib.axes._subplots.AxesSubplot], np.ndarray[plt.Subplot]]][source]

Main function for plotting data and simulations.

What exactly should be plotted is specified in a visualizationSpecification.tsv file.

Also, the data, simulations and conditions have to be defined in a specific format (see “doc/documentation_data_format.md”).

Parameters
  • exp_data – measurement DataFrame in the PEtab format or path to the data file.

  • exp_conditions – condition DataFrame in the PEtab format or path to the condition file.

  • vis_spec – Visualization specification DataFrame in the PEtab format or path to visualization file.

  • sim_data – simulation DataFrame in the PEtab format or path to the simulation output data file.

  • dataset_id_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the datasetIds for this plot. Only to be used if no visualization file was available.

  • sim_cond_id_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the simulationConditionIds for this plot. Only to be used if no visualization file was available.

  • sim_cond_num_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the numbers corresponding to the simulationConditionIds for this plot. Only to be used if no visualization file was available.

  • observable_id_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the observableIds for this plot. Only to be used if no visualization file was available.

  • observable_num_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the numbers corresponding to the observableIds for this plot. Only to be used if no visualization file was available.

  • plotted_noise – String indicating how noise should be visualized: [‘MeanAndSD’ (default), ‘MeanAndSEM’, ‘replicate’, ‘provided’]

  • subplot_file_path – String which is taken as file path to which single subplots are saved. PlotIDs will be taken as file names.

Returns

  • ax (Axis object of the created plot.)

  • None (In case subplots are save to file)

petab.visualize.plot_data_and_simulation.plot_measurements_by_observable(data_file_path: str, condition_file_path: str, plotted_noise: Optional[str] = 'MeanAndSD') Optional[Union[Dict[str, matplotlib.axes._subplots.AxesSubplot], np.ndarray[plt.Subplot]]][source]

plot measurement data grouped by observable ID. A simple wrapper around the more complex function plot_data_and_simulation.

Parameters
  • data_file_path – file path of measurement data

  • condition_file_path – file path of condition file

  • plotted_noise – String indicating how noise should be visualized: [‘MeanAndSD’ (default), ‘MeanAndSEM’, ‘replicate’, ‘provided’]

Returns

ax

Return type

axis of figures

petab.visualize.plot_data_and_simulation.plot_petab_problem(petab_problem: petab.problem.Problem, sim_data: Optional[Union[str, pandas.core.frame.DataFrame]] = None, dataset_id_list: Optional[List[List[str]]] = None, sim_cond_id_list: Optional[List[List[str]]] = None, sim_cond_num_list: Optional[List[List[int]]] = None, observable_id_list: Optional[List[List[str]]] = None, observable_num_list: Optional[List[List[int]]] = None, plotted_noise: Optional[str] = 'MeanAndSD') Optional[Union[Dict[str, matplotlib.axes._subplots.AxesSubplot], np.ndarray[plt.Subplot]]][source]

Visualization using petab problem. For documentation, see function plot_data_and_simulation()

petab.visualize.plot_data_and_simulation.plot_problem(petab_problem: petab.problem.Problem, simulations_df: Optional[Union[str, pandas.core.frame.DataFrame]] = None, grouping_list: Optional[List[List[str]]] = None, group_by: str = 'observable', plotted_noise: str = 'MeanAndSD', subplot_dir: Optional[str] = None, plotter_type: str = 'mpl') Optional[Dict[str, matplotlib.axes._subplots.AxesSubplot]][source]

Visualization using petab problem. If Visualization table is part of the petab_problem, it will be used for visualization. Otherwise, grouping_list will be used. If neither Visualization table nor grouping_list are available, measurements (simulations) will be grouped by observable, i.e. all measurements for each observable will be visualized on one plot.

Parameters
  • petab_problem – A PEtab problem

  • simulations_df – A simulation DataFrame in the PEtab format or path to the simulation output data file.

  • grouping_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the Ids of datasets or observables or simulation conditions for this plot.

  • group_by – Possible values: ‘dataset’, ‘observable’, ‘simulation’

  • plotted_noise – A string indicating how noise should be visualized: [‘MeanAndSD’ (default), ‘MeanAndSEM’, ‘replicate’, ‘provided’]

  • subplot_dir – A string which is taken as path to the folder where single subplots should be saved. PlotIDs will be taken as file names.

  • plotter_type – Specifies which library should be used for plot generation. Currently, only matplotlib is supported

Returns

  • ax (Axis object of the created plot.)

  • None (In case subplots are saved to a file.)

petab.visualize.plot_data_and_simulation.plot_with_vis_spec(vis_spec_df, conditions_df: Union[str, pandas.core.frame.DataFrame], measurements_df: Optional[Union[str, pandas.core.frame.DataFrame]] = None, simulations_df: Optional[Union[str, pandas.core.frame.DataFrame]] = None, subplot_dir: Optional[str] = None, plotter_type: str = 'mpl', format_: str = 'png') Optional[Dict[str, matplotlib.axes._subplots.AxesSubplot]][source]

Plot measurements and/or simulations. Specification of the visualization routines is provided in visualization table.

Parameters
  • vis_spec_df (visualization table) –

  • conditions_df – A condition DataFrame in the PEtab format or path to the condition file.

  • measurements_df – A measurement DataFrame in the PEtab format or path to the data file.

  • simulations_df – A simulation DataFrame in the PEtab format or path to the simulation output data file.

  • subplot_dir – A path to the folder where single subplots should be saved. PlotIDs will be taken as file names.

  • plotter_type – Specifies which library should be used for plot generation. Currently, only matplotlib is supported.

  • format – File format for the generated figure. (See matplotlib.pyplot.savefig() for supported options).

Returns

  • ax (Axis object of the created plot.)

  • None (In case subplots are saved to a file.)

petab.visualize.plot_data_and_simulation.plot_without_vis_spec(conditions_df: Union[str, pandas.core.frame.DataFrame], grouping_list: Optional[List[List[str]]] = None, group_by: str = 'observable', measurements_df: Optional[Union[str, pandas.core.frame.DataFrame]] = None, simulations_df: Optional[Union[str, pandas.core.frame.DataFrame]] = None, plotted_noise: str = 'MeanAndSD', subplot_dir: Optional[str] = None, plotter_type: str = 'mpl', format_: str = 'png') Optional[Dict[str, matplotlib.axes._subplots.AxesSubplot]][source]

Plot measurements and/or simulations. What exactly should be plotted is specified in a grouping_list. If grouping list is not provided, measurements (simulations) will be grouped by observable, i.e. all measurements for each observable will be visualized on one plot.

Parameters
  • grouping_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the Ids of datasets or observables or simulation conditions for this plot.

  • group_by – Grouping type. Possible values: ‘dataset’, ‘observable’, ‘simulation’

  • conditions_df – A condition DataFrame in the PEtab format or path to the condition file.

  • measurements_df – A measurement DataFrame in the PEtab format or path to the data file.

  • simulations_df – A simulation DataFrame in the PEtab format or path to the simulation output data file.

  • plotted_noise – A string indicating how noise should be visualized: [‘MeanAndSD’ (default), ‘MeanAndSEM’, ‘replicate’, ‘provided’]

  • subplot_dir – A path to the folder where single subplots should be saved. PlotIDs will be taken as file names.

  • plotter_type – Specifies which library should be used for plot generation. Currently, only matplotlib is supported

  • format – File format for the generated figure. (See matplotlib.pyplot.savefig() for supported options).

Returns

  • ax (Axis object of the created plot.)

  • None (In case subplots are saved to a file.)

petab.visualize.plot_data_and_simulation.save_vis_spec(exp_data: Union[str, pandas.core.frame.DataFrame], exp_conditions: Union[str, pandas.core.frame.DataFrame], vis_spec: Optional[Union[str, pandas.core.frame.DataFrame]] = None, dataset_id_list: Optional[List[List[str]]] = None, sim_cond_id_list: Optional[List[List[str]]] = None, sim_cond_num_list: Optional[List[List[int]]] = None, observable_id_list: Optional[List[List[str]]] = None, observable_num_list: Optional[List[List[int]]] = None, plotted_noise: Optional[str] = 'MeanAndSD', output_file_path: str = 'visuSpec.tsv')[source]

Generate and save visualization specification to a file. If vis_spec is provided, the missing columns will be added.

Parameters
  • exp_data – Measurement DataFrame in the PEtab format or path to the data file.

  • exp_conditions – Condition DataFrame in the PEtab format or path to the condition file.

  • vis_spec – Visualization specification DataFrame in the PEtab format or path to visualization file.

  • dataset_id_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the datasetIds for this plot. Only to be used if no visualization file was available.

  • sim_cond_id_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the simulationConditionIds for this plot. Only to be used if no visualization file was available.

  • sim_cond_num_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the numbers corresponding to the simulationConditionIds for this plot. Only to be used if no visualization file was available.

  • observable_id_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the observableIds for this plot. Only to be used if no visualization file was available.

  • observable_num_list – A list of lists. Each sublist corresponds to a plot, each subplot contains the numbers corresponding to the observableIds for this plot. Only to be used if no visualization file was available.

  • plotted_noise – String indicating how noise should be visualized: [‘MeanAndSD’ (default), ‘MeanAndSEM’, ‘replicate’, ‘provided’]

  • output_file_path – File path to which the generated visualization specification is saved.