A wrapper around the Kmeans clustering algorithm. Iterates over all combinations of ks and methods_kmeans and stores the resulting clustering variables in the feature data.frame.

runKmeansClustering(
  object,
  ks,
  methods_kmeans = "Hartigan-Wong",
  prefix = "K",
  naming = "{method_kmeans}_k{k}",
  n_pcs = NULL,
  overwrite = TRUE,
  ...
)

Arguments

object

An object of class SPATA2 or, in case of S4 generics, objects of classes for which a method has been defined.

ks

Numeric vector. Denotes all options for k-clusters over which to iterate. Values <1 are discarded. (Givent o centers of stats::kmeans()).

methods_kmeans

A character vector of kmeans methods. Should be one or more of c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"). (Given to algorithm of stats::kmeans()).

naming

A glue::glue() instruction on how to name the resulting cluster variables. use method_kmeans to refer to the method and k for the value of k.

n_pcs

Integer value. The number of principal components to use for the clustering.

overwrite

Logical value. Must be TRUE to allow overwriting.

...

Additional arguments given to stats::kmeans().

Value

The updated input object, containing the added, removed or computed results.

Examples

library(SPATA2)

data("example_data")

object <- example_data$object_UKF269T_diet

object <- runPCA(object, n_pcs = 20)

object <- runKmeansClustering(object, ks = 3:10, n_pcs = 20)

getFeatureNames(object)