Skip to content

Commit 0512164

Browse files
authored
Update visualization example notebooks (#146)
* remove plot_data_and_simulation * move scatterplots to a separate visualization specification file * add scatterplot test * scatterplot can be plotted only if both measurements and simulations are available * fix plotting barplots with only simulation data * code style * un-exclude in doc/conf.py and add to examples.rst * remove jupyter notebook outputs
1 parent efa9edb commit 0512164

File tree

7 files changed

+164
-232
lines changed

7 files changed

+164
-232
lines changed

doc/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
'**.ipynb_checkpoints',
6666
'logo/LICENSE.md',
6767
# TODO update and un-exclude
68-
'example/example_visualization.ipynb',
6968
'example/example_visualization_without_visspec.ipynb',
7069
]
7170

doc/example.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The following examples should help to get a better idea of how to use the PEtab
99
:maxdepth: 1
1010

1111
example/example_petablint.ipynb
12+
example/example_visualization.ipynb
1213
example/example_visualization_with_visspec.ipynb
1314

1415
Examples of systems biology parameter estimation problems specified in PEtab

doc/example/example_Isensee/Isensee_visualizationSpecification.tsv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ plot4 JI09_151102_Drg421_418_Age LinePlot MeanAndSD JI09_151102_Drg421_418_Age__
3030
plot5 JI09_160126_Drg449_444_CycNuc BarPlot MeanAndSD JI09_160126_Drg449_444_CycNuc__ctrl condition 0 Condition pRII_Western 0 pRII_Western Ctrl lin lin
3131
plot5 JI09_160126_Drg449_444_CycNuc BarPlot MeanAndSD JI09_160126_Drg449_444_CycNuc__Fsk10_and_IBMX100 condition 0 Condition pRII_Western 0 pRII_Western IBMX(100)/Fsk(10) lin lin
3232
plot5 JI09_160126_Drg449_444_CycNuc BarPlot MeanAndSD JI09_160126_Drg449_444_CycNuc__Sp8_Br_cAMPS_AM10 condition 0 Condition pRII_Western 0 pRII_Western Sp8-Br-cAMPS-AM(10) lin lin
33-
plot6 JI09_160201_Drg453-452_CycNuc ScatterPlot MeanAndSD JI09_160201_Drg453-452_CycNuc__ctrl time 0 Time [min] Calpha_Microscopy 0 Calpha_Microscopy Ctrl lin lin
34-
plot6 JI09_160201_Drg453-452_CycNuc ScatterPlot MeanAndSD JI09_160201_Drg453-452_CycNuc__Fsk time 0 Time [min] Calpha_Microscopy 0 Calpha_Microscopy Fsk(10) lin lin
35-
plot6 JI09_160201_Drg453-452_CycNuc ScatterPlot MeanAndSD JI09_160201_Drg453-452_CycNuc__Sp8_Br_cAMPS_AM time 0 Time [min] Calpha_Microscopy 0 Calpha_Microscopy Sp8-Br-cAMPS-AM(10) lin lin
33+
plot6 JI09_160201_Drg453-452_CycNuc LinePlot MeanAndSD JI09_160201_Drg453-452_CycNuc__ctrl time 0 Time [min] Calpha_Microscopy 0 Calpha_Microscopy Ctrl lin lin
34+
plot6 JI09_160201_Drg453-452_CycNuc LinePlot MeanAndSD JI09_160201_Drg453-452_CycNuc__Fsk time 0 Time [min] Calpha_Microscopy 0 Calpha_Microscopy Fsk(10) lin lin
35+
plot6 JI09_160201_Drg453-452_CycNuc LinePlot MeanAndSD JI09_160201_Drg453-452_CycNuc__Sp8_Br_cAMPS_AM time 0 Time [min] Calpha_Microscopy 0 Calpha_Microscopy Sp8-Br-cAMPS-AM(10) lin lin
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plotId plotName plotTypeSimulation plotTypeData datasetId xValues xOffset xLabel yValues yOffset yLabel legendEntry xScale yScale
2+
plot5 JI09_160126_Drg449_444_CycNuc ScatterPlot MeanAndSD JI09_160126_Drg449_444_CycNuc__ctrl condition 0 Condition pRII_Western 0 pRII_Western Ctrl lin lin
3+
plot5 JI09_160126_Drg449_444_CycNuc ScatterPlot MeanAndSD JI09_160126_Drg449_444_CycNuc__Fsk10_and_IBMX100 condition 0 Condition pRII_Western 0 pRII_Western IBMX(100)/Fsk(10) lin lin
4+
plot5 JI09_160126_Drg449_444_CycNuc ScatterPlot MeanAndSD JI09_160126_Drg449_444_CycNuc__Sp8_Br_cAMPS_AM10 condition 0 Condition pRII_Western 0 pRII_Western Sp8-Br-cAMPS-AM(10) lin lin
5+
plot6 JI09_160201_Drg453-452_CycNuc ScatterPlot MeanAndSD JI09_160201_Drg453-452_CycNuc__ctrl time 0 Time [min] Calpha_Microscopy 0 Calpha_Microscopy Ctrl lin lin
6+
plot6 JI09_160201_Drg453-452_CycNuc ScatterPlot MeanAndSD JI09_160201_Drg453-452_CycNuc__Fsk time 0 Time [min] Calpha_Microscopy 0 Calpha_Microscopy Fsk(10) lin lin
7+
plot6 JI09_160201_Drg453-452_CycNuc ScatterPlot MeanAndSD JI09_160201_Drg453-452_CycNuc__Sp8_Br_cAMPS_AM time 0 Time [min] Calpha_Microscopy 0 Calpha_Microscopy Sp8-Br-cAMPS-AM(10) lin lin

