app.components.figures package

Submodules

app.components.figures.bar_graph module

Bar graph utilities using Plotly Express and Dash.

Provides a configurable bar plot builder and a Dash Graph factory.

app.components.figures.bar_graph.bar_plot(defaults, value_df, title, x_name=None, x_label=None, sort_x=None, y_name=None, y_label=None, y_idx=0, barmode='relative', color=True, color_col=None, hide_legend=False, color_discrete_map=False, color_discrete_map_dict=None, width=None, height=None)[source]

Draw a bar plot from the given input.

Parameters:
  • defaults (dict) – Dictionary of default values for the figure.

  • value_df (DataFrame) – DataFrame containing the plot data.

  • title (str) – Title for the figure.

  • x_name (str) – Column to use for x-axis; if None, index is reset and the new column is used.

  • x_label (str) – Axis label to use for X regardless of x_name.

  • sort_x (bool) – If True ascending, False descending, None leaves default order.

  • y_name (str) – Column to use for y-axis; if None, use y_idx.

  • y_label (str) – Axis label to use for Y regardless of y_name/y_idx.

  • y_idx (int) – Index of the column to use for y-axis when y_name is None.

  • barmode (str) – Plotly Express bar barmode.

  • color (bool) – If True, use column Color unless color_col is provided.

  • color_col (str) – Explicit name of color column.

  • hide_legend – If True, hides the legend.

  • color_discrete_map – If True, use 'identity' mapping or a provided dict.

  • color_discrete_map_dict (dict) – Explicit map for colors.

  • width (int | None) – Figure width; if None, derived from defaults and min width policy.

  • height (int | None) – Figure height; if None, derived from defaults.

Return type:

bar

Returns:

A Plotly Express bar figure.

app.components.figures.bar_graph.make_graph(graph_id, defaults, dlname, *args, **kwargs)[source]

Create a Dash Graph configured with a bar plot.

Parameters:
  • graph_id (str) – Component ID for the Graph.

  • defaults (dict) – Dictionary with config, height, width and related settings.

  • dlname – Name for the downloaded figure file.

  • args – Positional arguments forwarded to bar_plot.

  • kwargs – Keyword arguments forwarded to bar_plot.

Return type:

Graph

Returns:

Dash Graph instance.

app.components.figures.before_after_plot module

Before/After grouped bar plot for paired counts.

Builds a simple grouped bar chart comparing two Series (before vs after) per sample, returning a Dash Graph component.

app.components.figures.before_after_plot.make_graph(defaults, before, after, graph_id, dlname, title=None)[source]

Create a grouped bar chart comparing before vs after counts.

Parameters:
  • defaults (dict) – Dictionary with config, height, width and related settings.

  • before (Series) – Series of counts before, indexed by sample.

  • after (Series) – Series of counts after, indexed by sample.

  • graph_id (str) – Component ID for the Graph.

  • dlname (str) – Name for the downloaded figure file.

  • title (str) – Optional chart title.

Return type:

Graph

Returns:

Dash Graph instance containing the grouped bar plot.

app.components.figures.color_tools module

Color utilities for Plotly/Dash figures.

Includes helpers to translate color formats, darken colors, trim overly light template colors, and assign consistent group/sample colors.

app.components.figures.color_tools.darken(color, percent)[source]

Darken a given RGB(A) color by a percentage.

Parameters:
  • color (str) – Color as "rgb(r,g,b)" or "rgba(r,g,b,a)".

  • percent (int) – Percentage to darken (0–100).

Return type:

str

Returns:

Darkened color string of the same type.

app.components.figures.color_tools.get_assigned_colors(sample_group_dict)[source]

Assign per-group and per-sample colors.

Parameters:

sample_group_dict (dict) – Mapping of group name to list of sample names.

Return type:

dict

Returns:

Tuple (colors, colors_with_contaminant) where both are dicts with keys 'samples' and 'sample groups'.

app.components.figures.color_tools.get_cut_colors(colormapname='gist_ncar', number_of_colors=15, cut=0.4)[source]

