.normalize_median

proteopy.pp.normalize_median(adata, method, log_space, fill_na=None, zeros_to_na=False, batch_id=None, inplace=True, force=False)[source]

Median normalization of intensities.

Parameters:
  • adata (AnnData) – Input AnnData.

  • method ({'max_ref', 'median_ref'}) – How to choose the reference across sample medians. 'max_ref' uses the maximum sample median, 'median_ref' uses the median of sample medians.

  • log_space (bool) – Whether the input intensities are log-transformed. Mismatches with automatic detection raise unless force=True.

  • fill_na (float, optional) – Temporarily replace non-finite entries with this value for the median computation only; original values are restored afterward.

  • zeros_to_na (bool, default False) – Treat zeros as missing for the median computation only; original zeros are restored afterward.

  • batch_id (str, optional) – Column in adata.obs to perform normalization within batches.

  • inplace (bool, default True) – Modify adata in place. If False, return a copy.

  • force (bool, default False) – Proceed even if log_space disagrees with automatic log detection.

Notes

Median normalization:
log_space=True

X + ref - sample_median

log_space=False

X * ref / sample_median

'max_ref'

reference = max of sample medians (within batch if per_batch)

'median_ref'

reference = median of sample medians (within batch if per_batch)

Returns:

  • AnnData or None – Normalized AnnData when inplace is False; otherwise None.

  • pandas.DataFrame, optional – Per-sample factors when inplace is False.

Parameters: