TRexSPCASelector: T-Rex Sparse PCA Selector (T-Rex+SPCA)

TRexSPCASelectorR Documentation

T-Rex Sparse PCA Selector (T-Rex+SPCA)

Description

Sparse principal components whose non-zero loadings are selected with FDR control. Each ordinary principal component is the response of a T-Rex+GVS run with the elastic net.

Details

Steps:

  1. X is centered and its first M ordinary principal components are computed (a PCA of the covariance, the columns are not scaled).

  2. For each component, a T-Rex+GVS run with the elastic net and the component as response selects its variables at the target FDR.

  3. The sparse loading vector is assembled from the selected set (see mode of trex_spca_control()), and the scores of the sparse component are the centered X times the loading vector.

  4. The explained variance is adjusted for components that are not orthogonal, by the QR decomposition of the scores.

A component without a selected variable has a zero column in V and Z and the explained variance 0.

Active bindings

Z

Scores of the sparse components (n x M): column m is the centered X times column m of V.

V

Sparse loadings (p x M), each column of unit L2 norm. In "ActiveSet" mode the non-zero entries of column m are the variables of active_sets[[m]]. In "Thresholded" mode they are the largest ordinary PCA loadings, as many as active_sets[[m]] has entries, which can be other variables.

active_sets

Selected variables per component, a list of M integer vectors (1-based), the result of the T-Rex+GVS runs. The FDR control holds for these sets. In "Thresholded" mode they can differ from the non-zero entries of V.

adjusted_ev

Adjusted explained variance per component (length M): r_mm^2 / (n - 1), with r_mm the m-th diagonal element of R in the QR decomposition Z = QR. The adjustment accounts for sparse components that are not orthogonal.

cumulative_ev

Cumulative adjusted explained variance as a fraction of the total variance of the centered X (length M), between 0 and 1. It is not the PEV of Definition 1 of the paper, whose denominator (signal EV plus mixed EV) needs the true support.

Methods

Public methods


TRexSPCASelector$new()

Create a new TRexSPCASelector.

Usage
TRexSPCASelector$new(
  X,
  M,
  tFDR,
  control = trex_spca_control(),
  seed = -1L,
  verbose = FALSE
)
Arguments
X

Design matrix (n x p) in memory, or an mmap_matrix opened in "readwrite" mode. Both are bound without a copy. X is centered in place during select() and restored on return.

M

Number of sparse principal components, 1 to min(n, p).

tFDR

Target FDR level of each component, in [0, 1].

control

A control list from trex_spca_control() (default: trex_spca_control()).

seed

Random seed. A negative value (default: -1) gives a run that is not reproducible. Each component runs with its own seed derived from it.

verbose

Whether to print one line per component (default: FALSE). The T-Rex+GVS runs stay quiet.


TRexSPCASelector$select()

Run the T-Rex sparse PCA selection.

Usage
TRexSPCASelector$select()
Returns

Invisible self for method chaining. The results are in the fields Z, V, active_sets, adjusted_ev and cumulative_ev.


TRexSPCASelector$clone()

The objects of this class are cloneable with this method.

Usage
TRexSPCASelector$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

References

J. Machkour, A. Breloy, M. Muma, D. P. Palomar, and F. Pascal, "Sparse PCA with False Discovery Rate Controlled Variable Selection," in Proc. IEEE 49th Int. Conf. Acoust., Speech, Signal Process. (ICASSP), 2024, pp. 9716-9720.

J. Machkour, M. Muma, and D. P. Palomar, "The Terminating-Random Experiments Selector: Fast High-Dimensional Variable Selection with False Discovery Rate Control," Signal Process., vol. 231, Art. no. 109894, 2025, doi: 10.1016/j.sigpro.2025.109894.

See Also

Other T-Rex selectors and controls: Gauss_data, TRexBiobankScreeningSelector, TRexDASelector, TRexGVSSelector, 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_normalize_design(), 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)
n <- 100; p <- 30
X <- matrix(rnorm(n * p), n, p)
sel <- TRexSPCASelector$new(X, M = 2, tFDR = 0.2,
                             control = trex_spca_control(K = 5))
sel$select()
sel$adjusted_ev
sel$active_sets



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