k_select: Plots for helping decide number of clusters

View source: R/kmeans.R

k_selectR Documentation

Plots for helping decide number of clusters

Description

To help decide the number of cluster, three different methods are provided: total within cluster sum of squares, average silhouette coefficient, and gap statistics.

Usage

k_select(
  result,
  method = "wss",
  clust.method = "kmeans",
  n = 10,
  proportional = TRUE
)

Arguments

result

A musica_result object generated by a mutational discovery or prediction tool.

method

A single character string indicating which statistic to use for plot. Options are "wss" (total within cluster sum of squares), "silhouette" (average silhouette coefficient), and "gap_stat" (gap statistic). Default is "wss".

clust.method

A character string indicating clustering method. Options are "kmeans" (default), "hclust" (hierarchical clustering), "hkmeans", "pam", and "clara".

n

An integer indicating maximum number of clusters to test. Default is 10.

proportional

Logical, indicating if proportional exposure (default) will be used for clustering.

Value

A ggplot object.

See Also

fviz_nbclust

Examples

data(res_annot)
set.seed(123)
#Make an elbow plot
k_select(res_annot, method = "wss", n = 6)
#Plot average silhouette coefficient against number of clusters
k_select(res_annot, method = "silhouette", n = 6)
#Plot gap statistics against number of clusters
k_select(res_annot, method = "gap_stat", n = 6)

campbio/musicatk documentation built on July 14, 2024, 8:28 a.m.