proteobench.plotting package#

Plotting module for ProteoBench.

class proteobench.plotting.LFQHYEPlotGenerator(y_axis_title: str = 'Total number of features quantified in the selected number of raw files')[source]#

Bases: PlotGeneratorBase

Plot generator for LFQ HYE (Human-Yeast-Ecoli) quantification modules. Used by DIA/DDA ion modules that use the HYE benchmark dataset.

generate_comparison_plots(intermediates: Dict[str, DataFrame], **kwargs) → Dict[str, Figure][source]#

Generate the plots that compare several benchmark runs with each other.

Unlike generate_in_depth_plots, which describes a single run, these plots take the intermediate tables of several runs at once. LFQ modules that offer no such plot inherit this default, which returns nothing, and show only the two generic comparison tabs.

Parameters:
  • intermediates (Dict[str, pd.DataFrame]) – Mapping of workflow label (e.g. a ProteoBench ID) to that workflow’s intermediate DataFrame.

  • **kwargs (dict) – Additional module-specific parameters. Implementations should document which ones they accept; precursor_column_name is the usual one.

Returns:

Dictionary mapping plot names to plotly figures. Empty by default.

Return type:

Dict[str, go.Figure]

generate_in_depth_plots(performance_data: DataFrame, parse_settings: any, **kwargs) → Dict[str, Figure][source]#

Generate standard LFQ HYE plots.

Parameters:
  • performance_data (pd.DataFrame) – The performance data to plot

  • parse_settings (ParseSettings) – The parse settings for the module

  • recalculate (bool) – Whether to recalculate or use cached plots

  • **kwargs (dict) – Additional module-specific parameters

Returns:

Dictionary mapping plot names to plotly figures

Return type:

Dict[str, go.Figure]

get_comparison_plot_descriptions() → Dict[str, str][source]#

Get descriptions for each comparison tab.

The web interface renders the description under the tab title. Keys match the name values of get_comparison_plot_layout.

Returns:

Dictionary mapping comparison tab names to their descriptions.

Return type:

Dict[str, str]

get_comparison_plot_layout() → List[dict][source]#

Define the full set of tabs the workflow comparison shows, and in which order.

This is the complete specification the web interface renders, so an LFQ module controls its comparison tabs entirely from its plot generator. Two names are rendered by the web interface itself rather than by a figure, because they combine a plot with widgets: precursor_overlap and parameter_differences. Every other name must match a key returned by generate_comparison_plots.

The default returns only the two generic tabs. Modules that add a comparison plot should extend rather than replace it, for example return super().get_comparison_plot_layout() + [{"name": ..., "title": ...}].

Returns:

List of tab configurations, each with a name and a title.

Return type:

List[dict]

get_in_depth_metrics_help_markdown() → str[source]#

Return a Markdown explanation of how the in-depth plots are calculated.

Returns:

The Markdown explanation shown in the “How are the metrics calculated?” popover on the in-depth tab.

Return type:

str

get_in_depth_plot_descriptions() → Dict[str, str][source]#

Get descriptions for each plot.

Returns:

Dictionary mapping plot names to their descriptions

Return type:

Dict[str, str]

get_in_depth_plot_layout() → list[source]#

Define layout for LFQ HYE plots.

Returns:

List of in-depth plot configurations defining how plots should be displayed

Return type:

list

get_metrics_help_markdown() → str[source]#

Return a Markdown explanation of how the metrics of the main plot are calculated.

Returns:

The Markdown explanation shown in the “How are the metrics calculated?” popover.

Return type:

str

plot_accuracy_vs_abundance(intermediates: Dict[str, DataFrame], **kwargs) → Figure[source]#

Compare quantification accuracy over the abundance range of each workflow.

A module opts into this comparison plot by returning it from generate_comparison_plots. The figure is large enough to own its module: see proteobench.plotting.utils.accuracy_vs_abundance for what it shows and what its two dropdowns change.

Parameters:
Returns:

The figure, or a placeholder carrying an explanatory message when it cannot be built.

Return type:

go.Figure

