Visualization of data and simulations

In this notebook, we illustrate the visualization functions of petab.

from petab.visualize import plot_with_vis_spec, plot_without_vis_spec
folder = "example_Isensee/"

data_file_path = folder + "Isensee_measurementData.tsv"
condition_file_path = folder + "Isensee_experimentalCondition.tsv"
visualization_file_path = folder + "Isensee_visualizationSpecification.tsv"
simulation_file_path = folder + "Isensee_simulationData.tsv"
ax = plot_with_vis_spec(
    visualization_file_path,
    condition_file_path,
    data_file_path,
    simulation_file_path,
)
../_images/fa037ba113da1a6542ffbea5a42f7c18d0aba8a8f611b6491467bdaf17650d22.png

Now, we want to call the plotting routines without using the simulated data, only the visualization specification file.

ax_without_sim = plot_with_vis_spec(
    visualization_file_path, condition_file_path, data_file_path
)
../_images/3fb41ba71c7934a505042ad0524727f746f593071977bc30f05cbdf2b290a831.png

One can also plot only simulated data:

ax = plot_with_vis_spec(
    visualization_file_path,
    condition_file_path,
    simulations_df=simulation_file_path,
)
../_images/766507d168176bc4cef162e135b5a4c4c83f31a686ab40fba9e97f82a13d09de.png

If both measurements and simulated data are available, they can be visualized using scatter plot:

visualization_file_scatterplots = (
    folder + "Isensee_visualizationSpecification_scatterplot.tsv"
)
ax = plot_with_vis_spec(
    visualization_file_scatterplots,
    condition_file_path,
    data_file_path,
    simulation_file_path,
)
../_images/836253ff3b6c2dfe8462ae6e907a7a0da961b042472d596dcdaa5ec7fdd147b3.png

We can also call the plotting routine without the visualization specification file, but by passing a list of lists as dataset_id_list. Each sublist corresponds to a plot, and contains the datasetIds which should be plotted. In this simply structured plotting routine, the independent variable will always be time.

datasets = [
    [
        "JI09_150302_Drg345_343_CycNuc__4_ABnOH_and_ctrl",
        "JI09_150302_Drg345_343_CycNuc__4_ABnOH_and_Fsk",
    ],
    [
        "JI09_160201_Drg453-452_CycNuc__ctrl",
        "JI09_160201_Drg453-452_CycNuc__Fsk",
        "JI09_160201_Drg453-452_CycNuc__Sp8_Br_cAMPS_AM",
    ],
]
ax_without_sim = plot_without_vis_spec(
    condition_file_path, datasets, "dataset", data_file_path
)
../_images/e097a3653c59c61c4467103a947fe2f5034b2d096ce7c09cb2be8a2b855ca9ac.png

Let’s look more closely at the plotting routines, if no visualization specification file is provided. If such a file is missing, PEtab needs to know how to group the data points. For this, three options can be used:

  • dataset_id_list

  • sim_cond_id_lis

  • observable_id_list

Each of them is a list of lists. Again, each sublist is a plot and its content are either simulation condition IDs or observable IDs or the dataset IDs.

We want to illustrate this functionality by using a simpler example, a model published in 2010 by Fujita et al.

data_file_Fujita = "example_Fujita/Fujita_measurementData.tsv"
condition_file_Fujita = "example_Fujita/Fujita_experimentalCondition.tsv"

# Plot 4 axes objects, plotting
# - in the first window  all observables of the simulation condition 'model1_data1'
# - in the second window all observables of the simulation conditions 'model1_data2', 'model1_data3'
# - in the third window  all observables of the simulation conditions 'model1_data4', 'model1_data5'
# - in the fourth window all observables of the simulation condition 'model1_data6'

sim_cond_id_list = [
    ["model1_data1"],
    ["model1_data2", "model1_data3"],
    ["model1_data4", "model1_data5"],
    ["model1_data6"],
]

ax = plot_without_vis_spec(
    condition_file_Fujita,
    sim_cond_id_list,
    "simulation",
    data_file_Fujita,
    plotted_noise="provided",
)
../_images/73f996f194f3dae5ab3dddac0c1b7cc1cb86b40c393faf8a2b2d2c6bb0b0e89e.png
# Plot 3 axes objects, plotting
# - in the first window  the observable 'pS6_tot' for all simulation conditions
# - in the second window the observable 'pEGFR_tot' for all simulation conditions
# - in the third window  the observable 'pAkt_tot' for all simulation conditions

observable_id_list = [["pS6_tot"], ["pEGFR_tot"], ["pAkt_tot"]]


ax = plot_without_vis_spec(
    condition_file_Fujita,
    observable_id_list,
    "observable",
    data_file_Fujita,
    plotted_noise="provided",
)
../_images/107eeb0185d1483da010ebd79404e8c0300bbb5906977b0426669c3813683c4c.png
# Plot 2 axes objects, plotting
# - in the first window  the observable 'pS6_tot' for all simulation conditions
# - in the second window the observable 'pEGFR_tot' for all simulation conditions
# - in the third window  the observable 'pAkt_tot' for all simulation conditions
# while using the noise values which are saved in the PEtab files

observable_id_list = [["pS6_tot"], ["pEGFR_tot"]]


ax = plot_without_vis_spec(
    condition_file_Fujita,
    observable_id_list,
    "observable",
    data_file_Fujita,
    plotted_noise="provided",
)
../_images/18cd16d5af079d5e0bb664abb42af251d0044daef851d9765edc3da73a7469e4.png

Plot only simulations

simu_file_Fujita = "example_Fujita/Fujita_simulatedData.tsv"

sim_cond_id_list = [
    ["model1_data1"],
    ["model1_data2", "model1_data3"],
    ["model1_data4", "model1_data5"],
    ["model1_data6"],
]

ax = plot_without_vis_spec(
    condition_file_Fujita,
    sim_cond_id_list,
    "simulation",
    simulations_df=simu_file_Fujita,
    plotted_noise="provided",
)
../_images/52deffe51876c5663550761129832cc9e8767296776335ef8872f7ec43a39c13.png
observable_id_list = [["pS6_tot"], ["pEGFR_tot"], ["pAkt_tot"]]

ax = plot_without_vis_spec(
    condition_file_Fujita,
    observable_id_list,
    "observable",
    simulations_df=simu_file_Fujita,
    plotted_noise="provided",
)
../_images/e44c183f2925249458f807c971d5c3b3c0952f1009d4d716ed0301f10afefe49.png