plot_bars#

RAPDOR.plots.plot_bars(subdata, design, x, offset: int = 0, colors=None, yname: str = 'rel. protein amount', barmode: str = 'overlay')#

Plots bar charts with overlaid scatter markers and quantile-based error bars for grouped protein abundance data across experimental conditions.

This function groups samples by treatment (as specified in the design DataFrame), computes mean and interquartile range (25–75%) for each group, and visualizes the results using Plotly bars and error bars.

Parameters:
  • subdata (np.ndarray) – A 2D NumPy array with shape (n_samples, n_features), containing protein abundance values. Sample indices must align with the design DataFrame.

  • design (pd.DataFrame) – A DataFrame that includes a “Treatment” column mapping sample indices to group labels.

  • x (list) – A list of original x-axis labels corresponding to features (e.g., protein IDs or timepoints).

  • offset (int, optional) – Index offset applied to the x list to align with subdata columns. Default is 0.

  • colors (list, optional) – A list of color values to be used for each treatment group. If None, default colors are used.

  • yname (str, optional) – Y-axis label for the plot. Defaults to “rel. protein amount”.

  • barmode (str, optional) – Bar layout mode for Plotly. Options include “overlay” and “group”. Default is “overlay”.

Returns:

A Plotly figure containing the bar chart with overlaid quantile scatter markers and error bars.

Return type:

plotly.graph_objects.Figure

Notes

  • For each group in design[“Treatment”], the function computes:
    • Mean protein abundance across group samples.

    • 25th and 75th quantiles to derive error bars.

  • Each group is visualized using a combination of bars and markers.

  • Hover mode is set to “x” for better interactivity.

Example

fig = plot_bars(

subdata=protein_array, design=sample_design_df, x=[“P1”, “P2”, “P3”], colors=[“#1f77b4”, “#ff7f0e”]

) fig.show()