colRowWeightedMedians_subset - HenrikBengtsson/matrixStats GitHub Wiki

matrixStats: Benchmark report


colWeightedMedians() and rowWeightedMedians() benchmarks on subsetted computation

This report benchmark the performance of colWeightedMedians() and rowWeightedMedians on subsetted computation.

Data

> rmatrix <- function(nrow, ncol, mode = c("logical", "double", "integer", "index"), range = c(-100, 
+     +100), na_prob = 0) {
+     mode <- match.arg(mode)
+     n <- nrow * ncol
+     if (mode == "logical") {
+         x <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+     }     else if (mode == "index") {
+         x <- seq_len(n)
+         mode <- "integer"
+     }     else {
+         x <- runif(n, min = range[1], max = range[2])
+     }
+     storage.mode(x) <- mode
+     if (na_prob > 0) 
+         x[sample(n, size = na_prob * n)] <- NA
+     dim(x) <- c(nrow, ncol)
+     x
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+     set.seed(seed)
+     data <- list()
+     data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+     data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+     data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+     data[[4]] <- t(data[[3]])
+     data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+     data[[6]] <- t(data[[5]])
+     names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+     data
+ }
> data <- rmatrices(mode = "double")

Results

10x10 matrix

> X <- data[["10x10"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3227229 172.4    5709258 305.0  5709258 305.0
Vcells 6786367  51.8   22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMedians_X_w_S = colWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `colWeightedMedians(X, w, rows, cols)` = colWeightedMedians(X, w = w, rows = rows, cols = cols, 
+         na.rm = FALSE), `colWeightedMedians(X[rows, cols], w[rows])` = colWeightedMedians(X[rows, 
+         cols], w = w[rows], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3226310 172.4    5709258 305.0  5709258 305.0
Vcells 6783615  51.8   22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMedians_X_w_S = rowWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `rowWeightedMedians(X, w, cols, rows)` = rowWeightedMedians(X, w = w, rows = cols, cols = rows, 
+         na.rm = FALSE), `rowWeightedMedians(X[cols, rows], w[rows])` = rowWeightedMedians(X[cols, 
+         rows], w = w[rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 10x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colWeightedMedians_X_w_S 0.034302 0.0350375 0.0356074 0.0353440 0.0357190 0.049407
3 colWeightedMedians(X[rows, cols], w[rows]) 0.035735 0.0363355 0.0368400 0.0366545 0.0371175 0.043340
2 colWeightedMedians(X, w, rows, cols) 0.035736 0.0363760 0.0402145 0.0367535 0.0369840 0.349562
expr min lq mean median uq max
1 colWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
3 colWeightedMedians(X[rows, cols], w[rows]) 1.041776 1.037046 1.034616 1.037078 1.039153 0.8772036
2 colWeightedMedians(X, w, rows, cols) 1.041805 1.038202 1.129386 1.039880 1.035415 7.0751513

Table: Benchmarking of rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on 10x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 rowWeightedMedians_X_w_S 0.034195 0.0348485 0.0352173 0.0350925 0.0354385 0.039509
2 rowWeightedMedians(X, w, cols, rows) 0.035136 0.0362160 0.0391777 0.0364440 0.0368450 0.281168
3 rowWeightedMedians(X[cols, rows], w[rows]) 0.035346 0.0362270 0.0365771 0.0364870 0.0367300 0.041582
expr min lq mean median uq max
1 rowWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowWeightedMedians(X, w, cols, rows) 1.027519 1.039241 1.112458 1.038512 1.039689 7.116556
3 rowWeightedMedians(X[cols, rows], w[rows]) 1.033660 1.039557 1.038612 1.039738 1.036443 1.052469

Figure: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 10x10 data as well as rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 10x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
2 rowWeightedMedians_X_w_S 34.195 34.8485 35.21727 35.0925 35.4385 39.509
1 colWeightedMedians_X_w_S 34.302 35.0375 35.60739 35.3440 35.7190 49.407
expr min lq mean median uq max
2 rowWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colWeightedMedians_X_w_S 1.003129 1.005424 1.011078 1.007167 1.007915 1.250525

Figure: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 matrix

> X <- data[["100x100"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3225249 172.3    5709258 305.0  5709258 305.0
Vcells 6454851  49.3   22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMedians_X_w_S = colWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `colWeightedMedians(X, w, rows, cols)` = colWeightedMedians(X, w = w, rows = rows, cols = cols, 
+         na.rm = FALSE), `colWeightedMedians(X[rows, cols], w[rows])` = colWeightedMedians(X[rows, 
+         cols], w = w[rows], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3225240 172.3    5709258 305.0  5709258 305.0
Vcells 6464929  49.4   22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMedians_X_w_S = rowWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `rowWeightedMedians(X, w, cols, rows)` = rowWeightedMedians(X, w = w, rows = cols, cols = rows, 
+         na.rm = FALSE), `rowWeightedMedians(X[cols, rows], w[rows])` = rowWeightedMedians(X[cols, 
+         rows], w = w[rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 100x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colWeightedMedians_X_w_S 0.379641 0.3857220 0.3919640 0.390685 0.3967110 0.419902
2 colWeightedMedians(X, w, rows, cols) 0.398307 0.4044780 0.4115723 0.407831 0.4122035 0.546634
3 colWeightedMedians(X[rows, cols], w[rows]) 0.396093 0.4042525 0.4093514 0.407877 0.4135600 0.434313
expr min lq mean median uq max
1 colWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colWeightedMedians(X, w, rows, cols) 1.049168 1.048626 1.050026 1.043887 1.039052 1.301813
3 colWeightedMedians(X[rows, cols], w[rows]) 1.043336 1.048041 1.044360 1.044005 1.042472 1.034320

Table: Benchmarking of rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on 100x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 rowWeightedMedians_X_w_S 0.377905 0.3831235 0.3886964 0.3866505 0.3908480 0.444158
3 rowWeightedMedians(X[cols, rows], w[rows]) 0.388325 0.3920955 0.3985507 0.3952715 0.4002135 0.465010
2 rowWeightedMedians(X, w, cols, rows) 0.387284 0.3927990 0.3996651 0.3956865 0.4010540 0.533076
expr min lq mean median uq max
1 rowWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
3 rowWeightedMedians(X[cols, rows], w[rows]) 1.027573 1.023418 1.025352 1.022297 1.023962 1.046947
2 rowWeightedMedians(X, w, cols, rows) 1.024818 1.025254 1.028219 1.023370 1.026112 1.200195

Figure: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 100x100 data as well as rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 100x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
2 rowWeightedMedians_X_w_S 377.905 383.1235 388.6964 386.6505 390.848 444.158
1 colWeightedMedians_X_w_S 379.641 385.7220 391.9640 390.6850 396.711 419.902
expr min lq mean median uq max
2 rowWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
1 colWeightedMedians_X_w_S 1.004594 1.006782 1.008407 1.010434 1.015001 0.9453888

Figure: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 matrix

> X <- data[["1000x10"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3226009 172.3    5709258 305.0  5709258 305.0
Vcells 6460823  49.3   22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMedians_X_w_S = colWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `colWeightedMedians(X, w, rows, cols)` = colWeightedMedians(X, w = w, rows = rows, cols = cols, 
+         na.rm = FALSE), `colWeightedMedians(X[rows, cols], w[rows])` = colWeightedMedians(X[rows, 
+         cols], w = w[rows], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3225997 172.3    5709258 305.0  5709258 305.0
Vcells 6470896  49.4   22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMedians_X_w_S = rowWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `rowWeightedMedians(X, w, cols, rows)` = rowWeightedMedians(X, w = w, rows = cols, cols = rows, 
+         na.rm = FALSE), `rowWeightedMedians(X[cols, rows], w[rows])` = rowWeightedMedians(X[cols, 
+         rows], w = w[rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colWeightedMedians_X_w_S 0.273149 0.2767410 0.2792019 0.2785060 0.2809955 0.315919
3 colWeightedMedians(X[rows, cols], w[rows]) 0.292800 0.2960765 0.2983786 0.2977415 0.3006775 0.313773
2 colWeightedMedians(X, w, rows, cols) 0.292246 0.2972230 0.3008766 0.2994060 0.3015225 0.414559
expr min lq mean median uq max
1 colWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
3 colWeightedMedians(X[rows, cols], w[rows]) 1.071942 1.069869 1.068684 1.069067 1.070044 0.9932071
2 colWeightedMedians(X, w, rows, cols) 1.069914 1.074011 1.077631 1.075043 1.073051 1.3122319

Table: Benchmarking of rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on 1000x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 rowWeightedMedians_X_w_S 0.273641 0.2766135 0.2796697 0.2789745 0.2822870 0.309655
3 rowWeightedMedians(X[cols, rows], w[rows]) 0.286128 0.2903070 0.2942811 0.2925320 0.2953505 0.397460
2 rowWeightedMedians(X, w, cols, rows) 0.287867 0.2923810 0.2953519 0.2948145 0.2974310 0.315792
expr min lq mean median uq max
1 rowWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
3 rowWeightedMedians(X[cols, rows], w[rows]) 1.045633 1.049504 1.052245 1.048598 1.046277 1.283557
2 rowWeightedMedians(X, w, cols, rows) 1.051988 1.057002 1.056074 1.056779 1.053648 1.019819

Figure: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 1000x10 data as well as rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 1000x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colWeightedMedians_X_w_S 273.149 276.7410 279.2019 278.5060 280.9955 315.919
2 rowWeightedMedians_X_w_S 273.641 276.6135 279.6697 278.9745 282.2870 309.655
expr min lq mean median uq max
1 colWeightedMedians_X_w_S 1.000000 1.0000000 1.000000 1.000000 1.000000 1.0000000
2 rowWeightedMedians_X_w_S 1.001801 0.9995393 1.001676 1.001682 1.004596 0.9801721

Figure: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 matrix

> X <- data[["10x1000"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3226206 172.3    5709258 305.0  5709258 305.0
Vcells 6460117  49.3   22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMedians_X_w_S = colWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `colWeightedMedians(X, w, rows, cols)` = colWeightedMedians(X, w = w, rows = rows, cols = cols, 
+         na.rm = FALSE), `colWeightedMedians(X[rows, cols], w[rows])` = colWeightedMedians(X[rows, 
+         cols], w = w[rows], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3226197 172.3    5709258 305.0  5709258 305.0
Vcells 6470195  49.4   22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMedians_X_w_S = rowWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `rowWeightedMedians(X, w, cols, rows)` = rowWeightedMedians(X, w = w, rows = cols, cols = rows, 
+         na.rm = FALSE), `rowWeightedMedians(X[cols, rows], w[rows])` = rowWeightedMedians(X[cols, 
+         rows], w = w[rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 10x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colWeightedMedians_X_w_S 1.763628 1.892162 2.130632 1.967949 2.166019 8.076422
2 colWeightedMedians(X, w, rows, cols) 1.779392 1.902375 2.134930 1.970640 2.191380 7.873922
3 colWeightedMedians(X[rows, cols], w[rows]) 1.783316 1.864411 2.207503 1.991594 2.208190 8.265785
expr min lq mean median uq max
1 colWeightedMedians_X_w_S 1.000000 1.0000000 1.000000 1.000000 1.000000 1.000000
2 colWeightedMedians(X, w, rows, cols) 1.008938 1.0053975 1.002017 1.001367 1.011708 0.974927
3 colWeightedMedians(X[rows, cols], w[rows]) 1.011163 0.9853334 1.036079 1.012015 1.019469 1.023446

Table: Benchmarking of rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on 10x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
2 rowWeightedMedians(X, w, cols, rows) 1.794099 1.871738 1.958928 1.915993 2.007179 2.305629
1 rowWeightedMedians_X_w_S 1.780364 1.878151 2.055792 1.920506 1.986166 7.812905
3 rowWeightedMedians(X[cols, rows], w[rows]) 1.787825 1.894575 2.018832 1.925763 2.003176 8.042999
expr min lq mean median uq max
2 rowWeightedMedians(X, w, cols, rows) 1.0000000 1.000000 1.000000 1.000000 1.0000000 1.000000
1 rowWeightedMedians_X_w_S 0.9923443 1.003426 1.049448 1.002355 0.9895311 3.388622
3 rowWeightedMedians(X[cols, rows], w[rows]) 0.9965030 1.012201 1.030580 1.005099 0.9980059 3.488419

Figure: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 10x1000 data as well as rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 10x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
2 rowWeightedMedians_X_w_S 1.780364 1.878151 2.055792 1.920506 1.986166 7.812905
1 colWeightedMedians_X_w_S 1.763628 1.892162 2.130632 1.967949 2.166019 8.076422
expr min lq mean median uq max
2 rowWeightedMedians_X_w_S 1.0000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colWeightedMedians_X_w_S 0.9905997 1.007461 1.036404 1.024703 1.090553 1.033728

Figure: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 matrix

> X <- data[["100x1000"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3226414 172.4    5709258 305.0  5709258 305.0
Vcells 6505082  49.7   22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMedians_X_w_S = colWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `colWeightedMedians(X, w, rows, cols)` = colWeightedMedians(X, w = w, rows = rows, cols = cols, 
+         na.rm = FALSE), `colWeightedMedians(X[rows, cols], w[rows])` = colWeightedMedians(X[rows, 
+         cols], w = w[rows], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3226405 172.4    5709258 305.0  5709258 305.0
Vcells 6605160  50.4   22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMedians_X_w_S = rowWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `rowWeightedMedians(X, w, cols, rows)` = rowWeightedMedians(X, w = w, rows = cols, cols = rows, 
+         na.rm = FALSE), `rowWeightedMedians(X[cols, rows], w[rows])` = rowWeightedMedians(X[cols, 
+         rows], w = w[rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 100x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colWeightedMedians_X_w_S 3.659224 3.803071 4.289474 3.896034 4.074591 17.704004
2 colWeightedMedians(X, w, rows, cols) 3.866455 4.022183 4.330211 4.103757 4.319814 7.683273
3 colWeightedMedians(X[rows, cols], w[rows]) 3.837779 4.028799 4.669478 4.148396 4.450134 19.872772
expr min lq mean median uq max
1 colWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colWeightedMedians(X, w, rows, cols) 1.056633 1.057615 1.009497 1.053317 1.060184 0.433985
3 colWeightedMedians(X[rows, cols], w[rows]) 1.048796 1.059354 1.088590 1.064774 1.092167 1.122502

Table: Benchmarking of rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on 100x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 rowWeightedMedians_X_w_S 3.674153 3.835123 4.027186 3.936933 4.034851 5.754177
2 rowWeightedMedians(X, w, cols, rows) 3.793616 3.962799 4.305666 4.039116 4.113932 19.721633
3 rowWeightedMedians(X[cols, rows], w[rows]) 3.787243 3.989422 4.461775 4.058145 4.194319 17.824748
expr min lq mean median uq max
1 rowWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowWeightedMedians(X, w, cols, rows) 1.032514 1.033291 1.069150 1.025955 1.019600 3.427360
3 rowWeightedMedians(X[cols, rows], w[rows]) 1.030780 1.040233 1.107914 1.030789 1.039523 3.097706

Figure: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 100x1000 data as well as rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 100x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colWeightedMedians_X_w_S 3.659224 3.803071 4.289474 3.896034 4.074591 17.704004
2 rowWeightedMedians_X_w_S 3.674153 3.835123 4.027186 3.936933 4.034851 5.754177
expr min lq mean median uq max
1 colWeightedMedians_X_w_S 1.00000 1.000000 1.000000 1.000000 1.0000000 1.0000000
2 rowWeightedMedians_X_w_S 1.00408 1.008428 0.938853 1.010498 0.9902469 0.3250212

Figure: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 matrix

> X <- data[["1000x100"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3226621 172.4    5709258 305.0  5709258 305.0
Vcells 6507415  49.7   22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMedians_X_w_S = colWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `colWeightedMedians(X, w, rows, cols)` = colWeightedMedians(X, w = w, rows = rows, cols = cols, 
+         na.rm = FALSE), `colWeightedMedians(X[rows, cols], w[rows])` = colWeightedMedians(X[rows, 
+         cols], w = w[rows], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3226612 172.4    5709258 305.0  5709258 305.0
Vcells 6607493  50.5   22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMedians_X_w_S = rowWeightedMedians(X_S, w = w_S, na.rm = FALSE), 
+     `rowWeightedMedians(X, w, cols, rows)` = rowWeightedMedians(X, w = w, rows = cols, cols = rows, 
+         na.rm = FALSE), `rowWeightedMedians(X[cols, rows], w[rows])` = rowWeightedMedians(X[cols, 
+         rows], w = w[rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colWeightedMedians_X_w_S 2.535627 2.597145 2.670464 2.616480 2.679305 3.283902
2 colWeightedMedians(X, w, rows, cols) 2.626993 2.690973 2.958426 2.723665 2.779863 11.044253
3 colWeightedMedians(X[rows, cols], w[rows]) 2.598347 2.685658 2.840788 2.725602 2.779620 10.781910
expr min lq mean median uq max
1 colWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colWeightedMedians(X, w, rows, cols) 1.036033 1.036127 1.107832 1.040965 1.037531 3.363149
3 colWeightedMedians(X[rows, cols], w[rows]) 1.024736 1.034080 1.063781 1.041706 1.037441 3.283262

Table: Benchmarking of rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on 1000x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 rowWeightedMedians_X_w_S 2.550044 2.649730 2.719527 2.693096 2.733735 3.590357
2 rowWeightedMedians(X, w, cols, rows) 2.653831 2.774217 2.934614 2.803576 2.864693 10.831308
3 rowWeightedMedians(X[cols, rows], w[rows]) 2.647955 2.780111 3.044350 2.809877 2.895876 10.920285
expr min lq mean median uq max
1 rowWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowWeightedMedians(X, w, cols, rows) 1.040700 1.046981 1.079090 1.041023 1.047905 3.016777
3 rowWeightedMedians(X[cols, rows], w[rows]) 1.038396 1.049205 1.119441 1.043363 1.059311 3.041560

Figure: Benchmarking of colWeightedMedians_X_w_S(), colWeightedMedians(X, w, rows, cols)() and colWeightedMedians(X[rows, cols], w[rows])() on 1000x100 data as well as rowWeightedMedians_X_w_S(), rowWeightedMedians(X, w, cols, rows)() and rowWeightedMedians(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 1000x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colWeightedMedians_X_w_S 2.535627 2.597145 2.670464 2.616480 2.679305 3.283902
2 rowWeightedMedians_X_w_S 2.550044 2.649730 2.719527 2.693096 2.733735 3.590357
expr min lq mean median uq max
1 colWeightedMedians_X_w_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.00000
2 rowWeightedMedians_X_w_S 1.005686 1.020247 1.018373 1.029282 1.020315 1.09332

Figure: Benchmarking of colWeightedMedians_X_w_S() and rowWeightedMedians_X_w_S() on 1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

Appendix

Session information

R version 3.6.1 Patched (2019-08-27 r77078)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS

Matrix products: default
BLAS:   /home/hb/software/R-devel/R-3-6-branch/lib/R/lib/libRblas.so
LAPACK: /home/hb/software/R-devel/R-3-6-branch/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] microbenchmark_1.4-6    matrixStats_0.55.0-9000 ggplot2_3.2.1          
[4] knitr_1.24              R.devices_2.16.0        R.utils_2.9.0          
[7] R.oo_1.22.0             R.methodsS3_1.7.1       history_0.0.0-9002     

loaded via a namespace (and not attached):
 [1] Biobase_2.45.0       bit64_0.9-7          splines_3.6.1       
 [4] network_1.15         assertthat_0.2.1     highr_0.8           
 [7] stats4_3.6.1         blob_1.2.0           robustbase_0.93-5   
[10] pillar_1.4.2         RSQLite_2.1.2        backports_1.1.4     
[13] lattice_0.20-38      glue_1.3.1           digest_0.6.20       
[16] colorspace_1.4-1     sandwich_2.5-1       Matrix_1.2-17       
[19] XML_3.98-1.20        lpSolve_5.6.13.3     pkgconfig_2.0.2     
[22] genefilter_1.66.0    purrr_0.3.2          ergm_3.10.4         
[25] xtable_1.8-4         mvtnorm_1.0-11       scales_1.0.0        
[28] tibble_2.1.3         annotate_1.62.0      IRanges_2.18.2      
[31] TH.data_1.0-10       withr_2.1.2          BiocGenerics_0.30.0 
[34] lazyeval_0.2.2       mime_0.7             survival_2.44-1.1   
[37] magrittr_1.5         crayon_1.3.4         statnet.common_4.3.0
[40] memoise_1.1.0        laeken_0.5.0         R.cache_0.13.0      
[43] MASS_7.3-51.4        R.rsp_0.43.1         tools_3.6.1         
[46] multcomp_1.4-10      S4Vectors_0.22.1     trust_0.1-7         
[49] munsell_0.5.0        AnnotationDbi_1.46.1 compiler_3.6.1      
[52] rlang_0.4.0          grid_3.6.1           RCurl_1.95-4.12     
[55] cwhmisc_6.6          rappdirs_0.3.1       labeling_0.3        
[58] bitops_1.0-6         base64enc_0.1-3      boot_1.3-23         
[61] gtable_0.3.0         codetools_0.2-16     DBI_1.0.0           
[64] markdown_1.1         R6_2.4.0             zoo_1.8-6           
[67] dplyr_0.8.3          bit_1.1-14           zeallot_0.1.0       
[70] parallel_3.6.1       Rcpp_1.0.2           vctrs_0.2.0         
[73] DEoptimR_1.0-8       tidyselect_0.2.5     xfun_0.9            
[76] coda_0.19-3         

Total processing time was 17.8 secs.

Reproducibility

To reproduce this report, do:

html <- matrixStats:::benchmark('colRowWeightedMedians_subset')

Copyright Dongcan Jiang. Last updated on 2019-09-10 20:55:55 (-0700 UTC). Powered by RSP.

<script> var link = document.createElement('link'); link.rel = 'icon'; link.href = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAA21BMVEUAAAAAAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8BAf4CAv0DA/wdHeIeHuEfH+AgIN8hId4lJdomJtknJ9g+PsE/P8BAQL9yco10dIt1dYp3d4h4eIeVlWqWlmmXl2iYmGeZmWabm2Tn5xjo6Bfp6Rb39wj4+Af//wA2M9hbAAAASXRSTlMAAQIJCgsMJSYnKD4/QGRlZmhpamtsbautrrCxuru8y8zN5ebn6Pn6+///////////////////////////////////////////LsUNcQAAAS9JREFUOI29k21XgkAQhVcFytdSMqMETU26UVqGmpaiFbL//xc1cAhhwVNf6n5i5z67M2dmYOyfJZUqlVLhkKucG7cgmUZTybDz6g0iDeq51PUr37Ds2cy2/C9NeES5puDjxuUk1xnToZsg8pfA3avHQ3lLIi7iWRrkv/OYtkScxBIMgDee0ALoyxHQBJ68JLCjOtQIMIANF7QG9G9fNnHvisCHBVMKgSJgiz7nE+AoBKrAPA3MgepvgR9TSCasrCKH0eB1wBGBFdCO+nAGjMVGPcQb5bd6mQRegN6+1axOs9nGfYcCtfi4NQosdtH7dB+txFIpXQqN1p9B/asRHToyS0jRgpV7nk4nwcq1BJ+x3Gl/v7S9Wmpp/aGquum7w3ZDyrADFYrl8vHBH+ev9AUASW1dmU4h4wAAAABJRU5ErkJggg==" document.getElementsByTagName('head')[0].appendChild(link); </script>
⚠️ **GitHub.com Fallback** ⚠️