| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/bk_method.R |
| 3 |
\name{Bk_permutations} |
| 4 |
\alias{Bk_permutations} |
| 5 |
\title{Bk permutation - Calculating Fowlkes-Mallows Index for two dendrogram} |
| 6 |
\usage{ |
| 7 |
Bk_permutations( |
| 8 |
tree1, |
| 9 |
tree2, |
| 10 |
k, |
| 11 |
R = 1000, |
| 12 |
warn = dendextend_options("warn"), |
| 13 |
... |
| 14 |
) |
| 15 |
} |
| 16 |
\arguments{ |
| 17 |
\item{tree1}{a dendrogram/hclust/phylo object.} |
| 18 |
|
| 19 |
\item{tree2}{a dendrogram/hclust/phylo object.} |
| 20 |
|
| 21 |
\item{k}{an integer scalar or vector with the desired number |
| 22 |
of cluster groups. |
| 23 |
If missing - the Bk will be calculated for a default k range of |
| 24 |
2:(nleaves-1). |
| 25 |
No point in checking k=1/k=n, since both will give Bk=1.} |
| 26 |
|
| 27 |
\item{R}{integer (Default is 1000). The number of Bk permutation to perform for each k.} |
| 28 |
|
| 29 |
\item{warn}{logical (default from dendextend_options("warn") is FALSE). |
| 30 |
Set if warning are to be issued, it is safer to keep this at TRUE, |
| 31 |
but for keeping the noise down, the default is FALSE. |
| 32 |
If set to TRUE, extra checks are made to varify that the two clusters have |
| 33 |
the same size and the same labels.} |
| 34 |
|
| 35 |
\item{...}{Ignored (passed to FM_index_R).} |
| 36 |
} |
| 37 |
\value{ |
| 38 |
A list (of the length of k's), where each element of the list has |
| 39 |
R (number of permutations) calculations of Fowlkes-Mallows index |
| 40 |
between two dendrogram after having their labels shuffled. |
| 41 |
|
| 42 |
The names of the lists' items is the k for which it was calculated. |
| 43 |
} |
| 44 |
\description{ |
| 45 |
Bk is the calculation of Fowlkes-Mallows index for a series of k cuts |
| 46 |
for two dendrograms. |
| 47 |
|
| 48 |
Bk permutation calculates the Bk under the null hypothesis of no similarirty |
| 49 |
between the two trees by randomally shuffling the labels of the two trees |
| 50 |
and calculating their Bk. |
| 51 |
} |
| 52 |
\details{ |
| 53 |
From Wikipedia: |
| 54 |
|
| 55 |
Fowlkes-Mallows index (see references) is an external evaluation method |
| 56 |
that is used to determine the similarity between two clusterings |
| 57 |
(clusters obtained after a clustering algorithm). This measure of similarity |
| 58 |
could be either between two hierarchical clusterings or a clustering and |
| 59 |
a benchmark classification. A higher the value for the Fowlkes-Mallows index |
| 60 |
indicates a greater similarity between the clusters and the benchmark |
| 61 |
classifications. |
| 62 |
} |
| 63 |
\examples{ |
| 64 |
|
| 65 |
\dontrun{ |
| 66 |
|
| 67 |
set.seed(23235) |
| 68 |
ss <- TRUE # sample(1:150, 10 ) |
| 69 |
hc1 <- hclust(dist(iris[ss, -5]), "com") |
| 70 |
hc2 <- hclust(dist(iris[ss, -5]), "single") |
| 71 |
# tree1 <- as.treerogram(hc1) |
| 72 |
# tree2 <- as.treerogram(hc2) |
| 73 |
# cutree(tree1) |
| 74 |
|
| 75 |
some_Bk <- Bk(hc1, hc2, k = 20) |
| 76 |
some_Bk_permu <- Bk_permutations(hc1, hc2, k = 20) |
| 77 |
|
| 78 |
# we can see that the Bk is much higher than the permutation Bks: |
| 79 |
plot( |
| 80 |
x = rep(1, 1000), y = some_Bk_permu[[1]], |
| 81 |
main = "Bk distribution under H0", |
| 82 |
ylim = c(0, 1) |
| 83 |
) |
| 84 |
points(1, y = some_Bk, pch = 19, col = 2) |
| 85 |
} |
| 86 |
} |
| 87 |
\references{ |
| 88 |
Fowlkes, E. B.; Mallows, C. L. (1 September 1983). |
| 89 |
"A Method for Comparing Two Hierarchical Clusterings". |
| 90 |
Journal of the American Statistical Association 78 (383): 553. |
| 91 |
|
| 92 |
\url{https://en.wikipedia.org/wiki/Fowlkes-Mallows_index} |
| 93 |
} |
| 94 |
\seealso{ |
| 95 |
\code{\link{FM_index}}, \link{Bk} |
| 96 |
} |