alphapepttools.metrics.pooled_median_absolute_deviation

alphapepttools.metrics.pooled_median_absolute_deviation#

alphapepttools.metrics.pooled_median_absolute_deviation(adata, group_key, *, layer=None, inplace=True)#

Compute pooled median absolute deviation (PMAD) within sample groups.

The PMAD quantifies the variability of features across samples within biologically defined groups. It is particularly useful for assessing the performance of normalization approaches, especially when groups are expected to be biologically homogeneous (Arend et al., 2025).

For each group \(g\) in a set of sample groups \(G\), the PMAD is calculated as the average median absolute deviation (MAD) across all features \(f \in F\):

\[\text{PMAD}_g = \frac{1}{|F|} \sum_{f \in F} \mathrm{MAD}_g(f)\]

where \(\mathrm{MAD}_g(f)\) is the median absolute deviation of feature \(f\) within group \(g\).

In the original publication, PMAD was computed for each group and used to compare different normalization strategies. Lower PMAD values indicate reduced intra-group variability and may suggest improved normalization.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • group_key (str) – Column in adata.obs that defines the sample groups to evaluate (e.g., biological replicates or batches).

  • layer (Optional[str] (default: None)) – Layer for which the metric is computed.

  • inplace (bool (default: True)) – If True, the results are added to adata.uns['pmad']. The object is changed in place If False, a pandas.DataFrame with the PMAD values is returned.

Return type:

None | DataFrame

Returns:

AnnData or pandas.DataFrame If inplace=True, modifies the input adata with PMAD values stored in adata.uns["metrics"]["pmad"]. If inplace=False, returns a DataFrame containing PMAD values per group.

Notes

Some normalization approaches, such as MAD-based normalization, explicitly minimize intra-group variability. In such cases, PMAD may directly reflect the objective of the normalization procedure, and its interpretation should be made alongside other complementary metrics.

References

  • Arend, L. et al. Systematic evaluation of normalization approaches in tandem mass tag and label-free protein quantification data using PRONE. Briefings in Bioinformatics, 26, bbaf201 (2025).