cluster samples using self organizing map in R
Hi Tina, What's wrong with what you did? The output object of som() contains the classification of each sample. You probably do need to read more about self-organizing maps, since you specified you wanted the samples classified into nine groups, and that's unlikely to be your actual intent. I have no idea what you thought your hierarchical clustering step was supposed to do, either. Here's one way to get 3 groups instead of 9: library(kohonen) iris.sc <- scale(iris[, 1:4]) iris.som <- som(iris.sc, grid=somgrid(xdim = 1, ydim=3, topo="rectangular"), rlen=100, alpha=c(0.05,0.01)) table(iris.som$unit.classif, iris$Species) plot(iris.som) Sarah
On Wed, Oct 10, 2018 at 2:14 AM A DNA RNA <email2mrna at gmail.com> wrote:
Dear All,
Who can I use Self Organizing Map (SOM) results to cluster samples? I have
tried following but this gives me only the clustering of grids, while I
want to cluster (150) samples:
library(kohonen)
iris.sc <- scale(iris[, 1:4])
iris.som <- som(iris.sc, grid=somgrid(xdim = 3, ydim=3, topo="hexagonal"),
rlen=100, alpha=c(0.05,0.01))
##hierarchical clustering
groups <- 3
iris.hc <- cutree(hclust(dist(iris.som$codes[[1]])), groups)
iris.hc
#V1 V2 V3 V4 V5 V6 V7 V8 V9
#1 1 2 1 1 2 3 3 2
Can anyone help me with this please?
--
Tina
Sarah Goslee http://www.functionaldiversity.org