Dear all,
im trying to find the optimum number of clusters to fit to a gene expression dataset.
For this, Im using the packages FactoMineR
and factoextra
and the function fviz_nbclust
on my scaled dataframe (simple dataframe with genes in rows and samples in columns).
It scales (z-scoring) by column so im transposing first and then scaling. Then i retranspose and calculate the optimal number of clusters.
The problem is that i get a Warning message " did not converge in 10 iterations ".
The question is, do you know a way to modify the number of iteractions?
This is the code im using
df <- scale (t(mydata))
df <- t(df)
fviz_nbclust(df, kmeans, method = "gap_stat")
fit <- kmeans(df, ?)
mydata2 <- data.frame(df, fit$cluster)
?: this value is dictated by the clusters prediction
Thanks in advance
Dear Kevin, thanks a lot for your help. Do you have any idea about what this means?
The error occurs when you attempt to perform operations on objects of unequal dimensions. For example:
What are is the dimension size of your input data? You're using k.max=10 and B=100?
Im using the default parameters:
Hi, Kevin!
I've got exactly the same question (but for clusGap function). I tried your solution with custom kmeans and it produces the same warnings. I have a large matrix as input 20k*300 and even 15 clusters is a lot; so without more than 10 iterations it is unlikely to converge. Could you please help to solve the problem? The code is below. Thanks a lot!
MyKmeans <- function(x,k) list(cluster=kmeans(x, k, iter.max=300,nstart = 25))
gap_stat <- clusGap(w2v300_emb, FUN = MyKmeans, K.max = 15, B = 50)