trex_normalize_design: Apply the T-Rex data normalization to a design

View source: R/utils.R

trex_normalize_designR Documentation

Apply the T-Rex data normalization to a design

Description

The selectors' own preprocessing as a user-callable helper: the same code path a selector runs at construction for the given scaling_mode. Use it to pre-normalize a design and then run a selector with trex_control(scaling_mode = "NONE") (the selection is identical to running the raw design under "L2"), to inspect the centering and scaling parameters, or to validate a design before a long run. The inputs are copied and left untouched.

Usage

trex_normalize_design(
  X,
  y,
  scaling_mode = c("L2", "ZSCORE", "NONE"),
  eps = 1e-06,
  n_threads = NULL
)

Arguments

X

Numeric design matrix (n x p).

y

Numeric response vector (length n).

scaling_mode

One of "L2" (default; center, divide by the column L2 norm), "ZSCORE" (center, divide by the sample SD) or "NONE" (copies equal the inputs; identity parameters).

eps

Dead-column threshold on the working L2 norm (default 1e-6, the selectors' default solver tolerance).

n_threads

Integer, the thread budget of the column passes (NULL, the default: the library's default budget, trex_get_num_threads(), initially 1).

Details

Errors on a non-finite entry or a dead column (constant under "L2" / "ZSCORE", all-zero under "NONE"), naming the column (0-based, as reported by the C++ core).

Value

A list with X and y (the normalized copies), X_means, X_scales (the per-column divisors: L2 norms for "L2", sample SDs for "ZSCORE", ones for "NONE") and y_mean.

See Also

Other T-Rex selectors and controls: Gauss_data, TRexBiobankScreeningSelector, TRexDASelector, TRexGVSSelector, TRexSPCASelector, TRexScreeningSelector, TRexSelector, TRexTikhonovSelector, trex_biobank_control(), trex_build_group_centering_k(), trex_control(), trex_da_control(), trex_default_lambda2_grid(), trex_dummy_distribution(), trex_fdp(), trex_fdp_dense(), trex_gamma_to_k(), trex_get_num_threads(), trex_gvs_control(), trex_gvs_lambda2_power_rule(), trex_precision(), trex_recall(), trex_screen_control(), trex_spca_control(), trex_tikhonov_control(), trex_tikhonov_lambda2_power_rule(), trex_tpp(), trex_tpp_dense()

Examples

set.seed(1)
X <- matrix(rnorm(200), 40, 5)
y <- X[, 1] + rnorm(40)
d <- trex_normalize_design(X, y)
colMeans(d$X)            # ~ 0
sqrt(colSums(d$X^2))     # 1


TRexSelector documentation built on Nov. 20, 2026, 5:09 p.m.