library(Matrix)
library(susieR)
set.seed(1)
In this vignette, we provide line profiles for revised version SuSiE,
which allows for a sparse matrix structure. We compare speed performance
when the form of the matrix X
is dense and sparse.
In this minimal example, we observe that given a large sparse matrix,
if it is in the dense form, the speed is around 40%
slower
than that in a sparse form.
We randomly simulate a n=1000
by p=1000
dense matrix and a sparse matrix at sparsity \(99\%\), i.e. \(99\%\) entries are zeros.
= function(sparsity, n, p) {
create_sparsity_mat <- round(n*p*(1-sparsity))
nonzero <- sample(n*p, nonzero)
nonzero.idx <- numeric(n*p)
mat <- 1
mat[nonzero.idx] <- matrix(mat, nrow=n, ncol=p)
mat return(mat)
}
<- 1000
n <- 1000
p <- rep(0,p)
beta c(1,300,400,1000)] <- 10
beta[<- create_sparsity_mat(0.99,n,p)
X.dense <- as(X.dense,"dgCMatrix")
X.sparse <- c(X.dense %*% beta + rnorm(n)) y
X
in a dense form<- susie(X.dense,y) susie.dense
X
in a sparse form<- susie(X.sparse,y) susie.sparse
We encourage people who are insterested in improving SuSiE can get insights from those line profiles provided.