Calculate Earth Mover's distance between two flowFrames
EMDDist(
ff1,
ff2,
channels = NULL,
checkChannels = TRUE,
binSize = 0.05,
minRange = -10,
maxRange = 10,
returnAll = FALSE
)
a flowCore::flowFrame
a flowCore::flowFrame
which channels (integer index(ices) or character(s)):
if it is a character vector, it can refer to either the channel names, or the marker names
if it is a numeric vector,
it refers to the indexes of channels in ff1
if NULL all scatter and fluorescent channels of ff1
will be selected
if TRUE
, will explicitly check that
all provided channels are present in both flowFrames
size of equal bins to approximate the marginal distributions.
minimum value taken when approximating the marginal distributions
maximum value taken when approximating the marginal distributions
If TRUE
, distributions and marginal distribution
distances are returned as well. Default = FALSE
.
the Earth Mover's distance between ff1
and ff2
,
which is calculated by summing up all EMD approximates for
the marginal distributions of each channel
library(CytoPipeline)
data(OMIP021Samples)
# estimate scale transformations
# and transform the whole OMIP021Samples
transList <- estimateScaleTransforms(
ff = OMIP021Samples[[1]],
fluoMethod = "estimateLogicle",
scatterMethod = "linearQuantile",
scatterRefMarker = "BV785 - CD3")
OMIP021Trans <- CytoPipeline::applyScaleTransforms(
OMIP021Samples,
transList)
# distance with itself (all channels at once)
# => should return 0
dist0 <- EMDDist(
ff1 = OMIP021Trans[[1]],
ff2 = OMIP021Trans[[1]])
# returning only distance, 2 channels
dist1 <- EMDDist(
ff1 = OMIP021Trans[[1]],
ff2 = OMIP021Trans[[2]],
channels = c("FSC-A", "SSC-A"))
# using only one channel, passed by marker name
dist2 <- EMDDist(ff1 = OMIP021Trans[[1]],
ff2 = OMIP021Trans[[2]],
channels = c("BV785 - CD3"))
# using only one channel, passed by index
dist3 <- EMDDist(ff1 = OMIP021Trans[[1]],
ff2 = OMIP021Trans[[2]],
channels = 10)
dist2 == dist3
#> [1] TRUE