earthmover_dist: Earthmover distance (and general Wasserstein distance)

Description Usage Arguments Value Examples

View source: R/evaluation.R

Description

i.e., wasserstein distance with L1 (p_param = 1); can also use other penalties > 1 (Not technically earthmover distance if using other p_param values)

Usage

1
earthmover_dist(batch1, batch2, whichdim = 1, numbins = 100, p_param = 1)

Arguments

batch1

matrix; subset of observations from an embedding correponding to some attribute (e.g., batch or phenotype)

batch2

matrix; subset of observations from an embedding correponding to some attribute (e.g., batch or phenotype)

whichdim

int; which dimension (i.e., column) from the embeddings is used. defaults on first

numbins

int; number of bins for the probability discretization (defaults to 100)

p_param

int; penalty parameter for general Wasserstein distance. Defaults to 1, which corresonds to earthmover.

Value

num; the distance

Examples

1
2
3
4
5
# To compare distributions of reduced dimension values to assess similarity, 
# e.g. as a metric for batch integration
embedding <- matrix(sample(x = seq(0,10,.1),1000, replace = TRUE),ncol = 5)
batch <- matrix(sample(c(1,2),200, replace = TRUE))
earthmover_dist(embedding[which(batch == 1),],embedding[which(batch == 2),]) 

corral documentation built on Nov. 8, 2020, 8:25 p.m.