This version performs latent-variable decomposition of a gene expression
matrix Y guided by prior pathway annotations priorMat, with
simplified and lighter regularization compared to the original extended
CLAMP variant. The algorithm alternates updates of Z, B,
and U, where U captures pathway-latent variable
associations inferred directly from the data without ridge-regularized
projections (Chat is not used).
CLAMPfull(
Y,
priorMat,
Chat = NULL,
svdres = NULL,
clamp.base.result = NULL,
clamp_k = NULL,
svd_k = NULL,
L1 = NULL,
L2 = NULL,
cvn = 5,
max.iter = 30,
trace = TRUE,
maxPath = 10,
doCrossval = TRUE,
penalty.factor = rep(1, ncol(priorMat)),
glm_alpha = 0.9,
minGenes = 0,
tol = 5e-04,
seed = 123456,
allGenes = FALSE,
rseed = NULL,
max.U.updates = Inf,
pathwaySelection = c("fast", "complete"),
multiplier = 5,
adaptive.p = 0.05,
useNNLS = TRUE,
useRaw = TRUE,
refitEvery = 3,
useSE = FALSE,
var.prior = TRUE,
Uscale = FALSE,
robust.vp = TRUE,
use_cpp = FALSE,
clamp_k_method = "elbow"
)Gene expression matrix (genes x samples). Can be dense, sparse (dgCMatrix), or FBM.
Binary or weighted prior matrix (genes x pathways) linking genes to pathways.
Ignored in this version (kept for interface compatibility).
Optional precomputed SVD result for initialization.
Optional result from CLAMPbase()
providing initial values.
Number of latent variables for CLAMP (final model rank).
If NULL, it is chosen automatically via select_clamp_k().
Number of singular values/components to compute in the SVD.
If NULL, defaults to max(2, min(n_genes, n_samples) - 1).
Regularization parameters for Z and B.
Defaults use values from
clamp.base.result.
Number of folds for pathway-level cross-validation. Default: 5.
Maximum number of outer iterations. Default: 30.
Logical; print iteration progress. Default: TRUE.
Maximum number of pathways per LV during U-fitting. Default: 10.
Whether to mask prior entries for CV evaluation.
Default: TRUE.
Optional vector of per-pathway penalties for glmnet. Default: 1.
Elastic net mixing parameter for U estimation. Default: 0.9.
Minimum number of genes per pathway. Default: 0.
Convergence tolerance for B updates. Default: 5e-4.
Random seed for CV masking. Default: 123456.
If TRUE, adds zero-filled rows for missing genes.
Default: FALSE.
Reproducibility, coordinate descent updates are done in random order.
Maximum number of U updates (capped by max.iter).
Pathway selection mode for U fitting
("fast" or "complete").
Variance-prior scaling factor. Default: 5.
Quantile of negative Z values used to define adaptive thresholding. Default: 0.05.
Whether to use non-negative least squares for U estimation.
Default: TRUE.
If TRUE, uses unthresholded Z in U updates.
Default: TRUE.
Frequency (in U updates) of full refits. Default: 3.
Logical; whether to use the 1-standard-error rule for internal glmnet fitting. Default is FALSE.
Logical; if TRUE, enables adaptive variance prior
updates for Z.
Default: TRUE.
Logical; whether to scale U columns. Default: FALSE.
Logical; winsorize prior-predicted Z2 values to reduce
outlier effects. Default: TRUE.
Logical; if TRUE, use C++ implementation for Z updates. Default is FALSE.
Method for selecting clamp_k when not provided.
One of "elbow" (default), "permutation", "gavish_donoho", or
"scaleSVs". Passed to select_clamp_k().
A list with elements:
BLV loadings on samples (k × samples)
ZGene loadings (genes × k)
UPathway loadings (pathways × k)
CPrior matrix used during training (masked if CV)
Z2Predicted Z from pathway priors
heldOutGenesHeld-out gene lists per pathway (CV mode)
Uauc, Up, summaryCV evaluation metrics if CV is enabled
priorMat, priorMatCVFinal and masked prior matrices
callFunction call
Cross-validation can be used to evaluate pathway-LV specificity, and a
variance-based prior (var.prior = TRUE) introduces adaptive
shrinkage of Z based on how strongly each latent component aligns
with prior pathways. The scaling factor multiplier (default 5)
controls the strength of this adaptive shrinkage.
This implementation omits ridge-projected priors (Chat) and uses
a lighter variance prior with a lower default multiplier = 5,
allowing more flexible latent representations. Setting
var.prior = FALSE reproduces standard CLAMP-like updates.
Cross-validation, if
enabled, masks 20% of gene-pathway associations per column to estimate
pathway-LV specificity
(reported via AUC and p-values).
set.seed(1)
mat <- matrix(rnorm(100), nrow = 10, ncol = 10)
base <- CLAMPbase(mat, clamp_k = 5, trace = FALSE, max.iter = 5)
#> ****
#> Computing SVD
#> CLAMP k is set to 5
#> L1 is set to 0.736045659723086
#> L2 is set to 2.20813697916926
prior <- matrix(sample(0:1, 10 * 6, TRUE, prob = c(0.9, 0.1)),
nrow = 10, ncol = 6
)
fit <- CLAMPfull(
Y = mat,
priorMat = prior,
clamp.base.result = base,
doCrossval = FALSE,
adaptive.p = 0,
max.U.updates = 0,
max.iter = 1,
trace = FALSE
)
#> ** CLAMPfull **
#> using provided CLAMPbase result
#> CLAMP k is set to 5
#> L1=0.736045659723086; L2=2.20813697916926
#> Not using cross-validation. No AUCs or p-values