What's New
Sparse matrix support for guidedPLS()
X1 and X2 now accept Matrix::dgCMatrix (sparse matrices) in addition to base R matrices. This is particularly useful for single-cell data (scRNA-seq, scATAC-seq) where feature matrices are large and sparse.
Key changes:
- Internally uses the identity
X_c Y = X Y - mu(1^T Y)to avoid materializing the dense centered matrix - Only the small
k × pcross-product matrix is dense; the input X stays sparse throughout - SUMCOR mode (
sumcor=TRUE) auto-converts to dense with a verbose message (p × p covariance matrices are inherently dense) - Added
Matrixto Imports
Performance (benchmark):
| Scenario | Dense | Sparse | Speedup | Memory |
|---|---|---|---|---|
| 3000 × 10000, 5% density | 5.93s | 2.29s | 2.6× | 240 MB → 18 MB (13× reduction) |
| 5000 × 50000, 1% density (scATAC-like) | OOM | 55.96s | — | 2000 MB → 30 MB (67× reduction) |
Other changes:
- Added comprehensive sparse/dense equivalence tests (31 expectations, tolerance 1e-8)
- Added CLAUDE.md for development guidance
- Registered missing test files in
tests/testthat.R
Full Changelog: v1.0.0...v1.2.0