sib-swiss / dsSwissKnifeClient

3 stars 1 forks source link

Kmeans: assign cluster to each variate #4

Open ciropom opened 2 years ago

ciropom commented 2 years ago

Hello, I've read

https://github.com/sib-swiss/dsSwissKnife-example/blob/main/dsSwissKnife_example.R

And I successfully performed PCA and KNN. Now I want to plot the first two PCA components using ggplot, coloring each variates with a colour indicating the cluster he belongs to.

When I compute a kmeans using plain R, I can use '$cluster' to map a sample to a cluster, but with dss version the cluster attribute is different

# plain R kmeans
> fit.km$cluster
  [1] 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2
 [61] 2 2 2 2 2 2 2 2 2 2 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
[121] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

# dssKmeans
> knn$global$cluster
    1     2 
13072  8335 

How can I assign cluster label to my samples?

I tried also to layer the kmeans cluster classification onto the PCA biplots, as shown in the example but I've found the result confusing and difficult to interpret.

Thank you Danilo

ciropom commented 2 years ago

Hello, just bumping up this discussion. Is there any way to get per-sample cluster labels from dssKmeans?

Thank you

IulianD commented 2 years ago

Hello, sorry, I somehow missed this with the holidays an others. I'll look into it and get back to you.

ciropom commented 2 years ago

thank you!