cluster_pam: Estimate Optimal Number of Cluster for PAM Algorithm

View source: R/cluster_pam.R

cluster_pam_estimateR Documentation

Estimate Optimal Number of Cluster for PAM Algorithm

Description

cluster::clusGap() cannot be used here for distance matrix, so it is removed.

Usage

cluster_pam_estimate(
  x,
  method = c("silhouette", "wss"),
  k.max = 10,
  verbose = interactive(),
  barfill = "steelblue",
  barcolor = "steelblue",
  linecolor = "steelblue",
  FUNcluster = cluster::pam,
  seed = 1234L,
  clean_memory = FALSE,
  ...
)

cluster_pam(x, k, ...)

Arguments

x

a dissimilarity matrix.

method

the method to be used for estimating the optimal number of clusters. Possible values are "silhouette" (for average silhouette width), "wss" (for total within sum of square) and "gap_stat" (for gap statistics).

k.max

the maximum number of clusters to consider, must be at least two.

verbose

logical value. If TRUE, the result of progress is printed.

barfill

fill color and outline color for bars

barcolor

fill color and outline color for bars

linecolor

color for lines

FUNcluster

a partitioning function which accepts as first argument a (data) matrix like x, second argument, say k, k >= 2, the number of clusters desired, and returns a list with a component named cluster which contains the grouping of observations. Allowed values include: kmeans, cluster::pam, cluster::clara, cluster::fanny, hcut, etc. This argument is not required when x is an output of the function NbClust::NbClust().

seed

random seed.

clean_memory

logical. If TRUE, the cluster result object will be removed and the memory will be released by calling gc() to reduce the memory consumption.

...

other parameters passing to cluster::pam.

k

positive integer specifying the number of clusters, less than the number of observations.

Value

a ggplot object.

a PAM clustering result object.

Examples

data("iris")
head(iris)
iris.scaled <- scale(iris[, -5])
iris.dist <- dist(iris.scaled) %>% as.matrix()
p <- cluster_pam_estimate(iris.dist)
p2 <- cluster_pam_estimate(iris.dist, method = "wss")

cl <- cluster_pam(iris.dist, 3)

ShixiangWang/CNVMotif documentation built on June 3, 2022, 3:44 a.m.