Approximate SVD

rcpp_mmutil_svd(
  mtx_file,
  RANK,
  TAKE_LN = TRUE,
  TAU = 1,
  COL_NORM = 10000,
  EM_ITER = 0L,
  EM_TOL = 1e-04,
  LU_ITER = 5L,
  row_weight_file = "",
  NUM_THREADS = 1L,
  BLOCK_SIZE = 10000L
)

Arguments

mtx_file

data file (feature x n)

RANK

SVD rank

TAKE_LN

take log(1 + x) trans or not

TAU

regularization parameter (default = 1)

COL_NORM

column normalization

EM_ITER

EM iteration for factorization (default: 10)

EM_TOL

EM convergence (default: 1e-4)

LU_ITER

LU iteration

row_weight_file

row-wise weight file

NUM_THREADS

number of threads for multi-core processing

BLOCK_SIZE

number of columns per block

Value

a list of (1) U (2) D (3) V

Examples

## Generate some data
set.seed(1)
rr <- rgamma(1000, 1, 1) # 1000 cells
mm <- matrix(rgamma(100 * 3, 1, 1), 100, 3)
.dat <- mmutilR::rcpp_mmutil_simulate_poisson(mm, rr, "sim_test")
.pc <- mmutilR::rcpp_mmutil_svd(.dat$mtx, 3, TAKE_LN = FALSE)
.ind <- read.table(.dat$indv)
.col <- unlist(read.table(.dat$col))
.ind <- .ind[match(.col, .ind$V1), ]
plot(.pc$V[, 1], .pc$V[, 2], col = .ind$V2,
     xlab = "PC1", ylab = "PC2")

plot(.pc$V[, 2], .pc$V[, 3], col = .ind$V2,
     xlab = "PC2", ylab = "PC3")

## clean up temp directory
unlink(list.files(pattern = "sim_test"))