plot_main_metric(result_df: DataFrame, metric: str = 'Median', mode: str = 'Species-weighted', colorblind_mode: bool = False, software_colors: Dict[str, str] = {'AlphaDIA': '#1D2732', 'AlphaPept': '#cc6777', 'Custom': '#000000', 'DIA-NN': '#999934', 'FragPipe': '#342288', 'FragPipe (DIA-NN quant)': '#F89008', 'MSAID': '#bfef45', 'MSAngel': '#147733', 'MaxQuant': '#88ccef', 'MetaMorpheus': '#637C7A', 'PEAKS': '#f032e6', 'ProlineStudio': '#ddcc77', 'Proteome Discoverer': '#911eb4', 'Sage': '#671100', 'Spectronaut': '#007548', 'WOMBAT': '#44aa9a', 'i2MassChroQ': '#aa4599', 'quantms': '#f5e830'}, software_markers: Dict[str, str] = {'AlphaDIA': 'star-triangle-up', 'AlphaPept': 'square', 'Custom': 'star-square', 'DIA-NN': 'star', 'FragPipe': 'x', 'FragPipe (DIA-NN quant)': 'circle-x', 'MSAID': 'square-cross', 'MSAngel': 'cross', 'MaxQuant': 'circle', 'MetaMorpheus': 'asterisk', 'PEAKS': 'diamond-wide', 'ProlineStudio': 'diamond', 'Proteome Discoverer': 'hash', 'Sage': 'triangle-down', 'Spectronaut': 'diamond-tall', 'WOMBAT': 'pentagon', 'i2MassChroQ': 'triangle-up', 'quantms': 'hexagram'}, mapping: Dict[str, str] = {'new': 20, 'old': 10}, highlight_color: str = '#d30067', label: str = '', legend_name_map: Dict[str, str] = {'AlphaPept': 'AlphaPept (legacy tool)'}, annotation: str = '', **kwargs) → Figure[source]#

Generate the main performance metric plot for LFQ HYE modules.

Parameters:
  • result_df (pd.DataFrame) – DataFrame containing the results to plot.

  • metric (str, optional) – Metric to plot, either “Median” or “Mean”.

  • mode (str, optional) – Mode of calculation, either, “Species-weighted” or “Global”. Case-insensitive.

  • colorblind_mode (Bool, optional) – If True, use different shapes for workflows.

  • software_colors (Dict[str, str]) – Mapping of software names to colors.

  • software_markers (Dict[str, str]) – Mapping of software names to markers.

  • mapping (Dict[str, str]) – Mapping for renaming software versions.

  • highlight_color (str) – Color to use for highlighting a specific software/tool.

  • label (str) – Label for the highlighted software/tool.

  • legend_name_map (Dict[str, str]) – Mapping for legend names.

  • annotation (str) – Extra text shown next to the highlighted software/tool.

  • **kwargs (dict) – Additional module-specific parameters.

Returns:

Plotly figure with the main performance metric plot.

Return type:

go.Figure

plot_precursor_overlap(workflow_1_id: str, precursors_1: Iterable[str], workflow_2_id: str, precursors_2: Iterable[str]) → Figure[source]#

Plot how many features two workflows share and how many are unique to each.

The comparison is plain set arithmetic on the feature identifiers, so it applies to every LFQ quant module, whose intermediate tables all identify features by a precursor ion or peptidoform column.

Parameters:
  • workflow_1_id (str) – Label of the first workflow, used in the legend.

  • precursors_1 (Iterable[str]) – Feature identifiers quantified by the first workflow.

  • workflow_2_id (str) – Label of the second workflow, used in the legend.

  • precursors_2 (Iterable[str]) – Feature identifiers quantified by the second workflow.

Returns:

A grouped bar chart with one bar for the features unique to each workflow and one for the features they share.

Return type:

go.Figure

class proteobench.plotting.LFQLowInputPlotGenerator(y_axis_title: str = 'Total number of features quantified in the selected number of raw files')[source]#

Bases: LFQHYEPlotGenerator

Plot generator for the low-input LFQ HYE quantification modules.

Identical to LFQHYEPlotGenerator except that it adds the inherited plot_accuracy_vs_abundance figure to the workflow comparison tab.

