Perform KMeans clustering on a
SingleCellExperiment object, with kmeans.
runKMeans(
  inSCE,
  nCenters,
  useReducedDim = "PCA",
  clusterName = "KMeans_cluster",
  nComp = 10,
  nIter = 10,
  nStart = 1,
  seed = 12345,
  algorithm = c("Hartigan-Wong", "Lloyd", "MacQueen")
)A SingleCellExperiment object.
An integer, the number of centroids (clusters).
A single character, specifying which
low-dimension representation to perform the clustering algorithm on. Default
"PCA".
A single character, specifying the name to store
the cluster label in colData. Default "KMeans_cluster".
An integer. The number of components to use for K-Means.
Default 10. See Detail.
An integer, the maximum number of iterations allowed.
Default 10.
An integer, the number of random sets to choose. Default
1.
An integer. The seed for the random number generator.
Default 12345.
A single character. Choose from
"Hartigan-Wong", "Lloyd", "MacQueen". May be
abbreviated. Default "Hartigan-Wong".
The input SingleCellExperiment object with
factor cluster labeling updated in
colData(inSCE)[[clusterName]].
data("mouseBrainSubsetSCE")
mouseBrainSubsetSCE <- runKMeans(mouseBrainSubsetSCE,
                                 useReducedDim = "PCA_logcounts",
                                 nCenters = 2)
#> Tue Jun 28 22:07:07 2022 ... Running 'KMeans clustering' with Hartigan-Wong algorithm.
#> Tue Jun 28 22:07:08 2022 ...   Identified 2 clusters