Return a list of evenly spaced colors from a matplotlib colormap.

Parameters:
  • colormapname (str) – Matplotlib colormap name.

  • number_of_colors (int) – Number of colors to sample.

  • cut (float) – Brightness adjustment mixed with white (0–1).

Return type:

list

Returns:

List of RGBA tuples in 0–1 range.

app.components.figures.color_tools.remove_unwanted_colors(figure_template)[source]

Return a Plotly template with overly light colors darkened.

The function reads the colorway from the named template and adjusts entries with high luminance to improve visibility on light backgrounds.

Parameters:

figure_template (str) – Name of a Plotly template (e.g., "plotly").

Return type:

str

Returns:

Modified template object with updated layout.colorway.

app.components.figures.color_tools.rgba_to_hex(rgba)[source]

Convert an RGBA color string to hex.

Parameters:

rgba (str) – Input as "rgba(r,g,b,a)".

Return type:

str

Returns:

Hex color string, e.g. "#RRGGBB".

app.components.figures.commonality_graph module

Commonality visualizations for sample group overlaps.

Provides two representations: - supervenn: Supervenn diagram for up to ~10 sets - common_heatmap: Jaccard-like overlap heatmap for larger numbers

class app.components.figures.commonality_graph.Intersection(bits, label, size)[source]

Bases: object

Representation of an intersection used for plotting.

bits: Tuple[bool, ...]
label: str
size: int
app.components.figures.commonality_graph.create_upset_figure(set_membership, *, top_n=15, min_size=1, title='UpSet Plot')[source]

Build a Plotly UpSet graph representing set intersections.

Parameters:
  • set_membership (Mapping[str, Iterable[object]]) – Mapping of set label to an iterable of hashable entries.

  • top_n (int | None) – Optional limit for the number of intersection bars to show.

  • min_size (int) – Minimum intersection size; smaller entries are dropped.

  • title (str) – Figure title.

Return type:

Figure

Returns:

plotly.graph_objects.Figure configured with bar and matrix sections.

app.components.figures.commonality_graph.make_graph(group_sets, id_str, defaults)[source]

Choose and build an overlap visualization based on group count.

Parameters:
  • group_sets (dict) – Mapping of group name to a set of identifiers.

  • id_str (str) – Component ID for the output figure.

  • use_supervenn – If True, prefer Supervenn when feasible.

  • defaults (dict) – Figure defaults (expects height, width, config).

Return type:

tuple

Returns:

Tuple of (component, aux_data) where aux_data may be a base64 PDF.

app.components.figures.comparative_plot module

Comparative violin/box plot for grouped data frames.

Takes a list of DataFrames (columns = replicates), stacks values into a long format and renders either grouped violin or box plots.

app.components.figures.comparative_plot.make_graph(id_name, sets, defaults, dlname, names=None, replicate_colors=None, points_visible='outliers', title=None, showbox=False, plot_type='violin')[source]

Create a comparative violin/box plot from multiple DataFrames.

Parameters:
  • id_name (str) – Component ID for the Graph; default name used if None.

  • sets (list) – List of DataFrames; each column is treated as a replicate.

  • defaults (dict) – Dictionary with config, height, width and related settings.

  • dlname (str) – Name for the downloaded figure file.

  • names (list) – Optional list of labels for each DataFrame in sets.

  • replicate_colors (dict) – Mapping with 'sample groups' color strings per name.

  • points_visible (str) – Violin/box points visibility (e.g., 'outliers' or False).

  • title (str) – Optional title.

  • showbox (bool) – For violin, whether to show the internal box.

  • plot_type (str) – 'violin' or 'box'.

Return type:

Graph

Returns:

Dash Graph instance with the figure.

app.components.figures.cvplot module

Coefficient of variation (CV) plot per sample group.

Computes per-group mean, std and CV, and renders a violin plot with mean annotations for each group.

app.components.figures.cvplot.make_graph(raw_data, sample_groups, replicate_colors, defaults, id_name, dlname)[source]

