.completeness_per_var

proteopy.pl.completeness_per_var(adata, layer=None, zero_to_na=False, order=None, group_by_partition=None, group_by_resolution=None, min_count=None, min_fraction=None, fraction_thresh=None, print_stats=False, bin_width=0.01, xlabel_rotation=0.0, figsize=(6.0, 5.0), show=True, ax=None, save=None)[source]

Plot a histogram of completeness per variable.

For each variable (column), completeness is the fraction of observations (rows) with non-missing values. When group_by_resolution is provided, shows the fraction of observation-groups in which each variable is detected. When group_by_partition is provided, shows boxplots of per-variable completeness within each partition group.

Parameters:
  • adata (AnnData) – AnnData object in proteodata format.

  • layer (str | None) – Name of the layer to use instead of .X.

  • zero_to_na (bool) – Treat zero entries as missing values when True.

  • order (Optional[Sequence[Any]]) – Explicit ordering and subsetting of groups when group_by_partition is provided. Groups not listed are excluded.

  • group_by_partition (str | None) – Column in .obs used to partition observations. For each group, completeness fractions are computed per variable and displayed as side-by-side boxplots. Mutually exclusive with group_by_resolution.

  • group_by_resolution (str | None) – Column in .obs used to define detection groups. When provided, the plot shows the fraction of groups in which each variable is detected.

  • min_count (int or None, optional) – Minimum number of non-missing observations within a group for a variable to be considered detected. Mutually exclusive with min_fraction. Only used when group_by_resolution is provided.

  • min_fraction (float or None, optional) – Minimum fraction of non-missing observations within a group for a variable to be considered detected. Mutually exclusive with min_count. Only used when group_by_resolution is provided.

  • fraction_thresh (float or None, optional) – Completeness fraction threshold in [0, 1]. Drawn as a vertical dashed line on histograms or a horizontal dashed line on boxplots (group_by_partition).

  • print_stats (bool, optional) – Print completeness distribution statistics before plotting. When group_by_partition is provided, per-group statistics are printed below the global summary.

  • bin_width (float, optional) – Width of each histogram bin on the fraction axis. Bins span from 0.0 to 1.0 + bin_width. Defaults to 0.01.

  • xlabel_rotation (float) – Rotation angle in degrees applied to x-axis tick labels.

  • figsize (tuple[float, float]) – Tuple (width, height) controlling figure size in inches.

  • show (bool) – Display the plot with plt.show() when True.

  • ax (Axes or None, optional) – Matplotlib Axes object to plot onto. If None, a new figure and axes are created.

  • save (str or Path or None, optional) – File path to save the figure. If None, do not save.

Returns:

The Matplotlib Axes object used for plotting.

Return type:

Axes

Examples

>>> import proteopy as pr
>>> adata = pr.datasets.example_peptide_data()
>>> pr.pl.completeness_per_var(adata, fraction_thresh=0.7)
>>> pr.pl.completeness_per_var(
...     adata,
...     group_by_resolution="condition",
...     min_count=1,
... )
>>> pr.pl.completeness_per_var(
...     adata,
...     group_by_partition="condition",
...     order=["control", "treatment"],
... )