PEtab-dev / libpetab-python

Python package for working with PEtab files
https://libpetab-python.readthedocs.io
MIT License
14 stars 6 forks source link

Update visualization notebooks #89

Closed dweindl closed 2 years ago

dweindl commented 2 years ago

Probably didn't survive the recent visualization refactoring...

plakrisenko commented 2 years ago

What exactly doesn't work? The old code wasn't removed yet, so they should be fine

dweindl commented 2 years ago
---------------------------------------------------------------------------

NotImplementedError                       Traceback (most recent call last)

/tmp/ipykernel_509298/4631237.py in <module>
----> 1 ax_without_sim = plot_data_and_simulation(
      2     data_file_path,
      3     condition_file_path,
      4     visualization_file_path)
      5 plt.show()

~/src/libpetab-python/petab/visualize/plot_data_and_simulation.py in plot_data_and_simulation(exp_data, exp_conditions, vis_spec, sim_data, dataset_id_list, sim_cond_id_list, sim_cond_num_list, observable_id_list, observable_num_list, plotted_noise, subplot_file_path)
    179         for _, plot_spec in vis_spec[ind_plot].iterrows():
    180             # handle plot of current dataset
--> 181             handle_dataset_plot(plot_spec, ax, exp_data,
    182                                 exp_conditions, sim_data)
    183 

~/src/libpetab-python/petab/visualize/helper_functions.py in handle_dataset_plot(plot_spec, ax, exp_data, exp_conditions, sim_data)
    890     nan_set = all([np.isnan(val) for val in measurement_to_plot['mean']])
    891     if not nan_set:
--> 892         plot_lowlevel(plot_spec, ax, conditions, measurement_to_plot, plot_sim)
    893 
    894     # Beautify plots

~/src/libpetab-python/petab/visualize/plotting_config.py in plot_lowlevel(plot_spec, ax, conditions, ms, plot_sim)
    158     elif plot_spec[PLOT_TYPE_SIMULATION] == SCATTER_PLOT:
    159         if not plot_sim:
--> 160             raise NotImplementedError('Scatter plots do not work without'
    161                                       ' simulation data')
    162         ax.scatter(ms['mean'], ms['sim'],

NotImplementedError: Scatter plots do not work without simulation data
---------------------------------------------------------------------------

IndexError                                Traceback (most recent call last)

/tmp/ipykernel_635809/2240385560.py in <module>
      6                               visualization_files=visualization_file_path)
      7 
----> 8 ax = petab.visualize.plot_petab_problem(petab_problem=pp)
      9 

~/src/libpetab-python/petab/visualize/plot_data_and_simulation.py in plot_petab_problem(petab_problem, sim_data, dataset_id_list, sim_cond_id_list, sim_cond_num_list, observable_id_list, observable_num_list, plotted_noise)
    229                   DeprecationWarning)
    230 
--> 231     return plot_data_and_simulation(petab_problem.measurement_df,
    232                                     petab_problem.condition_df,
    233                                     petab_problem.visualization_df,

~/src/libpetab-python/petab/visualize/plot_data_and_simulation.py in plot_data_and_simulation(exp_data, exp_conditions, vis_spec, sim_data, dataset_id_list, sim_cond_id_list, sim_cond_num_list, observable_id_list, observable_num_list, plotted_noise, subplot_file_path)
    142         vis_spec = core.get_visualization_df(vis_spec)
    143 
--> 144     exp_data, vis_spec = create_or_update_vis_spec(exp_data,
    145                                                    exp_conditions,
    146                                                    vis_spec,

~/src/libpetab-python/petab/visualize/helper_functions.py in create_or_update_vis_spec(exp_data, exp_conditions, vis_spec, dataset_id_list, sim_cond_id_list, sim_cond_num_list, observable_id_list, observable_num_list, plotted_noise)
    684             # get other settings that could have potentially been there
    685             # and expand according to plot_id_column
--> 686             vis_spec = expand_vis_spec_settings(vis_spec, columns_dict)
    687 
    688         # if dataset_id is there, then nothing to expand?

~/src/libpetab-python/petab/visualize/helper_functions.py in expand_vis_spec_settings(vis_spec, columns_dict)
    596                         vis_spec[Y_VALUES] == columns_dict[Y_VALUES][i])
    597                     column_entries.append(
--> 598                         vis_spec[select_conditions].loc[:, column].values[0])
    599             else:
    600                 # get unique plotIDs from visspecfile

IndexError: index 0 is out of bounds for axis 0 with size 0
dweindl commented 2 years ago

The old code wasn't removed yet, so they should be fine

Then they should be revised anyways - we don't want to advertise deprecated functions.

dweindl commented 2 years ago

P.S.: I would suggest to use that as an opportunity to kick out the old visualization code in the next release. Any objections?

plakrisenko commented 2 years ago

NotImplementedError: Scatter plots do not work without simulation data

This is because I've added scatter plot to visualization file in Isensee example. So that there are line plots, bar plot and scatter plot. But scatter plot only works if both measurements and simulations are available. In the old notebook Isensee example was used to demonstrate plots without simulations. With the modified visualization file it doesn't work. Fujita example can be used instead or another visualization file for Isensee.