.completeness_per_sample
- proteopy.pl.completeness_per_sample(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 sample (observation).
For each sample (row), completeness is the fraction of variables (columns) with non-missing values. When
group_by_resolutionis provided, shows the fraction of variable-groups in which each sample is detected. Whengroup_by_partitionis provided, shows boxplots of per-sample completeness within each partition group.- Parameters:
adata (AnnData) –
AnnDataobject 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 whengroup_by_partitionis provided. Groups not listed are excluded.group_by_partition (
str|None) – Column in.varused to partition variables. For each group, completeness fractions are computed per sample and displayed as side-by-side boxplots. Mutually exclusive withgroup_by_resolution.group_by_resolution (
str|None) – Column in.varused to define detection groups. When provided, the plot shows the fraction of groups in which each sample is detected.min_count (int or None, optional) – Minimum number of non-missing variables within a group for a sample to be considered detected. Mutually exclusive with
min_fraction. Only used whengroup_by_resolutionis provided.min_fraction (float or None, optional) – Minimum fraction of non-missing variables within a group for a sample to be considered detected. Mutually exclusive with
min_count. Only used whengroup_by_resolutionis 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_partitionis 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 withplt.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_sample(adata, fraction_thresh=0.5)
With peptide-level proteodata, grouping by
protein_idyields the fraction of proteins detected per sample.>>> pr.pl.completeness_per_sample( ... adata, ... group_by_resolution="protein_id", ... min_count=1, ... )