.summarize_overlapping_peptides

proteopy.pp.summarize_overlapping_peptides(adata, group_by='protein_id', layer=None, func='sum', zero_to_na=False, fill_na=None, skip_na=True, inplace=True)[source]

Aggregate intensities across overlapping peptides.

Calls extract_peptide_groups() internally to identify overlapping (substring-contained) peptides, then aggregates intensities within each group.

  • Uses the longest peptide_id in each group as the new var_name.

  • Keeps both the representative peptide_id as a column and index.

  • Retains the grouping key as 'peptide_group_id'.

  • Concatenates differing .var annotations using ';'.

Parameters:
  • adata (AnnData) – AnnData with peptide-level data.

  • group_by (str or None, optional) – Column in adata.var to partition peptides before grouping. Passed to extract_peptide_groups(). When set (e.g. 'protein_id'), substring containment is only evaluated among peptides sharing the same value in this column. When None, all peptides are grouped globally.

  • layer (str, optional) – Key in adata.layers specifying which matrix to aggregate; defaults to .X.

  • func ({'sum', 'mean', 'median', 'max'} or Callable) – Aggregation applied across peptides in each group.

  • zero_to_na (bool, optional) – If True, replace zeros with np.nan before aggregation.

  • fill_na (float or int, optional) – Replace np.nan values with this constant before aggregation.

  • skip_na (bool, optional) – If True, ignore np.nan during aggregation. If False, any np.nan in a group produces np.nan in the result.

  • inplace (bool, optional) – If True, modifies adata in place. Otherwise returns a new AnnData.

Returns:

Aggregated AnnData if inplace=False, else modifies in place.

Return type:

AnnData | None