Create a CV violin plot across sample groups.

Parameters:
  • raw_data (DataFrame) – DataFrame of values; columns referenced by sample_groups.

  • sample_groups (dict) – Mapping group -> list of column names.

  • replicate_colors (dict) – Mapping with 'sample groups' color strings per group.

  • defaults (dict) – Dictionary with config, height, width and related settings.

  • id_name (str) – Component ID for the Graph.

  • dlname (str) – Name for the downloaded figure file.

Returns:

Tuple (Graph, out_data) where out_data contains group stats.

app.components.figures.figure_legends module

Legend helpers for QC, proteomics, and interactomics figures.

Provides prewritten legend paragraphs and small utilities for dynamic legend generation and templating.

app.components.figures.figure_legends.enrichment_legend(clean_enrichment_name, enrichment_name, fc_col, fc_threshold, p_value_name, p_threshold)[source]

Legend paragraph for enrichment plot settings.

Parameters:
  • clean_enrichment_name – Clean identifier for the element ID.

  • enrichment_name – Display name of the enrichment.

  • fc_col – Fold change column used for filtering.

  • fc_threshold – Fold change threshold value.

  • p_value_name – P-value column name used for filtering.

  • p_threshold – P-value threshold.

Returns:

dash.html.P element.

app.components.figures.figure_legends.leg_rep(legend, replace, rep_with)[source]

Replace text in an existing legend paragraph.

Parameters:
  • legend – Existing dash.html.P element.

  • replace – Substring to replace.

  • rep_with – Replacement string.

Return type:

P

Returns:

New P element with modified text.

app.components.figures.figure_legends.saint_legend(rescued)[source]

Legend for SAINT filtered counts with rescue flag.

Parameters:

rescued (bool) – Whether preys were rescued across baits.

Return type:

P

Returns:

dash.html.P element.

app.components.figures.figure_legends.volcano_heatmap_legend(control, id_prefix)[source]

Legend paragraph for multi-comparison volcano heatmap.

Parameters:
  • control – Control name used in comparisons.

  • id_prefix – Prefix for the element ID.

Return type:

P

Returns:

dash.html.P element.

app.components.figures.figure_legends.volcano_plot_legend(sample, control, id_prefix)[source]

Create a legend paragraph for a volcano plot comparison.

Parameters:
  • sample – Sample name.

  • control – Control name.

  • id_prefix – Prefix for the element ID.

Return type:

P

Returns:

dash.html.P element.

app.components.figures.heatmaps module

Heatmap utilities, including clustered correlation heatmaps.

Provides a dendrogram-coupled clustergram builder and a simple imshow heatmap factory for numeric matrices.

app.components.figures.heatmaps.draw_clustergram(plot_data, defaults, color_map=None, **kwargs)[source]

Draw a clustered correlation heatmap with dendrograms.

Parameters:
  • plot_data – Square DataFrame-like correlation matrix (symmetric).

  • defaults – Dict with height and width.

  • color_map (list | None) – Plotly colorscale list; defaults to white→red.

  • kwargs – Optional zmin and zmax overrides.

Return type:

Figure

Returns:

Plotly Figure containing the clustergram.

Raises:

ValueError – If input is not square.

app.components.figures.heatmaps.make_heatmap_graph(matrix_df, plot_name, value_name, defaults, cmap, dlname, autorange=False, symmetrical=True, cluster=None)[source]

Create a simple heatmap as a Dash Graph.

Parameters:
  • matrix_df – DataFrame with numeric values to plot.

  • plot_name (str) – Name suffix for component ID.

  • value_name (str) – Colorbar label.

  • defaults (dict) – Dict with height, width, config.

  • cmap (str) – Plotly continuous color scale name.

  • dlname (str) – Name for the downloaded figure file.

  • autorange (bool) – If True, derive zmin from data with padding.

  • symmetrical (bool) – If True, use symmetric min/max around zero.

  • cluster (str) – If not None, apply clustering via matrix_functions.

Return type:

Graph

Returns:

