Kulczynski beta diversity metric.
Usage
kulczynski(counts, weighted = TRUE, pairs = NULL, cpus = n_cpus())
Arguments
- counts
An OTU abundance matrix where each column is a sample, and each row is an OTU. Any object coercible with
as.matrix()
can be given here, as well asphyloseq
,rbiom
,SummarizedExperiment
, andTreeSummarizedExperiment
objects.- weighted
If
TRUE
, the algorithm takes relative abundances into account. IfFALSE
, only presence/absence is considered.- pairs
Which combinations of samples should distances be calculated for? The default value (
NULL
) calculates all-vs-all. Provide a numeric or logical vector specifying positions in the distance matrix to calculate. See examples.- cpus
How many parallel processing threads should be used. The default,
n_cpus()
, will use all logical CPU cores.
Calculation
In the formulas below, x
and y
are two columns (samples) from counts
.
n
is the number of rows (OTUs) in counts
.
$$t = \displaystyle \sum_{i = 1}^{n} min(x_i,y_i)$$ $$D = \displaystyle 1 - 0.5(\frac{t}{\sum_{i = 1}^{n} x_i} + \frac{t}{\sum_{i = 1}^{n} y_i})$$
References
Kulcynski S 1927. Die Pflanzenassoziationen der Pieninen. Bulletin International de l'Academie Polonaise des Sciences et des Lettres. Classe des Sciences Mathematiques et Naturelles.
See also
Other beta_diversity:
bray_curtis()
,
canberra()
,
euclidean()
,
generalized_unifrac()
,
gower()
,
jaccard()
,
manhattan()
,
unweighted_unifrac()
,
variance_adjusted_unifrac()
,
weighted_normalized_unifrac()
,
weighted_unifrac()
Examples
# Example counts matrix
ex_counts
#> Saliva Gums Nose Stool
#> Streptococcus 162 793 22 1
#> Bacteroides 2 4 2 611
#> Corynebacterium 0 0 498 1
#> Haemophilus 180 87 2 1
#> Propionibacterium 1 1 251 0
#> Staphylococcus 0 1 236 1
# Kulczynski weighted distance matrix
kulczynski(ex_counts)
#> Saliva Gums Nose
#> Gums 0.4925704
#> Nose 0.9475164 0.9703510
#> Stool 0.9909509 0.9903586 0.9921546
# Kulczynski unweighted distance matrix
kulczynski(ex_counts, weighted = FALSE)
#> Saliva Gums Nose
#> Gums 0.10000000
#> Nose 0.16666667 0.08333333
#> Stool 0.32500000 0.20000000 0.08333333
# Only calculate distances for A vs all.
kulczynski(ex_counts, pairs = 1:3)
#> Saliva Gums Nose
#> Gums 0.4925704
#> Nose 0.9475164 NA
#> Stool 0.9909509 NA NA