Compare a set of clusterings by calculating their pairwise average element-centric clustering similarities.
Usage
element_sim_matrix(
clustering_list,
output_type = "matrix",
alpha = 0.9,
r = 1,
rescale_path_type = "max",
ppr_implementation = "prpack",
dist_rescaled = FALSE,
row_normalize = TRUE
)
Arguments
- clustering_list
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.
- output_type
A string specifying whether the output should be a matrix or a data.frame.
- alpha
A numeric giving the personalized PageRank damping factor; 1 - alpha is the restart probability for the PPR random walk.
- r
A numeric hierarchical scaling parameter.
- rescale_path_type
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.
- ppr_implementation
Choose a implementation for personalized page-rank calculation:
"prpack": use PPR algorithms in igraph.
"power_iteration": use power_iteration method.
- dist_rescaled
A logical: if TRUE, the linkage distances are linearly rescaled to be in-between 0 and 1.
- row_normalize
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.
References
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
Examples
# cluster across 20 random seeds
clustering.list <- lapply(1:20, function(x) kmeans(mtcars, centers = 3)$cluster)
element_sim_matrix(clustering.list, output_type = "matrix")
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
#> [1,] 1.0000000 0.5396205 0.5396205 1.0000000 0.5396205 1.0000000 1.0000000
#> [2,] 0.5396205 1.0000000 1.0000000 0.5396205 1.0000000 0.5396205 0.5396205
#> [3,] 0.5396205 1.0000000 1.0000000 0.5396205 1.0000000 0.5396205 0.5396205
#> [4,] 1.0000000 0.5396205 0.5396205 1.0000000 0.5396205 1.0000000 1.0000000
#> [5,] 0.5396205 1.0000000 1.0000000 0.5396205 1.0000000 0.5396205 0.5396205
#> [6,] 1.0000000 0.5396205 0.5396205 1.0000000 0.5396205 1.0000000 1.0000000
#> [7,] 1.0000000 0.5396205 0.5396205 1.0000000 0.5396205 1.0000000 1.0000000
#> [8,] 1.0000000 0.5396205 0.5396205 1.0000000 0.5396205 1.0000000 1.0000000
#> [9,] 0.5503724 0.7012775 0.7012775 0.5503724 0.7012775 0.5503724 0.5503724
#> [10,] 0.5503724 0.7012775 0.7012775 0.5503724 0.7012775 0.5503724 0.5503724
#> [11,] 0.5503724 0.7012775 0.7012775 0.5503724 0.7012775 0.5503724 0.5503724
#> [12,] 0.5396205 1.0000000 1.0000000 0.5396205 1.0000000 0.5396205 0.5396205
#> [13,] 0.5396205 1.0000000 1.0000000 0.5396205 1.0000000 0.5396205 0.5396205
#> [14,] 0.5503724 0.7012775 0.7012775 0.5503724 0.7012775 0.5503724 0.5503724
#> [15,] 0.5396205 1.0000000 1.0000000 0.5396205 1.0000000 0.5396205 0.5396205
#> [16,] 1.0000000 0.5396205 0.5396205 1.0000000 0.5396205 1.0000000 1.0000000
#> [17,] 1.0000000 0.5396205 0.5396205 1.0000000 0.5396205 1.0000000 1.0000000
#> [18,] 0.5396205 1.0000000 1.0000000 0.5396205 1.0000000 0.5396205 0.5396205
#> [19,] 0.5503724 0.7012775 0.7012775 0.5503724 0.7012775 0.5503724 0.5503724
#> [20,] 1.0000000 0.5396205 0.5396205 1.0000000 0.5396205 1.0000000 1.0000000
#> [,8] [,9] [,10] [,11] [,12] [,13] [,14]
#> [1,] 1.0000000 0.5503724 0.5503724 0.5503724 0.5396205 0.5396205 0.5503724
#> [2,] 0.5396205 0.7012775 0.7012775 0.7012775 1.0000000 1.0000000 0.7012775
#> [3,] 0.5396205 0.7012775 0.7012775 0.7012775 1.0000000 1.0000000 0.7012775
#> [4,] 1.0000000 0.5503724 0.5503724 0.5503724 0.5396205 0.5396205 0.5503724
#> [5,] 0.5396205 0.7012775 0.7012775 0.7012775 1.0000000 1.0000000 0.7012775
#> [6,] 1.0000000 0.5503724 0.5503724 0.5503724 0.5396205 0.5396205 0.5503724
#> [7,] 1.0000000 0.5503724 0.5503724 0.5503724 0.5396205 0.5396205 0.5503724
#> [8,] 1.0000000 0.5503724 0.5503724 0.5503724 0.5396205 0.5396205 0.5503724
#> [9,] 0.5503724 1.0000000 1.0000000 1.0000000 0.7012775 0.7012775 1.0000000
#> [10,] 0.5503724 1.0000000 1.0000000 1.0000000 0.7012775 0.7012775 1.0000000
#> [11,] 0.5503724 1.0000000 1.0000000 1.0000000 0.7012775 0.7012775 1.0000000
#> [12,] 0.5396205 0.7012775 0.7012775 0.7012775 1.0000000 1.0000000 0.7012775
#> [13,] 0.5396205 0.7012775 0.7012775 0.7012775 1.0000000 1.0000000 0.7012775
#> [14,] 0.5503724 1.0000000 1.0000000 1.0000000 0.7012775 0.7012775 1.0000000
#> [15,] 0.5396205 0.7012775 0.7012775 0.7012775 1.0000000 1.0000000 0.7012775
#> [16,] 1.0000000 0.5503724 0.5503724 0.5503724 0.5396205 0.5396205 0.5503724
#> [17,] 1.0000000 0.5503724 0.5503724 0.5503724 0.5396205 0.5396205 0.5503724
#> [18,] 0.5396205 0.7012775 0.7012775 0.7012775 1.0000000 1.0000000 0.7012775
#> [19,] 0.5503724 1.0000000 1.0000000 1.0000000 0.7012775 0.7012775 1.0000000
#> [20,] 1.0000000 0.5503724 0.5503724 0.5503724 0.5396205 0.5396205 0.5503724
#> [,15] [,16] [,17] [,18] [,19] [,20]
#> [1,] 0.5396205 1.0000000 1.0000000 0.5396205 0.5503724 1.0000000
#> [2,] 1.0000000 0.5396205 0.5396205 1.0000000 0.7012775 0.5396205
#> [3,] 1.0000000 0.5396205 0.5396205 1.0000000 0.7012775 0.5396205
#> [4,] 0.5396205 1.0000000 1.0000000 0.5396205 0.5503724 1.0000000
#> [5,] 1.0000000 0.5396205 0.5396205 1.0000000 0.7012775 0.5396205
#> [6,] 0.5396205 1.0000000 1.0000000 0.5396205 0.5503724 1.0000000
#> [7,] 0.5396205 1.0000000 1.0000000 0.5396205 0.5503724 1.0000000
#> [8,] 0.5396205 1.0000000 1.0000000 0.5396205 0.5503724 1.0000000
#> [9,] 0.7012775 0.5503724 0.5503724 0.7012775 1.0000000 0.5503724
#> [10,] 0.7012775 0.5503724 0.5503724 0.7012775 1.0000000 0.5503724
#> [11,] 0.7012775 0.5503724 0.5503724 0.7012775 1.0000000 0.5503724
#> [12,] 1.0000000 0.5396205 0.5396205 1.0000000 0.7012775 0.5396205
#> [13,] 1.0000000 0.5396205 0.5396205 1.0000000 0.7012775 0.5396205
#> [14,] 0.7012775 0.5503724 0.5503724 0.7012775 1.0000000 0.5503724
#> [15,] 1.0000000 0.5396205 0.5396205 1.0000000 0.7012775 0.5396205
#> [16,] 0.5396205 1.0000000 1.0000000 0.5396205 0.5503724 1.0000000
#> [17,] 0.5396205 1.0000000 1.0000000 0.5396205 0.5503724 1.0000000
#> [18,] 1.0000000 0.5396205 0.5396205 1.0000000 0.7012775 0.5396205
#> [19,] 0.7012775 0.5503724 0.5503724 0.7012775 1.0000000 0.5503724
#> [20,] 0.5396205 1.0000000 1.0000000 0.5396205 0.5503724 1.0000000