smftools.plotting.plotting_utils#

Functions

clean_barplot(ax, mean_values, title, *[, ...])

Format a barplot with consistent axes and labels.

make_row_colors(meta)

Convert metadata columns to RGB colors without invoking pandas Categorical.map (MultiIndex-safe, category-safe).

methylation_fraction(matrix, *[, ...])

Fraction methylated per column.

normalized_mean(matrix, *[, ignore_nan])

Compute normalized column means for a matrix.

smftools.plotting.plotting_utils.normalized_mean(matrix, *, ignore_nan=True)#

Compute normalized column means for a matrix.

Parameters:

matrix (ndarray) -- Input matrix.

Return type:

ndarray

Returns:

1D array of normalized means.

smftools.plotting.plotting_utils.methylation_fraction(matrix, *, ignore_nan=True, zero_is_valid=False)#

Fraction methylated per column. Methylated = 1 Valid = finite AND not 0 (unless zero_is_valid=True)

Return type:

ndarray

smftools.plotting.plotting_utils.clean_barplot(ax, mean_values, title, *, y_max=1.0, y_label='Mean', y_ticks=None)#

Format a barplot with consistent axes and labels.

Parameters:
  • ax -- Matplotlib axes.

  • mean_values -- Values to plot.

  • title -- Plot title.

  • y_max (float | None (default: 1.0)) -- Optional y-axis max; inferred from data if not provided.

  • y_label (str (default: 'Mean')) -- Y-axis label.

  • y_ticks (list[float] | None (default: None)) -- Optional y-axis ticks.

smftools.plotting.plotting_utils.make_row_colors(meta)#

Convert metadata columns to RGB colors without invoking pandas Categorical.map (MultiIndex-safe, category-safe).

Return type:

DataFrame