Supplementary Information for “Detect issue heterogenity in gene expression data with BioQC” (Jitao David Zhang, Klas Hatje, Gregor Sturm, Clemens Broger, Martin Ebeling, Martine Burtin, Fabiola Terzi, Silvia Ines Pomposiello and Laura Badi)
In this vignette, we explain the underlaying algorithmic details of our implementation of the Wilcoxon-Mann-Whitney test. The source code used to produce this document can be found in the github repository BioQC.
BioQC is a R/Bioconductor package to detect tissue heterogeneity from high-throughput gene expression profiling data. It implements an efficient Wilcoxon-Mann-Whitney test, and offers tissue-specific gene signatures that are ready to use ‘out of the box’.
The Wilcoxon-Mann-Whitney (WMW) test is a non-parametric statistical test to test if median values of two population are equal or not. Unlike the t-test, it does not require the assumption of normal distributions, which makes it more robust against noise.
We improved the computational efficiency of the Wilcoxon-Mann-Whitney test in comparison to the native R implementation based on three modifications:
While (1) and (2) are straightforward, we elaborate (3) in the following.
Let \(W_{a,b}\) be the approximative WMW test of two gene vectors \(a,b\), where \(a\) is the gene set of interest, typically containing less than a few hundreds of genes, and \(b\) is the set of all genes outside the gene set (background genes) typically containing \(>10000\) genes. In the context of BioQC, the gene sets are referred to as tissue signatures.
Given an \(m \times n\) input matrix of gene expression data with \(m\) genes and \(n\) samples \(s_1, \dots, s_n\), and \(k\) gene sets \(d_1, \dots, d_k\), the WMW-test needs to be applied for each sample \(s_i, i \in 1..n\) and each gene set \(d_j, j \in 1..k\). The runtime of the WMW-test is essentially determined by the sorting operation on the two input vectors. Using native R wilcox.test
, the vectors \(a\) and \(b\) are sorted individually for each gene set. However, in the context of gene set analysis, this is futile, as the (large) background set changes insignificantly in relation to the (small) gene set, when testing different gene sets on the same sample.
Therefore, we approximate the WMW-test by extending \(b\) to all genes in the sample, keeping the background unchanged when testing multiple gene sets. Like this, \(b\) has to be sorted only once per sample. The individual gene sets still need to be sorted, which is not a major issue, as they are small in comparison to the set of background genes.
To demonstrate BioQC’s superior performance, we apply both BioQC and the native R wilcox.test
to random expression matrices and measure the runtime.
We setup random expression matrices of 61164 human genes of 1, 5, 10, 50, or 100 samples. Genes are \(i.i.d\) distributed following \(\mathcal{N}(0,1)\). The native R and the BioQC implementations of the Wilcoxon-Mann-Whitney test are applied to the matrices respectively.
The numeric results of both implementations, bioqcNumRes
(from BioQC) and rNumRes
(from R), are equivalent, as shown by the next command.
The BioQC implementation is more than 500 times faster: while it takes about one second for BioQC to calculate enrichment scores of all 155 signatures in 100 samples, the native R implementation takes about 20 minutes:
We have shown that BioQC achieves identical results as the native implementation in two orders of magnitude less time. This renders BioQC a highly efficient tool for quality control of large-scale high-throughput gene expression data.
## R version 4.0.0 (2020-04-24)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.4 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.11-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.11-bioc/R/lib/libRlapack.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=C
## [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] stats4 parallel stats graphics grDevices utils datasets
## [8] methods base
##
## other attached packages:
## [1] rbenchmark_1.0.0 gplots_3.0.3 gridExtra_2.3
## [4] latticeExtra_0.6-29 lattice_0.20-41 org.Hs.eg.db_3.10.0
## [7] AnnotationDbi_1.50.0 IRanges_2.22.0 S4Vectors_0.26.0
## [10] BioQC_1.16.0 Biobase_2.48.0 BiocGenerics_0.34.0
## [13] testthat_2.3.2 knitr_1.28
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.4.6 highr_0.8 compiler_4.0.0 RColorBrewer_1.1-2
## [5] bitops_1.0-6 tools_4.0.0 digest_0.6.25 bit_1.1-15.2
## [9] gtable_0.3.0 evaluate_0.14 RSQLite_2.2.0 memoise_1.1.0
## [13] pkgconfig_2.0.3 png_0.1-7 rlang_0.4.5 DBI_1.1.0
## [17] yaml_2.2.1 xfun_0.13 stringr_1.4.0 caTools_1.18.0
## [21] gtools_3.8.2 vctrs_0.2.4 locfit_1.5-9.4 bit64_0.9-7
## [25] grid_4.0.0 R6_2.4.1 jpeg_0.1-8.1 rmarkdown_2.1
## [29] gdata_2.18.0 limma_3.44.0 blob_1.2.1 edgeR_3.30.0
## [33] magrittr_1.5 htmltools_0.4.0 KernSmooth_2.23-17 stringi_1.4.6