Dash Graph component with the heatmap figure.

app.components.figures.histogram module

Histogram figure utilities.

Provides a simple wrapper around Plotly Express histogram construction with sensible defaults drawn from a defaults dictionary.

app.components.figures.histogram.make_figure(data_table, x_column, title, defaults, **kwargs)[source]

Create a histogram figure using Plotly Express.

Parameters:
  • data_table (DataFrame) – Input DataFrame.

  • x_column (str) – Column name to plot on the x-axis.

  • title (str) – Figure title.

  • defaults (dict) – Dict with height and width.

  • kwargs – Additional Plotly Express histogram kwargs; height, width, and nbins defaulted if missing.

Return type:

Figure

Returns:

Plotly Figure.

app.components.figures.imputation_histogram module

Histogram comparing imputed vs non-imputed distributions.

Builds a violin-marginal histogram and highlights imputed values for visual comparison of value distributions.

app.components.figures.imputation_histogram.make_graph(non_imputed, imputed, defaults, dlname, id_name=None, title=None, **kwargs)[source]

Create a histogram comparing imputed vs non-imputed values.

Parameters:
  • non_imputed – DataFrame before imputation.

  • imputed – DataFrame after imputation.

  • defaults – Dict with height, width, config.

  • dlname (str) – Name for the downloaded figure file.

  • id_name (str) – Component ID for the Graph.

  • title (str) – Figure title.

  • kwargs – Additional keyword args forwarded to Plotly Express histogram.

Return type:

Graph

Returns:

Dash Graph containing the histogram figure.

app.components.figures.network_plot module

Network visualization utilities using Dash Cytoscape.

Creates Cytoscape elements and container for displaying bait–prey interaction networks with selectable layouts and styles.

app.components.figures.network_plot.get_cytoscape_container(cyto_elements, full_height)[source]

Build a Cytoscape container with controls and the graph component.

Parameters:
  • cyto_elements – List of Cytoscape nodes and edges.

  • full_height – CSS height string (e.g., "600px").

Returns:

Dash html.Div containing the Cytoscape graph and layout selector.

app.components.figures.network_plot.get_cytoscape_elements_and_ints(interaction_data)[source]

Convert interaction table to Cytoscape elements and a dict index.

Parameters:

interaction_data – DataFrame with columns including Bait, Prey, PreyGene, AvgSpec.

Returns:

Tuple (elements, interactions) where elements is a list of nodes/edges and interactions is a nested dict.

app.components.figures.network_plot.get_stylesheet()[source]

Return the default Cytoscape stylesheet for bait/prey nodes.

Returns:

List of stylesheet dictionaries.

app.components.figures.reproducibility_graph module

Reproducibility plots for deviations from sample-group means.

Generates per-replicate histograms of deviations from group mean and lays them out in a grid for quick visual inspection.

app.components.figures.reproducibility_graph.get_max(plot_data, minval=2)[source]

Return the maximum absolute deviation across all replicates.

Parameters:
  • plot_data (dict) – Output from get_reproducibility_dataframe.

  • minval – Minimum value to enforce.

Return type:

int

Returns:

Integer maximum used for x-axis range sizing.

app.components.figures.reproducibility_graph.get_reproducibility_dataframe(data_table, sample_groups)[source]

Compute per-replicate deviations from the group mean.

Parameters:
  • data_table (DataFrame) – DataFrame with sample columns.

  • sample_groups (dict) – Mapping group -> list of column names.

Return type:

DataFrame

Returns:

Nested dict {group: {replicate: [deviations...]}} suitable for plotting.

app.components.figures.reproducibility_graph.make_graph(graph_id, defaults, plot_data, title, table_type, dlname, num_per_row=2)[source]

Create a grid of histograms of deviations from group mean.

Parameters:
  • graph_id (str) – Component ID for the Graph.

  • defaults (dict) – Dict with height, width, config.

  • plot_data (dict) – Nested dict from get_reproducibility_dataframe.

  • title (str) – Plot title.

  • table_type (str) – Label for x-axis description.

  • dlname (str) – Name for the downloaded figure file.

  • num_per_row (int) – Number of subplots per row.