doc/example/example_visualization.ipynb

Lines changed: 133 additions & 221 deletions
Large diffs are not rendered by default.

petab/visualize/plotter.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ def generate_barplot(self, ax: 'matplotlib.pyplot.Axes',
170170
# TODO: plotTypeData == REPLICATE?
171171
noise_col = self._error_column_for_plot_type_data(plotTypeData)
172172

173-
simu_colors = None
174173
measurements_to_plot, simulations_to_plot = \
175174
self.data_provider.get_data_to_plot(dataplot,
176175
plotTypeData == PROVIDED)
@@ -191,15 +190,14 @@ def generate_barplot(self, ax: 'matplotlib.pyplot.Axes',
191190
color = plt.rcParams["axes.prop_cycle"].by_key()["color"][0]
192191

193192
if measurements_to_plot is not None:
194-
p = ax.bar(x_name, measurements_to_plot.data_to_plot['mean'],
195-
yerr=measurements_to_plot.data_to_plot[noise_col],
196-
color=color, **bar_kwargs, label='measurement')
197-
simu_colors = p[0].get_facecolor()
193+
ax.bar(x_name, measurements_to_plot.data_to_plot['mean'],
194+
yerr=measurements_to_plot.data_to_plot[noise_col],
195+
color=color, **bar_kwargs, label='measurement')
198196

199197
if simulations_to_plot is not None:
200198
bar_kwargs['width'] = -bar_kwargs['width']
201199
ax.bar(x_name, simulations_to_plot.data_to_plot['mean'],
202-
color='white', edgecolor=simu_colors, **bar_kwargs,
200+
color='white', edgecolor=color, **bar_kwargs,
203201
label='simulation')
204202

205203
def generate_scatterplot(self, ax: 'matplotlib.pyplot.Axes',
@@ -222,7 +220,7 @@ def generate_scatterplot(self, ax: 'matplotlib.pyplot.Axes',
222220
self.data_provider.get_data_to_plot(dataplot,
223221
plotTypeData == PROVIDED)
224222

225-
if simulations_to_plot is None:
223+
if simulations_to_plot is None or measurements_to_plot is None:
226224
raise NotImplementedError('Scatter plots do not work without'
227225
' simulation data')
228226
ax.scatter(measurements_to_plot.data_to_plot['mean'],

tests/test_visualization.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ def vis_spec_file_Isensee_replicates():
102102
/ "Isensee_visualizationSpecification_replicates.tsv"
103103

104104

105+
@pytest.fixture
106+
def vis_spec_file_Isensee_scatterplot():
107+
return EXAMPLE_DIR / "example_Isensee" \
108+
/ "Isensee_visualizationSpecification_scatterplot.tsv"
109+
110+
105111
@pytest.fixture
106112
def simulation_file_Isensee():
107113
return EXAMPLE_DIR / "example_Isensee" / "Isensee_simulationData.tsv"
@@ -124,6 +130,15 @@ def test_visualization_replicates(data_file_Isensee,
124130
data_file_Isensee, simulation_file_Isensee)
125131

126132

133+
def test_visualization_scatterplot(data_file_Isensee,
134+
condition_file_Isensee,
135+
vis_spec_file_Isensee_scatterplot,
136+
simulation_file_Isensee):
137+
plot_with_vis_spec(vis_spec_file_Isensee_scatterplot,
138+
condition_file_Isensee,
139+
data_file_Isensee, simulation_file_Isensee)
140+
141+
127142
def test_visualization_small_visu_file_w_datasetid(data_file_Fujita,
128143
condition_file_Fujita,
129144
visu_file_Fujita_small):

0 commit comments

Comments
 (0)