Principal Convex Hull Analysis via Rust PCHA
pcha.RdFit archetypes to your data using the fast Rust implementation of
Principal Convex Hull Analysis (PCHA). Optionally you can warm‐start
the solver by providing initial C and S matrices.
Arguments
- input_mat
A numeric matrix of size \(p\times n\), where
pis the number of features (rows) andnthe number of samples.- c_init
Optional numeric matrix of size
n x kgiving an initial guess for the archetype coefficientsC. PassNULL(the default) to let PCHA pick its own seed.- s_init
Optional numeric matrix of size
k x ngiving an initial guess for the cell‐to‐archetype weightsS. PassNULL(the default) to let PCHA pick its own seed.- max_iter
maximum number of PCHA updates (default 750)
- conv_crit
convergence threshold on relative ΔSSE (default 1e-6)
- k
Integer; the number of archetypes \(k\) to fit (
1 <= k <= n).
Value
A named list with components
CAn
n x kmatrix of archetype coefficients.SA
k x nmatrix of sample weights.XCA
p x kmatrix of fitted archetype profiles.sseThe final residual sum‐of‐squares.
varExplThe fraction of variance explained, \((SST - SSE)/SST\).
Examples
if (FALSE) { # \dontrun{
# simulate toy data
set.seed(1)
X <- matrix(rexp(60*300), nrow = 60, ncol = 300)
# fit 5 archetypes
res <- pcha_rust(X, k = 5)
# warm‐start with C0 and S0
C0 <- matrix(0, ncol(X), 5)
C0[sample(ncol(X),5) + 5*seq_len(5) - 5] <- 1
S0 <- matrix(runif(5*ncol(X)), 5, ncol(X))
res2 <- pcha_rust(X, k = 5, c_init = C0, s_init = S0)
} # }