mergeCommunities: Merge communities from graph-based clustering

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/mergeCommunities.R

Description

Adjust the resolution of a graph-based community detection algorithm by greedily merging clusters together. At each step, the pair of clusters that yield the highest modularity are merged.

Usage

1
mergeCommunities(graph, clusters, number = NULL, steps = NULL)

Arguments

graph

A graph object from igraph, usually where each node represents an observation.

clusters

Factor specifying the cluster identity for each node.

number

Integer scalar specifying the number of clusters to obtain. Ignored if steps is specified.

steps

Integer scalar specifying the number of merge steps.

Details

This function is similar to the cut_at function from the igraph package, but works on clusters that were not generated by a hierarchical algorithm. The aim is to facilitate rapid adjustment of the number of clusters without having to repeat the clustering - or, even worse, repeating the graph construction, e.g., in makeSNNGraph.

Value

A vector or factor of the same length as clusters, containing the desired number of merged clusters.

Author(s)

Aaron Lun

See Also

cut_at, for a faster and more natural adjustment when using a hierarchical community detection algorithm.

NNGraphParam, for a one-liner to generate graph-based clusters.

Examples

1
2
3
4
5
output <- clusterRows(iris[,1:4], NNGraphParam(k=5), full=TRUE)
table(output$clusters)

merged <- mergeCommunities(output$objects$graph, output$clusters, number=3)
table(merged)

bluster documentation built on Nov. 8, 2020, 8:29 p.m.