crisprzip.plotting module

Plotting functionality for Searcher objects.

class crisprzip.plotting.SearcherPlotter(searcher: Searcher)

Bases: object

Collection of plotting functionality for Searcher objects.

Base class that underlies plotting functionality in the Searcher and SearcherTargetComplex classes of the crisprzip.kinetics module.

Notes

This class is built up to support ‘blitting’: redrawing only the parts of a figure that are updated. This significantly speeds up the video making process in the analysis module. It contains 4 types of methods:

  1. prepare … canvas Creates or adapts Figure and Axes objects such that data can later be added.

  2. prepare … lines Adds properly styled lines to the canvas that do not yet contain data. (The term “line” here includes dots or other shapes.)

  3. update … Adds data to the pre-configured line.

  4. plot … Combines the above three methods to make a complete plot.

label_style = {'fontsize': 10}
line_style = {'linewidth': 2, 'marker': '.', 'markersize': 12}
plot_internal_rates(y_lims: Tuple[float, float] = None, color='cornflowerblue', axs: Axes = None, extra_rates: Dict[str, float] = None, **plot_kwargs) Axes

Create complete forward rates plot.

Parameters:
  • y_lims (tuple`[`float], optional) – Tuple specifying the y-axis limits for the plot. Defaults to None, in which case the limits are determined based on the landscape data.

  • color (str, optional) – Color of the plotted lines for the off-target landscape. Defaults to ‘firebrick’.

  • axs (matplotlib.axes.Axes, optional) – Axes to draw the plot on. If not provided, a new figure and axes are created.

  • extra_rates (dict`[`str, float], optional) – Additional rates to add to the plot.

Returns:

Axes – The axes containing the complete plot.

Return type:

matplotlib.axes.Axes

plot_mismatch_penalties(y_lims: Tuple[float, float] = None, color='firebrick', axs: Axes = None, **plot_kwargs) Axes

Creates complete mismatch landscape plot.

Parameters:
  • y_lims (tuple`[`float], optional) – Tuple specifying the y-axis limits for the plot. Defaults to None, in which case the limits are determined based on the landscape data.

  • color (str, optional) – Color of the plotted lines for the off-target landscape. Defaults to ‘firebrick’.

  • axs (matplotlib.axes.Axes, optional) – Axes to draw the plot on. If not provided, a new figure and axes are created.

Returns:

Axes – The axes containing the complete plot.

Return type:

matplotlib.axes.Axes

plot_off_target_landscape(mismatch_positions: MismatchPattern = None, y_lims: Tuple[float, float] = None, color='firebrick', axs: Axes = None, on_rates: List[float] = None, **plot_kwargs) Axes

Create complete off-target landscape plot.

Parameters:
  • mismatch_positions (MismatchPattern, optional) – Positions of mismatches in the target sequence. If not provided, the method shows the on-target landscape only.

  • y_lims (tuple`[`float], optional) – Tuple specifying the y-axis limits for the plot. Defaults to None, in which case the limits are determined based on the landscape data.

  • color (str, optional) – Color of the plotted lines for the off-target landscape. Defaults to ‘firebrick’.

  • axs (matplotlib.axes.Axes, optional) – Axes to draw the plot on. If not provided, a new figure and axes are created.

  • on_rates (list`[`float], optional) – Kinetic rates used to calculate solution energies. If not provided, no solution energies are plotted.

Returns:

Axes – The axes containing the complete plot.

Return type:

matplotlib.axes.Axes

plot_on_target_landscape(y_lims: Tuple[float, float] = None, color='cornflowerblue', axs: Axes = None, on_rates: List[float] = None, **plot_kwargs) Axes

Create complete on-target landscape plot

Parameters:
  • y_lims (tuple`[`float], optional) – Tuple specifying the y-axis limits for the plot. Defaults to None, in which case the limits are determined based on the landscape data.

  • color (str, optional) – Color of the plotted lines for the off-target landscape. Defaults to ‘firebrick’.

  • axs (matplotlib.axes.Axes, optional) – Axes to draw the plot on. If not provided, a new figure and axes are created.

  • on_rates (list`[`float], optional) – Kinetic rates used to calculate solution energies. If not provided, no solution energies are plotted.

Returns:

Axes – The axes containing the complete plot.

Return type:

matplotlib.axes.Axes

prepare_landscape_canvas(y_lims: Tuple[float, float] = None, title: str = '', axs: Axes = None) Axes
prepare_landscape_line(axs: Axes, color='cornflowerblue', **plot_kwargs) Line2D
prepare_rates_canvas(y_lims: Tuple[float, float] = None, title: str = 'Transition rates', axs: Axes = None, extra_rates: Dict[str, float] = None) Axes
prepare_rates_line(axs: Axes, color='cornflowerblue', **plot_kwargs) Line2D
tick_style = {'labelsize': 10}
title_style = {'fontweight': 'bold'}
update_mismatches(line: Line2D) None
update_on_target_landscape(line: Line2D) None
update_rates(line: Line2D, extra_rates: dict = None) None
update_solution_energies(lines: List[Line2D], on_rates: List[float]) None