acidbase.fold_change_to_log_ratio

acidbase.fold_change_to_log_ratio(x: float | ndarray, base: int = 2) float | ndarray

Convert fold change to log ratio.

Parameters:
  • x (float or array-like) – Fold-change values. Negative values are treated as reciprocal fold changes: -4 means 1/4.

  • base (int) – Logarithm base (default 2).

Returns:

Log-ratio values.

Return type:

float or numpy.ndarray

Notes

Matches R’s foldChangeToLogRatio semantics: negative fold changes are first transformed to 1 / -x before taking the logarithm, so the result is negative (down-regulation) as expected.