feature_plot()

Plot a unified feature plot with box/violin plots and optional scatter points.

Usage

Source

feature_plot(
    df,
    feature,
    conditions,
    axes=None,
    x_label=True,
    ymax=None,
    condition_col="condition",
    selector_col="cell_line",
    selector_val="",
    title="",
    colors=None,
    fig_size=(5, 5),
    size_units="cm",
    scale=False,
    violin=False,
    show_scatter=True,
    legend=True,
    group_size=1,
    within_group_spacing=0.2,
    between_group_gap=0.5,
    paired=True,
    show_significance=True,
    show_ns=True,
    scatter_size=7.0,
    min_effect=None,
    normalise_within_plate=True,
    save=True,
    save_stats=False,
    path=None,
    tight_layout=False,
    file_format="pdf",
    dpi=300
)

This is a backward-compatible wrapper around the new class-based architecture. The feature plot can show either boxplots or violin plots, with optional scatter points overlaid, plus median points and significance marks. Statistical analysis is shown for all group sizes.

Data Filtering df : pd.DataFrame The dataframe to plot containing single-cell measurements. feature : str The feature column to plot. conditions : list[str] The conditions to plot. condition_col : str, default=“condition” The column name for the conditions. selector_col : Optional[str], default=“cell_line” The column name for the selector. selector_val : Optional[str], default=“” The value of the selector.

Display Options ^ violin : bool, default=False Whether to use violin plots instead of box plots. show_scatter : bool, default=True Whether to show scatter points overlay. ymax : float | tuple[float, float] | None, default=None The y-axis maximum value. scale : bool, default=False Whether to scale the data.

Grouping & Layout ^ group_size : int, default=1 The number of conditions to group. paired : bool, default=True Use a paired t-test (ttest_rel, matched by plate_id) for significance; set False for the unpaired ttest_ind. show_significance : bool, default=True Annotate significance marks. Set False to plot the distributions and the per-repeat medians without a test – appropriate when n is small enough that the reader should judge the spread directly, or when many comparisons are shown side by side without correction. normalise_within_plate : bool, default=True Test the per-plate log fold-change ln(cond/control) vs 0 rather than the absolute feature difference. Removes a multiplicative plate baseline so significance tracks effect size (suited to area/intensity readouts). Requires paired=True; set False for the legacy absolute test. within_group_spacing : float, default=0.2 The spacing between conditions within a group. between_group_gap : float, default=0.5 The gap between groups.

Styling & Colors title : Optional[str], default=“” The title of the plot. colors : list[str], default=COLORS The colors to use for the plot. legend : bool, default=True Whether to show the default plate legend. x_label : bool, default=True Whether to show the x-label. axes : Optional[Axes], default=None The axis to plot on.

Layout & Sizing ^ fig_size : tuple[float, float], default=(5, 5) The size of the figure. size_units : str, default=“cm” The units of the figure size.

Save Options save : bool, default=True Whether to save the plot. save_stats : bool, default=False Write {title}_stats.csv and {title}_medians.csv to path (independent of save; works when plotting onto a provided/composed axes). path : Optional[Path], default=None The path to save the plot. file_format : str, default=“pdf” The format of the saved figure. tight_layout : bool, default=False Whether to use tight layout. dpi : int, default=300 The resolution of the saved figure.

tuple[Figure, Axes] The figure and axes objects.