Represent and Use Sparse + Low Rank Matrices

Provides an S4 class for representing and interacting with sparse plus rank matrices. At the moment the implementation is quite spare, but the plan is eventually subclass Matrix objects.


sparseLRMatrix

Codecov testcoverage R-CMD-check

sparseLRMatrix provides a single matrix S4 class called sparseLRMatrix which represents matrices that can be expressed as the sum of sparse matrix and a low rank matrix. We also provide an efficient SVD method for these matrices by wrapping the RSpectra SVD implementation.

Eventually, we will fully subclass Matrix::Matrix objects, but the current implementation is extremely minimal.

Installation

You can install the released version of sparseLRMatrix from CRAN with:

# install.packages("remotes")
remotes::install_github("RoheLab/sparseLRMatrix")

Usage

library(sparseLRMatrix)
#> Loading required package: Matrix
library(RSpectra)

set.seed(528491)

n <- 50
m <- 40
k <- 3

A <- rsparsematrix(n, m, 0.1)

U <- Matrix(rnorm(n * k), nrow = n, ncol = k)
V <- Matrix(rnorm(m * k), nrow = m, ncol = k)

# construct the matrix, which represents A + U %*% t(V)
X <- sparseLRMatrix(sparse = A, U = U, V = V)

s <- svds(X, 5)  # efficient

And a quick sanity check

Y <- A + tcrossprod(U, V)
s2 <- svds(Y, 5)  # inefficient, but same calculation

# singular values match up, you can check for yourself
# that the singular vectors do as well!
all.equal(s$d, s2$d)
#> [1] TRUE

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("sparseLRMatrix")

0.1.0 by Alex Hayes, 6 years ago


https://rohelab.github.io/sparseLRMatrix/, https://github.com/RoheLab/sparseLRMatrix


Report a bug at https://github.com/RoheLab/sparseLRMatrix/issues


Browse source code at https://github.com/cran/sparseLRMatrix


Authors: Alex Hayes [aut, cre, cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports RSpectra

Depends on Matrix, methods

Suggests covr, testthat


Imported by invertiforms.


See at CRAN