SpectrumPlot#

class pyopenms_viz._core.SpectrumPlot(data: ~pandas.core.frame.DataFrame, x: str, y: str, reference_spectrum: ~pandas.core.frame.DataFrame | None = None, mirror_spectrum: bool = False, relative_intensity: bool = False, bin_peaks: ~typing.Literal['auto'] | bool = False, bin_method: ~typing.Literal['none', 'sturges', 'freedman-diaconis', 'mz-tol-bin'] = 'mz-tol-bin', num_x_bins: int = 50, mz_tol: ~typing.Literal[<class 'float'>, 'freedman-diaconis', '1pct-diff'] = '1pct-diff', aggregation_method: ~typing.Literal['mean', 'sum', 'max'] = 'max', peak_color: str | None = None, annotate_top_n_peaks: int | None | ~typing.Literal['all'] = 5, annotate_mz: bool = True, ion_annotation: str | None = None, sequence_annotation: str | None = None, custom_annotation: str | None = None, annotation_color: str | None = None, **kwargs)#

Bases: BaseMSPlot, ABC

__init__(data: ~pandas.core.frame.DataFrame, x: str, y: str, reference_spectrum: ~pandas.core.frame.DataFrame | None = None, mirror_spectrum: bool = False, relative_intensity: bool = False, bin_peaks: ~typing.Literal['auto'] | bool = False, bin_method: ~typing.Literal['none', 'sturges', 'freedman-diaconis', 'mz-tol-bin'] = 'mz-tol-bin', num_x_bins: int = 50, mz_tol: ~typing.Literal[<class 'float'>, 'freedman-diaconis', '1pct-diff'] = '1pct-diff', aggregation_method: ~typing.Literal['mean', 'sum', 'max'] = 'max', peak_color: str | None = None, annotate_top_n_peaks: int | None | ~typing.Literal['all'] = 5, annotate_mz: bool = True, ion_annotation: str | None = None, sequence_annotation: str | None = None, custom_annotation: str | None = None, annotation_color: str | None = None, **kwargs) None#
_bin_peaks(data: DataFrame, x: str, y: str) DataFrame#

Bin peaks based on x-axis values.

Parameters:
  • data (DataFrame) – The data to bin.

  • x (str) – The column name for the x-axis data.

  • y (str) – The column name for the y-axis data.

Returns:

The binned data.

Return type:

DataFrame

_check_and_aggregate_duplicates()#

Check if duplicate data is present and aggregate if specified. Modifies self.data

_get_annotations(data: DataFrame, x: str, y: str)#

Create annotations for each peak. Return lists of texts, x and y locations and colors.

_get_colors(data: DataFrame, kind: Literal['peak', 'annotation'] | None = None)#

Get color generators for peaks or annotations based on config.

_get_ion_color_annotation(ion_annotations: str) str#

Retrieve the color associated with a specific ion annotation from a predefined colormap.

property _kind#

The kind of plot to assemble. Must be overridden by subclasses.

_prepare_data(spectrum: DataFrame, x: str, y: str, reference_spectrum: DataFrame | None) tuple[list, list]#

Prepares data for plotting based on configuration (copy, relative intensity, bin peaks).

get_spectrum_tooltip_data(spectrum: DataFrame, x: str, y: str)#

Get tooltip data for a spectrum plot.

property known_columns: List[str]#

List of known columns in the data, if there are duplicates outside of these columns they will be grouped in aggregation if specified

plot(x, y, **kwargs)#

Standard spectrum plot with m/z on x-axis, intensity on y-axis and optional mirror spectrum.