Visualization with visualization specification file

As described in the PEtab documentation, the visualization specification file (VS) is a tab-separated value file containing the specification of the visualization routines which come with the PEtab repository. In this example, we will discuss how to specify different visualization settings by means of the VS.

Let’s plot measurements corresponding to the ones of the models from the Benchmark collection Fujita_SciSignal2010.

import petab
from petab.visualize import plot_data_and_simulation

folder = "example_Fujita/"
data_file_path = folder + "Fujita_measurementData.tsv"
condition_file_path = folder + "Fujita_experimentalCondition.tsv"
observables_file_path = folder + "Fujita_observables.tsv"

If no settings are provided, the measurements will be plotted with default settings. Namely, it will be assumed that the independent variable is time, and that data for each observable is to be plotted in a separate subplot. This also applies to the case when VS is empty:

visualization_file_path = folder + "/visuSpecs/Fujita_visuSpec_empty.tsv"

pp = petab.Problem.from_files(
    measurement_file=data_file_path,
    condition_file=condition_file_path,
    observable_files=observables_file_path,
    visualization_files=visualization_file_path,
)
petab.visualize.plot_problem(petab_problem=pp);
/tmp/ipykernel_761/4264660.py:3: DeprecationWarning: petab.Problem.from_files is deprecated and will be removed in a future version. Use `petab.Problem.from_yaml instead.
  pp = petab.Problem.from_files(
/home/docs/checkouts/readthedocs.org/user_builds/libpetab-python/envs/v0.2.5/lib/python3.9/site-packages/petab/core.py:102: UserWarning: Visualization table is empty. Defaults will be used. Refer to the documentation for details.
  warn(
../_images/3f26603d0dca4ba9d9e226584434e1ae572e15c6451051e14e4a500a3e357c7b.png

First of all, let us create a visualization specification file with only mandatory columns. In fact, there is only one mandatory column: plotId. Resulting plot using the VS

plotId

plot1

This way, all data will be shown in a single plot, taking time as independent variable.

visualization_file_path = folder + "/visuSpecs/Fujita_visuSpec_mandatory.tsv"

pp = petab.Problem.from_files(
    measurement_file=data_file_path,
    condition_file=condition_file_path,
    observable_files=observables_file_path,
    visualization_files=visualization_file_path,
)

petab.visualize.plot_problem(petab_problem=pp);
/tmp/ipykernel_761/4062752345.py:3: DeprecationWarning: petab.Problem.from_files is deprecated and will be removed in a future version. Use `petab.Problem.from_yaml instead.
  pp = petab.Problem.from_files(
../_images/b41bb758f849171cfb5ef9a6ed2037c6b49e7cd967880a9602b382a7a4ada84e.png

Now let’s try adding some settings:

plotId

xOffset

yScale

plot1

100

log

visualization_file_path = folder + "/visuSpecs/Fujita_visuSpec_1.tsv"

pp = petab.Problem.from_files(
    measurement_file=data_file_path,
    condition_file=condition_file_path,
    observable_files=observables_file_path,
    visualization_files=visualization_file_path,
)

petab.visualize.plot_problem(petab_problem=pp);
/tmp/ipykernel_761/3408896722.py:3: DeprecationWarning: petab.Problem.from_files is deprecated and will be removed in a future version. Use `petab.Problem.from_yaml instead.
  pp = petab.Problem.from_files(
../_images/8a725502c489b546168fb8eaf58ad2e84e457510186a78fb412b87d92d0746bb.png

As you can see, the scale of the y-axis changed to a logarithmic one and an offset for the independent variable is set to 100.

You can group measurements by observables by adding yValues column:

plotId

yValues

yOffset

yScale

plotName

plot1

pEGFR_tot

0

log

pEGFR total

plot2

pAkt_tot

300

lin

pAkt total and pS6 total

plot2

pS6_tot

305

lin

pAkt total and pS6 total

visualization_file_path = folder + "/visuSpecs/Fujita_visuSpec_2.tsv"

pp = petab.Problem.from_files(
    measurement_file=data_file_path,
    condition_file=condition_file_path,
    observable_files=observables_file_path,
    visualization_files=visualization_file_path,
)

petab.visualize.plot_problem(petab_problem=pp);
/tmp/ipykernel_761/3874749703.py:3: DeprecationWarning: petab.Problem.from_files is deprecated and will be removed in a future version. Use `petab.Problem.from_yaml instead.
  pp = petab.Problem.from_files(
../_images/58041d4f774c66bd1a25857be05633a812a02f437fc17fc4097c9dd5bc204e4c.png

You can also plot individual datasets:

plotId

plotTypeSimulation

plotTypeData

datasetId

xValues

plot1

LinePlot

provided

model1_data1_pEGFR_tot

time

plot2

LinePlot

provided

model1_data2_pEGFR_tot

time

plot2

LinePlot

provided

model1_data3_pEGFR_tot

time

plot3

LinePlot

provided

model1_data4_pEGFR_tot

time

plot3

LinePlot

provided

model1_data5_pEGFR_tot

time

plot3

LinePlot

provided

model1_data6_pEGFR_tot

time

visualization_file_path = (
    folder + "/visuSpecs/Fujita_visuSpec_individual_datasets.tsv"
)

pp = petab.Problem.from_files(
    measurement_file=data_file_path,
    condition_file=condition_file_path,
    observable_files=observables_file_path,
    visualization_files=visualization_file_path,
)

petab.visualize.plot_problem(petab_problem=pp);
/tmp/ipykernel_761/2903552082.py:5: DeprecationWarning: petab.Problem.from_files is deprecated and will be removed in a future version. Use `petab.Problem.from_yaml instead.
  pp = petab.Problem.from_files(
../_images/1f2bea6bc79f94191401d5a921b36eb39486a55d24cd8360b69d18c8a15e0a71.png
visualization_file_path = folder + "/visuSpecs/Fujita_visuSpec_datasetIds.tsv"

pp = petab.Problem.from_files(
    measurement_file=data_file_path,
    condition_file=condition_file_path,
    observable_files=observables_file_path,
    visualization_files=visualization_file_path,
)

petab.visualize.plot_problem(petab_problem=pp);
/tmp/ipykernel_761/4122503411.py:3: DeprecationWarning: petab.Problem.from_files is deprecated and will be removed in a future version. Use `petab.Problem.from_yaml instead.
  pp = petab.Problem.from_files(
../_images/0af33784acfd9a85a23b469f7830690a5030ab59d6ca94fd8d8aefc32b0986b0.png

As you can see, with the VS file you have an opportunity to plot each dataset individually or groups of datasets. Refer to the PEtab documentation for descriptions of all possible settings. If you have any questions or encounter some problems, please create an issue. We will be happy to help!