Differential expression (DE) analysis, aiming to identify genes with significant expression changes across conditions, provides insights into molecular mechanisms underlying aging, disease, and other biological processes. Traditional DE methods primarily detect changes in centrality (e.g., mean or median), but often lack power against alternative hypotheses characterized by changes in spread (e.g. variance or dispersion). Variance shifts, however, are critical in understanding regulatory dynamics and stochasticity in gene expression, particularly in contexts like aging and cellular differentiation. Moreover, in DE analysis, there is often a trade-off between statistical power and control over the false discovery rate (FDR): parametric approaches may inflate FDRs, while nonparametric methods frequently lack sufficient power.
The QRscore package addresses these two limitations by
providing a robust framework for two-sample and K-sample tests that
detect shifts in both centrality and spread. Built upon rigorous
theoretical foundations,QRscore extends the Mann-Whitney
test to an adaptive, rank-based approach that combines non-parametric
tests with weights informed by (zero-inflated) negative binomial models,
ensuring both high power and strictly controlled FDR.
This package is designed to complement existing tools in Bioconductor
by offering enhanced capabilities for detecting distributional shifts.
By integrating with widely-used Bioconductor packages such as
DESeq2 and leveraging parallelization
(BiocParallel), QRscore seamlessly integrates
into genomics workflows for differential expression and differential
dispersion analysis. This vignette demonstrates the utility of
QRscore through a detailed example.
Check dependencies are installed.
if (!requireNamespace("BiocManager", quietly = TRUE)) {
install.packages("BiocManager")
}
if (!requireNamespace("DESeq2", quietly = TRUE)) {
BiocManager::install("DESeq2")
}You can install the QRscore package from Bioconductor with the following command:
Alternatively, you can install the QRscore package from github:
This vignette illustrates how to:
Preprocess and normalize bulk RNA-seq data.
Perform two-sample and three-sample differential tests using
QRscore.
Obtain results for DEGs and DDGs.
Here are detailed steps of using the package for analysis.
The example dataset contains 3000 randomly selected genes in RNA-seq counts data from whole blood samples in the GTEx project, along with associated metadata for age groups.
Age groups are aggregated for larger sample size and simplified analysis.
Genes with low expression or high dropout rates are excluded.
The DESeq2 package is used to normalize the filtered
gene expression matrix.
col_means <- colMeans(bulk_sparse_mat, na.rm = TRUE)
col_zeros <- colMeans(bulk_sparse_mat == 0, na.rm = TRUE)
# The following threshold can be modified
col_ids <- which(col_means > 5 & col_zeros < 0.2)
bulk_df <- bulk_sparse_mat[, col_ids]
expr_mat <- t(bulk_df)
coldata <- data.frame(age = ages)
dds <- DESeqDataSetFromMatrix(
countData = expr_mat,
colData = coldata,
design = ~age
)
dds <- estimateSizeFactors(dds)
est_size_factors = dds$sizeFactorThis example compares the 20-39 and 60-79 age groups.
Both mean and dispersion shifts are tested in parallel. The outputs includes ranked p-values of differential variance and differential mean tests for all genes, together with log ratio of mean shifts and variance shifts.
Genes with significant mean shifts are identified.
results_2_sample_mean <- results_2_sample$mean_test
results_2_sample_DEG <-
results_2_sample_mean[
results_2_sample_mean$QRscore_Mean_adj_p_value < 0.05,
]
head(results_2_sample_DEG)
#> QRscore_Mean_p_value QRscore_Mean_adj_p_value
#> ENSG00000272455.1 1.034172e-19 1.254451e-16
#> ENSG00000261326.2 7.244154e-19 3.889184e-16
#> ENSG00000249087.6 9.618757e-19 3.889184e-16
#> ENSG00000271895.2 1.983719e-18 6.015627e-16
#> ENSG00000116205.12 5.266523e-18 1.277659e-15
#> ENSG00000163155.11 7.626605e-18 1.387675e-15
#> Log_FC_Mean_60-79_vs_20-39
#> ENSG00000272455.1 -1.0379163
#> ENSG00000261326.2 -0.9286823
#> ENSG00000249087.6 -0.8174845
#> ENSG00000271895.2 -0.8803063
#> ENSG00000116205.12 -0.7140029
#> ENSG00000163155.11 -1.1847951Genes with significant variance shifts are identified.
results_2_sample_var <- results_2_sample$var_test
results_2_sample_DDG <-
results_2_sample_var[results_2_sample_var$QRscore_Var_adj_p_value < 0.05, ]
head(results_2_sample_DDG)
#> QRscore_Var_p_value QRscore_Var_adj_p_value
#> ENSG00000162692.10 6.109419e-13 7.410725e-10
#> ENSG00000189409.13 5.375410e-11 3.260186e-08
#> ENSG00000177606.6 1.682824e-10 6.804217e-08
#> ENSG00000188290.10 6.771200e-10 2.053366e-07
#> ENSG00000162383.11 1.184703e-09 2.874089e-07
#> ENSG00000134240.11 4.497744e-09 9.092940e-07
#> Log_FC_Var_60-79_vs_20-39
#> ENSG00000162692.10 2.4332081
#> ENSG00000189409.13 0.8072178
#> ENSG00000177606.6 0.2094172
#> ENSG00000188290.10 0.3225796
#> ENSG00000162383.11 2.1536069
#> ENSG00000134240.11 6.7424469This example compares the 20-39, 40-59, and 60-79 age groups.
The output includes 3-sample test p-values as well as pairwise fold
changes. To get a more comprehensive result, one can set
pairwise_test = TRUE to additionally obtain the pairwise
test p-values.
results_3_sample <- QRscoreGenetest(
expr_mat, coldata$age, size_factors = est_size_factors,
pairwise_test = FALSE,
pairwise_logFC = TRUE, test_mean = TRUE,
test_dispersion = TRUE, num_cores = 2,
approx = "asymptotic"
)For detecting DDGs and DEGs, it’s recommended to use 3-sample test
p-values (namely QRscore_Mean_adj_p_value and
QRscore_Var_adj_p_value) with certain cutoffs
(e.g. 0.05).
### DEGs
results_3_sample_mean <- results_3_sample$mean_test
results_3_sample_DEG <- results_3_sample_mean[
results_3_sample_mean$QRscore_Mean_adj_p_value < 0.05,
]
head(results_3_sample_DEG)
#> QRscore_Mean_p_value QRscore_Mean_adj_p_value
#> ENSG00000272455.1 2.473653e-19 2.323808e-16
#> ENSG00000116205.12 4.576349e-19 2.323808e-16
#> ENSG00000271895.2 5.747259e-19 2.323808e-16
#> ENSG00000261326.2 1.416041e-18 4.294144e-16
#> ENSG00000272078.1 2.610144e-18 6.332210e-16
#> ENSG00000162526.6 3.385879e-18 6.845119e-16
#> Log_FC_Mean_40-59_vs_20-39 Log_FC_Mean_60-79_vs_20-39
#> ENSG00000272455.1 -0.4483026 -1.0379163
#> ENSG00000116205.12 -0.3581835 -0.7140029
#> ENSG00000271895.2 -0.4010168 -0.8803063
#> ENSG00000261326.2 -0.3939637 -0.9286823
#> ENSG00000272078.1 0.6447943 1.1566804
#> ENSG00000162526.6 -0.3306444 -0.6571025
#> Log_FC_Mean_60-79_vs_40-59
#> ENSG00000272455.1 -0.5896137
#> ENSG00000116205.12 -0.3558193
#> ENSG00000271895.2 -0.4792895
#> ENSG00000261326.2 -0.5347186
#> ENSG00000272078.1 0.5118861
#> ENSG00000162526.6 -0.3264581### DDGs
results_3_sample_var <- results_3_sample$var_test
results_3_sample_DDG <-
results_3_sample_var[results_3_sample_var$QRscore_Var_adj_p_value < 0.05, ]
head(results_3_sample_DDG)
#> QRscore_Var_p_value QRscore_Var_adj_p_value
#> ENSG00000189409.13 4.283451e-10 2.949789e-07
#> ENSG00000177606.6 5.764378e-10 2.949789e-07
#> ENSG00000162692.10 7.295440e-10 2.949789e-07
#> ENSG00000188290.10 1.762051e-08 4.643779e-06
#> ENSG00000162383.11 1.914171e-08 4.643779e-06
#> ENSG00000233184.6 6.346682e-08 1.283088e-05
#> Log_FC_Var_40-59_vs_20-39 Log_FC_Var_60-79_vs_20-39
#> ENSG00000189409.13 0.4795484 0.8072178
#> ENSG00000177606.6 0.3483889 0.2094172
#> ENSG00000162692.10 0.3628677 2.4332081
#> ENSG00000188290.10 -1.8237979 0.3225796
#> ENSG00000162383.11 1.8681958 2.1536069
#> ENSG00000233184.6 0.1407786 0.4660539
#> Log_FC_Var_60-79_vs_40-59
#> ENSG00000189409.13 0.3276693
#> ENSG00000177606.6 -0.1389717
#> ENSG00000162692.10 2.0703404
#> ENSG00000188290.10 2.1463775
#> ENSG00000162383.11 0.2854110
#> ENSG00000233184.6 0.3252753sessionInfo()
#> R version 4.6.2 (2026-10-29)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04.1 LTS
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so; LAPACK version 3.12.0
#>
#> 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
#>
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats4 stats graphics grDevices utils datasets methods
#> [8] base
#>
#> other attached packages:
#> [1] DESeq2_1.53.7 SummarizedExperiment_1.43.0
#> [3] Biobase_2.73.2 MatrixGenerics_1.25.0
#> [5] matrixStats_1.5.0 GenomicRanges_1.65.4
#> [7] Seqinfo_1.3.2 IRanges_2.47.5
#> [9] S4Vectors_0.51.10 BiocGenerics_0.59.12
#> [11] generics_0.1.4 QRscore_1.5.2
#> [13] BiocStyle_2.41.0
#>
#> loaded via a namespace (and not attached):
#> [1] gmp_0.7-5.1 sass_0.4.10 SparseArray_1.13.4
#> [4] lattice_0.23-1 digest_0.6.39 magrittr_2.0.5
#> [7] RColorBrewer_1.1-3 grid_4.6.2 evaluate_1.0.5
#> [10] fastmap_1.2.0 jsonlite_2.0.0 Matrix_1.7-6
#> [13] BiocManager_1.30.27 hitandrun_0.5-6 scales_1.4.0
#> [16] codetools_0.2-20 jquerylib_0.1.4 abind_1.4-8
#> [19] cli_3.6.6 rlang_1.3.0 XVector_0.53.0
#> [22] DelayedArray_0.39.8 cachem_1.1.0 yaml_2.3.12
#> [25] otel_0.2.0 S4Arrays_1.13.2 tools_4.6.2
#> [28] parallel_4.6.2 BiocParallel_1.47.0 dplyr_1.2.1
#> [31] ggplot2_4.0.3 locfit_1.5-9.12 assertthat_0.2.1
#> [34] buildtools_1.0.0 vctrs_0.7.3 R6_2.6.1
#> [37] lifecycle_1.0.5 arrangements_1.1.10 MASS_7.3-66
#> [40] pkgconfig_2.0.3 gtable_0.3.6 pillar_1.11.1
#> [43] bslib_0.12.0 Rcpp_1.1.2 glue_1.8.1
#> [46] xfun_0.62 tibble_3.3.1 tidyselect_1.2.1
#> [49] sys_3.4.3 knitr_1.52 farver_2.1.2
#> [52] htmltools_0.5.9 rmarkdown_2.32 maketools_1.3.2
#> [55] pscl_1.5.9 compiler_4.6.2 S7_0.2.2