# squared_wass_decomp: Compute the squared 2-Wasserstein distance based on a... In goncalves-lab/diffexpR: Statistical tests for detecting differential distributions based on the 2-Wasserstein distance

 squared_wass_decomp R Documentation

## Compute the squared 2-Wasserstein distance based on a decomposition

### Description

Computes the squared 2-Wasserstein distance between two vectors based on a decomposition into location, size and shape terms. For a detailed description of the (empirical) calculation of the invoved quantities, see Schefzik et al. (2020).

### Usage

``````squared_wass_decomp(x, y)
``````

### Arguments

 `x` sample (vector) representing the distribution of condition `A` `y` sample (vector) representing the distribution of condition `B`

### Value

A list of 4:

• distance: the sum location+size+shape

• location: location part in the decoposition of the 2-Wasserstein distance

• size: size part in the decoposition of the 2-Wasserstein distance

• shape: shape part in the decoposition of the 2-Wasserstein distance

### References

Schefzik, R., Flesch, J., and Goncalves, A. (2020). waddR: Using the 2-Wasserstein distance to identify differences between distributions in two-sample testing, with application to single-cell RNA-sequencing data.

See the functions `wasserstein_metric` and `squared_wass_approx` for alternative implementations of the 2-Wasserstein distance

### Examples

``````set.seed(24)
x<-rnorm(100)
y1<-rnorm(150)
y2<-rexp(150,3)
y3<-rpois(150,2)

squared_wass_decomp(x,y1)
squared_wass_decomp(x,y2)
squared_wass_decomp(x,y3)

``````

goncalves-lab/diffexpR documentation built on June 5, 2023, 10:18 p.m.