waddR package offers statistical tests based on the 2-Wasserstein distance for detecting and characterizing differences between two distributions given in the form of samples. Functions for calculating the 2-Wasserstein distance and testing for differential distributions are provided, as well as a specifically tailored test for differential expression in single-cell RNA sequencing data.
waddR provides tools to address the following tasks, each described in a separate vignette:
Two-sample tests to check for differences between two distributions,
Detection of differential gene expression distributions in single-cell RNA sequencing (scRNAseq) data.
These are bundled into one package, because they are internally dependent: The procedure for detecting differential distributions in scRNAseq data is an adaptation of the general two-sample test, which itself uses the 2-Wasserstein distance to compare two distributions.
The 2-Wasserstein distance is a metric to describe the distance between two distributions, representing e.g. two diferent conditions \(A\) and \(B\). The
waddR package specifically considers the squared 2-Wasserstein distance which can be decomposed into location, size, and shape terms, thus providing a characterization of potential differences.
waddR package offers three functions to calculate the (squared) 2-Wasserstein distance, which are implemented in C++ and exported to R with Rcpp for faster computation. The function
wasserstein_metric is a Cpp reimplementation of the
wasserstein1d function from the R package
transport. The functions
squared_wass_decomp compute approximations of the squared 2-Wasserstein distance, with
squared_wass_decomp also returning the decomposition terms for location, size, and shape.
?squared_wass_decomp for more details.
waddR package provides two testing procedures using the 2-Wasserstein distance to test whether two distributions \(F_A\) and \(F_B\) given in the form of samples are different by testing the null hypothesis \(H_0: F_A = F_B\) against the alternative hypothesis \(H_1: F_A != F_B\).
The first, semi-parametric (SP), procedure uses a permutation-based test combined with a generalized Pareto distribution approximation to estimate small p-values accurately.
The second procedure uses a test based on asymptotic theory (ASY) which is valid only if the samples can be assumed to come from continuous distributions.
?wasserstein.test for more details.
waddR package provides an adaptation of the semi-parametric testing procedure based on the 2-Wasserstein distance which is specifically tailored to identify differential distributions in scRNAseq data. In particular, a two-stage (TS) approach is implemented that takes account of the specific nature of scRNAseq data by separately testing for differential proportions of zero gene expression (using a logistic regression model) and differences in non-zero gene expression (using the semiparametric 2-Wasserstein distance-based test) between two conditions.
?testZeroes for more details.
waddR from Bioconductor, use
BiocManager with the following commands:
BiocManager, the package can also be installed from GitHub directly:
waddR can then be used in R:
sessionInfo() #> R Under development (unstable) (2021-10-19 r81077) #> Platform: x86_64-pc-linux-gnu (64-bit) #> Running under: Ubuntu 20.04.3 LTS #> #> Matrix products: default #> BLAS: /home/biocbuild/bbs-3.15-bioc/R/lib/libRblas.so #> LAPACK: /home/biocbuild/bbs-3.15-bioc/R/lib/libRlapack.so #> #> locale: #>  LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C #>  LC_TIME=en_GB LC_COLLATE=C #>  LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 #>  LC_PAPER=en_US.UTF-8 LC_NAME=C #>  LC_ADDRESS=C LC_TELEPHONE=C #>  LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C #> #> attached base packages: #>  stats graphics grDevices utils datasets methods base #> #> other attached packages: #>  waddR_1.9.0 #> #> loaded via a namespace (and not attached): #>  MatrixGenerics_1.7.0 Biobase_2.55.0 #>  httr_1.4.2 sass_0.4.0 #>  bit64_4.0.5 jsonlite_1.7.2 #>  splines_4.2.0 bslib_0.3.1 #>  assertthat_0.2.1 stats4_4.2.0 #>  BiocFileCache_2.3.0 blob_1.2.2 #>  GenomeInfoDbData_1.2.7 yaml_2.2.1 #>  pillar_1.6.4 RSQLite_2.2.8 #>  lattice_0.20-45 glue_1.4.2 #>  digest_0.6.28 GenomicRanges_1.47.1 #>  XVector_0.35.0 minqa_1.2.4 #>  htmltools_0.5.2 Matrix_1.3-4 #>  pkgconfig_2.0.3 zlibbioc_1.41.0 #>  purrr_0.3.4 BiocParallel_1.29.0 #>  lme4_1.1-27.1 arm_1.12-2 #>  tibble_3.1.5 generics_0.1.1 #>  IRanges_2.29.0 ellipsis_0.3.2 #>  withr_2.4.2 cachem_1.0.6 #>  SummarizedExperiment_1.25.0 BiocGenerics_0.41.0 #>  magrittr_2.0.1 crayon_1.4.1 #>  memoise_2.0.0 evaluate_0.14 #>  fansi_0.5.0 nlme_3.1-153 #>  MASS_7.3-54 tools_4.2.0 #>  lifecycle_1.0.1 matrixStats_0.61.0 #>  stringr_1.4.0 S4Vectors_0.33.0 #>  DelayedArray_0.21.0 eva_0.2.6 #>  compiler_4.2.0 jquerylib_0.1.4 #>  GenomeInfoDb_1.31.0 rlang_0.4.12 #>  grid_4.2.0 RCurl_1.98-1.5 #>  nloptr_184.108.40.206 rappdirs_0.3.3 #>  SingleCellExperiment_1.17.0 bitops_1.0-7 #>  rmarkdown_2.11 boot_1.3-28 #>  abind_1.4-5 DBI_1.1.1 #>  curl_4.3.2 R6_2.5.1 #>  knitr_1.36 dplyr_1.0.7 #>  fastmap_1.1.0 bit_4.0.4 #>  utf8_1.2.2 filelock_1.0.2 #>  stringi_1.7.5 parallel_4.2.0 #>  Rcpp_1.0.7 vctrs_0.3.8 #>  dbplyr_2.1.1 tidyselect_1.1.1 #>  xfun_0.27 coda_0.19-4