Return type:

Graph

Returns:

Dash Graph with the subplot figure.

app.components.figures.scatter module

Scatter plot utilities with categorical coloring.

Offers a figure factory that preserves input categorical color order and a Dash Graph wrapper.

app.components.figures.scatter.make_figure(defaults, data_table, x, y, color_col, name_col, msize=15, improve_text_pos=True, **kwargs)[source]

Create a scatter plot with per-category colors and labels.

Parameters:
  • defaults (dict) – Dict with height, width.

  • data_table (DataFrame) – Input DataFrame.

  • x (str) – Column name for x-axis.

  • y (str) – Column name for y-axis.

  • color_col (str) – Column containing color strings.

  • name_col (str) – Column used for categories and hover names.

  • msize (int) – Marker size.

  • improve_text_pos (bool) – If True, adjust text positions heuristically.

  • kwargs – Additional keyword args forwarded to Plotly Express scatter.

Return type:

Figure

Returns:

Plotly Figure.

app.components.figures.scatter.make_graph(id_name, defaults, dlname, *args, **kwargs)[source]

Wrap the scatter figure in a Dash Graph component.

Parameters:
  • id_name – Component ID for the Graph.

  • defaults – Dict including a config key passed to the component.

  • dlname – Name for the downloaded figure file.

  • args – Positional args passed to make_figure.

  • kwargs – Keyword args passed to make_figure.

Return type:

Graph

Returns:

Dash Graph component.

app.components.figures.tic_graph module

Total ion chromatogram (TIC) and base peak figure utilities.

Builds a Plotly figure from precomputed JSON traces with automatic sizing and hover behavior.

app.components.figures.tic_graph.tic_figure(defaults, traces, datatype='TIC', height=None, width=None)[source]

Create a TIC/trace figure from serialized Plotly traces.

Parameters:
  • defaults (dict) – Dict with height and width fallbacks.

  • traces (dict) – Dict with keys for datatypes; each contains max_x, max_y, and a list of traces as Plotly JSON.

  • datatype (str) – Which trace set to render (e.g., 'TIC').

  • height (int) – Optional explicit height.

  • width (int) – Optional explicit width.

Returns:

Plotly Figure with added traces and layout.

app.components.figures.volcano_plot module

Volcano plots and significant-difference heatmaps.

Provides a Plotly volcano plot builder and utilities to generate a set of volcano graphs and an aggregate heatmap of significant changes.

app.components.figures.volcano_plot.generate_graphs(significant_data, defaults, fc_thr, p_thr, id_prefix)[source]

Generate volcano plots and a heatmap for significant changes.

Parameters:
  • significant_data (DataFrame) – Long-form DataFrame with at least Sample, Control, fold_change, p_value_adj columns.

  • defaults (dict) – Dict with figure defaults and component config.

  • fc_thr (float) – Absolute log2 fold change threshold for significance.

  • p_thr (float) – Adjusted p-value threshold.

  • id_prefix (str) – Prefix used for generated component IDs.

Return type:

Div

Returns:

dash.html.Div containing headers, plots, and legends.

app.components.figures.volcano_plot.volcano_plot(data_table, defaults, title=None, fc_axis_min_max=2, highlight_only=None, adj_p_threshold=0.01, fc_threshold=1.0)[source]

Draw a volcano plot from a differential results table.

Parameters:
  • data_table – Data from stats.differential; only one comparison expected.

  • defaults – Dict with height and width for the figure.

  • title (str) – Figure title.

  • fc_axis_min_max (float) – Minimum absolute FC range to avoid narrow plots.

  • adj_p_threshold (float) – Adjusted p-value threshold (q-value).

  • fc_threshold (float) – Absolute log2 fold change threshold for significance.

  • highlight_only (list) – Optional set/list; only significant points with names in this set are labeled.

Return type:

Figure

Returns:

Plotly Figure.

Module contents

Figure generation subpackage.