Configure clustering methods
Usage
register_clustering_methods(...)
all_clustering_methods()
remove_clustering_methods(method)
reset_clustering_methods()
Arguments
- ...
A named list of clustering functions, see in Details.
- method
A vector of method names.
Details
The user-defined functions should accept at least one argument which is the input matrix.
The second optional argument should always be ...
so that parameters
for the clustering function can be passed by the control
argument from cluster_terms()
, simplifyGO()
or simplifyEnrichment()
.
If users forget to add ...
, it is added internally.
Please note, the user-defined function should automatically identify the optimized number of clusters.
The function should return a vector of cluster labels. Internally it is converted to numeric labels.
The default clustering methods are:
kmeans
seecluster_by_kmeans()
.dynamicTreeCut
seecluster_by_dynamicTreeCut()
.mclust
seecluster_by_mclust()
.apcluster
seecluster_by_apcluster()
.hdbscan
seecluster_by_hdbscan()
.fast_greedy
seecluster_by_fast_greedy()
.louvain
seecluster_by_louvain()
.walktrap
seecluster_by_walktrap()
.MCL
seecluster_by_MCL()
.binary_cut
seebinary_cut()
.
Examples
register_clustering_methods(
# assume there are 5 groups
random = function(mat, ...) sample(5, nrow(mat), replace = TRUE)
)
all_clustering_methods()
#> [1] "binary_cut" "kmeans" "pam" "dynamicTreeCut"
#> [5] "mclust" "apcluster" "hdbscan" "fast_greedy"
#> [9] "louvain" "walktrap" "MCL" "random"
remove_clustering_methods("random")
all_clustering_methods()
#> [1] "binary_cut" "kmeans" "pam" "dynamicTreeCut"
#> [5] "mclust" "apcluster" "hdbscan" "fast_greedy"
#> [9] "louvain" "walktrap" "MCL"
remove_clustering_methods(c("kmeans", "mclust"))
all_clustering_methods()
#> [1] "binary_cut" "pam" "dynamicTreeCut" "apcluster"
#> [5] "hdbscan" "fast_greedy" "louvain" "walktrap"
#> [9] "MCL"
reset_clustering_methods()
all_clustering_methods()
#> [1] "kmeans" "pam" "dynamicTreeCut" "mclust"
#> [5] "apcluster" "hdbscan" "fast_greedy" "louvain"
#> [9] "walktrap" "MCL" "binary_cut"