This function was adapted from the original source code in the
Roptspace R package (version 0.2.3; MIT License) by Raghunandan
H. Keshavan, Andrea Montanari, Sewoong Oh (2010). See
ROptSpace::OptSpace
for more information. Let's assume an ideal
matrix \(M\) with \((m\times n)\) entries with rank \(r\) and we
are given a partially observed matrix \(M\_E\) which contains many
missing entries. Matrix reconstruction - or completion - is the task
of filling in such entries. optspace is an efficient algorithm that
reconstructs \(M\) from \(|E|=O(rn)\) observed elements with
relative root mean square error (RMSE) $$RMSE \le
C(\alpha)\sqrt{nr/|E|}$$.
optspace(x, ropt = 3, niter = 5, tol = 1e-5, verbose = FALSE)
Returns a named list containing:
an \((n \times r)\) matrix as left singular vectors.
an \((r \times r)\) matrix as singular values.
an \((m \times r)\) matrix as right singular vectors.
a vector containing reconstruction errors at each successive iteration.
an \((n \times m)\) imputed matrix, with columns and rows centered to zero.
An \((n\times m)\) matrix whose missing entries should be flagged as NA.
FALSE
to guess the rank, or a positive integer as a pre-defined rank (default: 3).
Maximum number of iterations allowed.
Stopping criterion for reconstruction in Frobenius norm.
a logical value; TRUE
to show progress, FALSE
otherwise.
Leo Lahti and Cameron Martino, with adaptations of the method
implemented in Roptspace::OptSpace
by Keshavan et
al. (2010).
This implementation removes the trimming step of the original
Roptspace::OptSpace
code in order to leave feature filtering to the
user. Some of the defaults have been adjusted to better reflect
ecological data. The implementation has been adjusted for ecological
applications as in Martino et al. (2019). The imputed matrix (M) in
the optspace output includes matrix reconstruction (XSY'), with
subsequent centering for the columns and rows.
Keshavan, R. H., Montanari, A., Oh, S. (2010). Matrix Completion From a Few Entries. IEEE Transactions on Information Theory 56(6):2980--2998.
Martino, C., Morton, J.T., Marotz, C.A., Thompson, L.R., Tripathi, A., Knight, R. & Zengler, K. (2019) A novel sparse compositional technique reveals microbial perturbations. mSystems 4, 1.
data(varespec)
# rclr transformation with no matrix completion for the 0/NA entries
x <- decostand(varespec, method = "rclr", impute = FALSE)
# Add matrix completion
xc <- optspace(x, ropt = 3, niter = 5, tol = 1e-5, verbose = FALSE)$M
Run the code above in your browser using DataLab