Inspect how consistently of a set of clusterings agree with a reference clustering by calculating their element-wise average agreement.
element_agreement(
reference_clustering,
clustering_list,
alpha = 0.9,
r = 1,
rescale_path_type = "max",
ppr_implementation = "prpack",
dist_rescaled = FALSE,
row_normalize = TRUE
)The reference clustering, that each clustering in clustering_list is compared to. It can be either:
A numeric/character/factor vector of cluster labels for each element.
A samples x clusters matrix/Matrix::Matrix of nonzero membership values.
An hclust object.
The list of clustering results, each of which is either:
A numeric/character/factor vector of cluster labels for each element.
A samples x clusters matrix/Matrix::Matrix of nonzero membership values.
An hclust object.
A numeric giving the personalized PageRank damping factor; 1 - alpha is the restart probability for the PPR random walk.
A numeric hierarchical scaling parameter.
A string; rescale the hierarchical height by:
"max" : the maximum path from the root.
"min" : the minimum path form the root.
"linkage" : use the linkage distances in the clustering.
Choose a implementation for personalized page-rank calculation:
"prpack": use PPR algorithms in igraph.
"power_iteration": use power_iteration method.
A logical: if TRUE, the linkage distances are linearly rescaled to be in-between 0 and 1.
Whether to normalize all rows in clustering_result so they sum to one before calculating ECS. It is recommended to set this to TRUE, which will lead to slightly different ECS values compared to clusim.
A vector containing the element-wise average agreement.
Gates, A. J., Wood, I. B., Hetrick, W. P., & Ahn, Y. Y. (2019). Element-centric clustering comparison unifies overlaps and hierarchy. Scientific reports, 9(1), 1-13. https://doi.org/10.1038/s41598-019-44892-y
# perform k-means clustering across 20 random seeds
reference.clustering <- iris$Species
clustering.list <- lapply(1:20, function(x) kmeans(iris[, 1:4], centers = 3)$cluster)
element_agreement(reference.clustering, clustering.list)
#> [1] 0.9150000 0.8350000 0.8350000 0.8350000 0.9150000 0.9150000 0.9150000
#> [8] 0.9150000 0.8350000 0.8350000 0.9150000 0.9150000 0.8350000 0.8350000
#> [15] 0.9150000 0.9150000 0.9150000 0.9150000 0.9150000 0.9150000 0.9150000
#> [22] 0.9150000 0.9150000 0.9150000 0.8350000 0.8350000 0.9150000 0.9150000
#> [29] 0.9150000 0.8350000 0.8350000 0.9150000 0.9150000 0.9150000 0.8350000
#> [36] 0.9150000 0.9150000 0.9150000 0.8350000 0.9150000 0.9150000 0.8350000
#> [43] 0.8350000 0.9150000 0.9150000 0.8350000 0.9150000 0.8350000 0.9150000
#> [50] 0.9150000 0.7004368 0.7004368 0.1497917 0.7004368 0.7004368 0.7004368
#> [57] 0.7004368 0.6006452 0.7004368 0.7004368 0.6006452 0.7004368 0.7004368
#> [64] 0.7004368 0.7004368 0.7004368 0.7004368 0.7004368 0.7004368 0.7004368
#> [71] 0.7004368 0.7004368 0.7004368 0.7004368 0.7004368 0.7004368 0.7004368
#> [78] 0.1497917 0.7004368 0.7004368 0.7004368 0.7004368 0.7004368 0.7004368
#> [85] 0.7004368 0.7004368 0.7004368 0.7004368 0.7004368 0.7004368 0.7004368
#> [92] 0.7004368 0.7004368 0.6006452 0.7004368 0.7004368 0.7004368 0.7004368
#> [99] 0.6006452 0.7004368 0.6702083 0.2995632 0.6702083 0.6702083 0.6702083
#> [106] 0.6702083 0.2995632 0.6702083 0.6702083 0.6702083 0.6702083 0.6702083
#> [113] 0.6702083 0.2995632 0.2995632 0.6702083 0.6702083 0.6702083 0.6702083
#> [120] 0.2995632 0.6702083 0.2995632 0.6702083 0.2995632 0.6702083 0.6702083
#> [127] 0.2995632 0.2995632 0.6702083 0.6702083 0.6702083 0.6702083 0.6702083
#> [134] 0.2995632 0.6702083 0.6702083 0.6702083 0.6702083 0.2995632 0.6702083
#> [141] 0.6702083 0.6702083 0.2995632 0.6702083 0.6702083 0.6702083 0.2995632
#> [148] 0.6702083 0.6702083 0.2995632