plots

Helper functions to make plots of drug combination responses and synergy.

synergy.utils.plots.plot_heatmap(d1, d2, vals, title='', xlabel='Drug 1', ylabel='Drug 2', fname='', **kwargs)[source]

Plot a heatmap of drug combination data.

This may be the raw response, dose-dependent synergy scores, model residuals, or any other data that can be represented as a grid of dose-dependent values.

Parameters:
  • d1 (ArrayLike) – array of doses for drug 1

  • d2 (ArrayLike) – array of doses for drug 2

  • vals (ArrayLike) – array of effect values

  • title (str) – title of the plot

  • xlabel (str) – label for the x-axis (e.g., drug name, concentration units)

  • ylabel (str) – label for the y-axis

  • fname (str) – filename to save the plot (if not empty)

  • kwargs

    additional keyword arguments to configure the plot

    • aggfunc: Callable function to aggregate replicates (default is np.median)

    • aspect: str aspect ratio of the plot (default is “equal”)

    • ax: matplotlib axis or None to generate a new figure

    • figsize: tuple of width and height for the figure

    • logscale: bool if True, plot the doses on a log scale

    • cmap: str or matplotlib.colors.Colormap colormap to use

    • nancolor: str color to use for NaN values (only if cmap is a string)

    • vmin: float minimum value for the color scale (or None to use the minimum value in vals)

    • vmax: float maximum value for the color scale (or None to use the maximum value in vals)

    • center_on_zero: bool if True, set vmin and vmax to symmetric values around zero

synergy.utils.plots.plot_surface_plotly(d1, d2, vals, scatter_points=None, logscale=True, xlabel='Drug 1', ylabel='Drug 2', zlabel='z', title='', fname='', **kwargs)[source]

Plot 3d surface of drug combination data.

Parameters:
  • d1 (ArrayLike) – array of doses for drug 1

  • d2 (ArrayLike) – array of doses for drug 2

  • vals (ArrayLike) – array of values

  • scatter_points (default: None) – pandas dataframe of points to scatter on the surface plot

  • logscale (bool) – if True, plot the doses on a log scale

  • xlabel (str) – label for the x-axis (e.g., drug name, concentration units)

  • ylabel (str) – label for the y-axis

  • zlabel (str) – label for the z-axis

  • title (str) – title of the plot

  • fname (str) – filename to save the plot (if not empty)

  • kwargs

    additional keyword arguments to configure the plot

    • figsize: tuple of width and height for the figure

    • font: dict of font properties

    • fontsize: int font size (if font is not specified)

    • cmap: colormap str

    • vmin: float minimum value for the color scale (or None to use the minimum value in vals)

    • vmax: float maximum value for the color scale (or None to use the maximum value in vals)

    • center_on_zero: bool if True, set vmin and vmax to symmetric values around

synergy.utils.plots.plotly_isosurfaces(d, vals, drug_indices=[0, 1, 2], fname='', xlabel='Drug 1', ylabel='Drug 2', zlabel='Drug 3', logscale=True, surface_count=10, title='', **kwargs)[source]

Plot isosurfaces of drug combination data.

Parameters:
  • d (ArrayLike) – array of doses for each drug

  • E (ArrayLike) – array of effect values

  • drug_indices (Sequence[int]) – indices of the drugs to plot

  • fname (str) – filename to save the plot (if not empty)

  • xlabel (str) – label for the x-axis (e.g., drug name, concentration units)

  • ylabel (str) – label for the y-axis

  • zlabel (str) – label for the z-axis

  • logscale (bool) – if True, plot the doses on a log scale

  • surface_count (int) – number of isosurfaces

  • title (str) – title of the plot

  • kwargs

    additional keyword arguments to configure the plot

    • figsize: tuple of width and height for the figure

    • font: dict of font properties

    • fontsize: int font size (if font is not specified)

    • cmap: colormap str

    • vmin: float minimum value for the color scale (or None to use the minimum value in vals)

    • vmax: float maximum value for the color scale (or None to use the maximum value in vals)

    • center_on_zero: bool if True, set vmin and vmax to symmetric values around

    • isomin: float minimum value for the isosurfaces

    • isomax: float maximum value for the isosurfaces

synergy.utils.plots.set_plotly_interactive(interactive=True)[source]

Configures plotly to use iplot() instead of plot(), such as within a Jupyter notebook.