-
Notifications
You must be signed in to change notification settings - Fork 0
/
fast.pbmc8k.R
45 lines (36 loc) · 1.23 KB
/
fast.pbmc8k.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
library(Matrix)
library(irlba)
load("objects/pbmc8k.matrix.rda")
load("objects/pbmc8k.sparseMatrix.rda")
setClass("testMult", representation(matrix = "Matrix",
center = "numeric",
scale = "numeric"))
dim.testMult <- function(x) dim(x@matrix)
nrow.testMult <- function(x) nrow(x@matrix)
ncol.testMult <- function(x) ncol(x@matrix)
setMethod("%*%", signature(x = "testMult", y = "numeric"),
function(x,y) {
x %*% y
})
setMethod("%*%", signature(x = "numeric", y = "testMult"),
function(x,y) {
x %*% y
})
test <- new("testMult")
test@matrix <- pbmc8k.matrix$matrix
test@center <- pbmc8k.matrix$center
test@scale <- pbmc8k.matrix$scale
test <- new("testMult")
test@matrix <- pbmc8k.sparseMatrix$matrix
test@center <- pbmc8k.sparseMatrix$center
test@scale <- pbmc8k.sparseMatrix$scale
system.time({
pca1 <- prcomp_irlba(pbmc8k.matrix$matrix, n = 10,
center = FALSE, scale. = FALSE,
retx = TRUE, verbose = TRUE)
})
system.time({
pca2 <- prcomp_irlba(pbmc8k.sparseMatrix$matrix, n = 10,
center = FALSE, scale. = FALSE,
retx = TRUE, verbose = TRUE)
})