generate_comparison_plots(intermediates: Dict[str, DataFrame], precursor_column_name: str = 'precursor ion', **kwargs) → Dict[str, Figure][source]#

Generate the cross-workflow comparison plots of the low-input modules.

Parameters:
  • intermediates (Dict[str, pd.DataFrame]) – Mapping of workflow label (e.g. a ProteoBench ID) to that workflow’s intermediate DataFrame, as produced by QuantScoresHYE.generate_intermediate.

  • precursor_column_name (str, optional) – Name of the precursor identifier column shared across workflows.

  • **kwargs (dict) – Additional parameters forwarded to plot_accuracy_vs_abundance.

Returns:

Dictionary with the accuracy_vs_abundance figure.

Return type:

Dict[str, go.Figure]

get_comparison_plot_descriptions() → Dict[str, str][source]#

Get descriptions for each comparison tab.

Returns:

The inherited descriptions plus the one for the accuracy-vs-abundance plot.

Return type:

Dict[str, str]

get_comparison_plot_layout() → List[dict][source]#

Define the comparison tabs of the low-input modules.

Returns:

The tabs every module shows, followed by the accuracy-vs-abundance plot.

Return type:

List[dict]

class proteobench.plotting.PlotGeneratorBase[source]#

Bases: ABC

Abstract base class for module-specific plot generators. Each module can extend this to define its own in-depth plots.

abstractmethod generate_in_depth_plots(performance_data: DataFrame, **kwargs) → Dict[str, Figure][source]#

Generate module-specific plots.

Parameters:
  • performance_data (pd.DataFrame) – The performance data to plot

  • **kwargs (dict) –

    Additional module-specific parameters. Common parameters include: - parse_settings: ParseSettings - module-specific parse settings (may be optional for some modules) - metric: str - metric to display (e.g., “Median”, “Mean”) - mode: str - calculation mode (e.g., “Global”, “Species-weighted”) - colorblind_mode: bool - whether to use colorblind-friendly visualization

    Each implementation should document which parameters it accepts.

Returns:

Dictionary mapping plot names to plotly figures

Return type:

Dict[str, go.Figure]

Notes

Implementations may add parse_settings as an explicit positional parameter for consistency with generic tab code, even if not used by the module.

get_in_depth_metrics_help_markdown() → str | None[source]#

Return a Markdown explanation of how the in-depth plots are calculated.

The web interface renders this text in the “How are the metrics calculated?” popover on the tab that shows the in-depth plots of a single benchmark run. That tab does not display the main plot, so the main-plot explanation would not apply there.

Returns:

The Markdown explanation, or None when the module does not provide one. In that case the web interface hides the popover on the in-depth tab.

Return type:

str or None

abstractmethod get_in_depth_plot_descriptions() → Dict[str, str][source]#

Get descriptions for each plot.

Returns:

Dictionary mapping plot names to their descriptions

Return type:

Dict[str, str]

abstractmethod get_in_depth_plot_layout() → list[source]#

Define the layout configuration for displaying plots.

Returns:

List of plot configurations, e.g.: [

{“plots”: [“logfc”, “cv”], “columns”: 2, “title”: “Distribution Plots”}, {“plots”: [“ma_plot”], “columns”: 1, “title”: “MA Plot”}

]

Return type:

list

get_metrics_help_markdown() → str | None[source]#

Return a Markdown explanation of how the metrics of the main plot are calculated.

The web interface renders this text in a “How are the metrics calculated?” popover at the top of the tabs that show the main plot. Because the explanation describes the axes and encodings of that plot, it lives next to the code that produces it.

Returns:

The Markdown explanation, or None when the module does not provide one. In that case the web interface hides the popover.

Return type:

str or None

abstractmethod plot_main_metric(result_df: DataFrame, hide_annot: bool = False, **kwargs) → Figure[source]#

Generate the main performance metric plot for the module.

Parameters:
  • result_df (pd.DataFrame) – DataFrame containing the results to plot.

  • hide_annot (bool, optional) – Whether to hide annotations on the plot (default is False).

  • **kwargs (dict) – Additional module-specific parameters.

Returns:

The generated plotly figure for the main performance metric.

Return type:

go.Figure

Subpackages#

Submodules#