# #——回声= FALSE,结果=“隐藏”,消息= FALSE ------------------------------- knitr: opts_chunk美元集(错误= FALSE,消息= FALSE,警告= FALSE ) ## ----------------------------------------------------------------------------- 垫< -矩阵(rnorm (10000), ncol = 10) smat1 < -规模(垫)头(smat1)库(DelayedArray) smat2 < -规模(DelayedArray(垫))头(smat2)库(ScaledMatrix) smat3 < - ScaledMatrix(垫、中心= TRUE,规模(smat3 = TRUE) ) ## ----------------------------------------------------------------------------- 库(矩阵)垫< - rsparsematrix(20000、10000、密度= 0.01)smat < - ScaledMatrix(垫,中心= TRUE,规模= TRUE) blob < -矩阵(runif (ncol(垫)* 5),ncol = 5)系统。time(out <- smat %*% blob) #块处理的较慢方式。da <- scale(DelayedArray(mat))系统。时间(out2 < - da % * % blob ) ## ----------------------------------------------------------------------------- 库(BiocSingular) set.seed(1000)系统。时间(pc < - runSVD (smat k = 10, BSPARAM = IrlbaParam ())) ## ----------------------------------------------------------------------------- system.time (rowSums (smat) system.time (rowSums(哒 )) ## ----------------------------------------------------------------------------- smat [1:5] t (smat) rownames (smat) < - paste0(“GENE_”,1:20000) smat ## ----------------------------------------------------------------------------- smat + 1 ## ----------------------------------------------------------------------------- set.seed(1000)垫< -矩阵(rnorm (1000000), ncol = 100000)大。mat <- mat + 1e12 #“正确”值,不受数值精度影响。ref <- rowMeans(scale(mat)) head(ref) #缩放DelayedArray的值。library(DelayedArray) smat2 <- scale(DelayedArray(big.mat)) head(rowMeans(smat2)) #来自ScaledMatrix的值。smat3 <- ScaledMatrix(大的。垫,中心= TRUE,规模= TRUE)头(rowMeans (smat3 )) ## ----------------------------------------------------------------------------- sessionInfo ()