Perform K-means clustering into k clusters

doKmeans(X, k, nstart)

Arguments

X

matrix of values

k

value for kmeans

nstart

Where to start

Value

list of clusters and labels

Examples

example_dta<-create_example_data_for_R()
X=as.matrix(example_dta$counts)
#Default ... values:
default.par <- list(q=0.25,Kmax.rec=5,B=100,ref.gen="PC",dist.method="euclidean",cl.method="hclust",linkage="average",cor.method="pearson",nstart=10)
#Check for user modifications:
fixed.par <- c(minDist=NULL,minSize=2,modifyList(default.par,list(cor.method='pearson',linkage='average')))
#Find stopping threshold if minDist is NULL
minDist <- get.threshold(X,q=fixed.par$q,fixed.par)
fixed.par$minDist <- minDist
dX <- getDist(X,dist.method='euclidean',cor.method='pearson')
cl.lab <- vector("list",10)
for(k in 1:10){
  labX <- switch('hclust',
                 hclust=doHclust(dX,k=k,linkage='average')$lab,
                 kmeans=doKmeans(X,k,nstart=10)$lab)    #note:kmeans only calculated for euclidean distance!
  cl.lab[[k]] <- labX
}