Combines sequence clustering and network estimation into a single call.
Clusters the data using the specified algorithm, then calls
build_network on each cluster subset.
Arguments
- data
Sequence data. Accepts a data frame, matrix, or
netobject. Seecluster_datafor supported formats.- k
Integer. Number of clusters.
- cluster_by
Character. Clustering algorithm passed to
cluster_data'smethodparameter ("pam","ward.D2","ward.D","complete","average","single","mcquitty","median","centroid"), or"mmm"for Mixed Markov Model clustering. Default:"pam".- dissimilarity
Character. Distance metric for sequence clustering (ignored when
cluster_by = "mmm"). Default:"hamming".- ...
Passed directly to
build_network. Usemethodto specify the network type;threshold,scaling, and all otherbuild_networkarguments are supported.
Details
If data is a netobject and method is not provided in
..., the original network method is inherited automatically so the
per-cluster networks match the type of the input network.
Examples
# \donttest{
seqs <- data.frame(
V1 = sample(LETTERS[1:4], 50, TRUE), V2 = sample(LETTERS[1:4], 50, TRUE),
V3 = sample(LETTERS[1:4], 50, TRUE), V4 = sample(LETTERS[1:4], 50, TRUE)
)
# Default: PAM clustering, relative (transition) networks
grp <- cluster_network(seqs, k = 3)
# Specify network method (cor requires numeric panel data)
if (FALSE) { # \dontrun{
panel <- as.data.frame(matrix(rnorm(1500), nrow = 300, ncol = 5))
grp <- cluster_network(panel, k = 2, method = "cor")
} # }
# MMM-based clustering
grp <- cluster_network(seqs, k = 2, cluster_by = "mmm")
# }