combplot_feature()
Create a combined plot with histograms and scatter plots for feature analysis.
Usage
combplot_feature(
df,
conditions,
feature,
threshold=None,
condition_col="condition",
selector_col="cell_line",
selector_val=None,
title=None,
cell_number=3000,
fig_size=None,
size_units="cm",
save=True,
path=None,
file_format="png",
dpi=300,
figure=None,
show_ylabel=True,
show_xlabel=True
)Creates a (2 + n_features)×n_conditions grid layout that grows vertically with the number of features supplied:
- Top row: DNA content histograms for each condition.
- Second row: DNA vs EdU scatter plots with cell cycle phases.
- One additional row per feature: DNA vs feature scatter plots with optional threshold colouring.
Passing a single feature string reproduces the classic three-row layout (histogram → EdU → feature); passing a list of features stacks one scatter row per feature underneath the EdU row.
Data Filtering df : pd.DataFrame DataFrame containing single-cell measurements. conditions : list[str] List of condition names to plot. condition_col : str, default=“condition” Column name for experimental condition. selector_col : Optional[str], default=“cell_line” Column name for selector (e.g., cell line). selector_val : Optional[str], default=None Value to filter selector_col by.
Plot Configuration feature : str | list[str] Feature column name(s) for the stacked scatter rows. A single string creates one feature row; a list creates one row per entry, in order. threshold : float | list[float | None] | None, default=None Threshold value(s) for feature colouring (below=blue, above=red). A scalar (or None) is applied to every feature row; a list must match the length of feature, with None entries disabling the threshold for that row. cell_number : Optional[int], default=3000 Number of cells to sample per condition for plotting.
Styling & Layout title : Optional[str], default=None Plot title. If None, generates default title. fig_size : Optional[tuple[float, float]], default=None Figure size as (width, height). When None the height scales with the number of rows (matching the classic (10, 7) default for a single feature). size_units : str, default=“cm” Units for fig_size (“cm” or “inches”).
Save Options save : bool, default=True Whether to save the figure. path : Optional[Path], default=None Directory path for saving the figure. file_format : str, default=“png” File format for saving (“png”, “pdf”, “svg”, etc.). dpi : int, default=300 Resolution for saved figure.
tuple[Figure, list] The figure object and list of axes objects.
Classic single-feature layout:
>>> fig, axes = combplot_feature(
... df=data,
... conditions=["control", "treatment1", "treatment2"],
... feature="intensity_mean_p21_nucleus",
... threshold=5000,
... selector_col="cell_line",
... selector_val="MCF10A",
... )Stack several features as extra rows (one threshold per feature, None to disable):
>>> fig, axes = combplot_feature(
... df=data,
... conditions=["control", "treatment1"],
... feature=[
... "intensity_mean_p21_nucleus",
... "intensity_mean_p53_nucleus",
... "area_cell",
... ],
... threshold=[5000, 3000, None],
... selector_col="cell_line",
... selector_val="MCF10A",
... )