Cluster groups based on an adjacency/confusion matrix using Louvain
Usage
cluster_adjacency_matrix(
adj_matrix,
cutoff = 0.1,
resolution = 1,
algorithm = "louvain"
)
Arguments
- adj_matrix
Adjacency matrix (e.g., normalized confusion matrix)
- cutoff
Threshold for binarizing the matrix (default: 0.1)
- resolution
Resolution parameter for Louvain clustering (default: 1.0)
- algorithm
Clustering algorithm: "louvain" or "leiden" (if igraph supports it)
Value
Integer vector of cluster assignments
Details
The function:
Binarizes the adjacency matrix using the cutoff
Creates a graph from the binary matrix
Applies Louvain/Leiden clustering to identify groups of connected clusters
Examples
# Create a sample adjacency matrix
adj <- matrix(c(0, 0.3, 0.05, 0.3, 0, 0.02, 0.05, 0.02, 0), nrow = 3)
rownames(adj) <- colnames(adj) <- c("A", "B", "C")
cluster_adjacency_matrix(adj, cutoff = 0.1)
#> [1] 1 1 2