capellini.utils.transforms

Numerical transformations: CLR, row normalization, shrinkage correlation.

Functions

clr(X[, pseudocount, eps])

Row-wise centered log-ratio transform.

row_normalize(W[, eps])

Row-normalize a matrix so each row sums to 1.

schaefer_strimmer_corr(X)

Schäfer-Strimmer shrinkage correlation estimator.

capellini.utils.transforms.clr(X, pseudocount: float = 1e-06, eps: float = 1e-12)[source]

Row-wise centered log-ratio transform.

Parameters:
  • X – Nonnegative array-like of shape (n_samples, n_features).

  • pseudocount – Constant added before the log to handle zeros.

  • eps – Numerical stability constant inside the log.

Returns:

CLR-transformed numpy array.

capellini.utils.transforms.row_normalize(W, eps: float = 1e-12)[source]

Row-normalize a matrix so each row sums to 1.

Parameters:
  • W – Matrix-like.

  • eps – Small constant to avoid division by zero.

Returns:

Row-normalized numpy array.

capellini.utils.transforms.schaefer_strimmer_corr(X: DataFrame) tuple[DataFrame, dict][source]

Schäfer-Strimmer shrinkage correlation estimator.

Parameters:

X – Samples x features DataFrame (at least 3 samples required).

Returns:

Tuple (shrinkage_correlation_DataFrame, diagnostics_dict) with keys n_samples, n_features, lambda_var, lambda_corr.