cluster samples using self organizing map in R

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

cluster samples using self organizing map in R

A DNA RNA
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

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: cluster samples using self organizing map in R

Bert Gunter-2
Search!

the rseek.org site gives many hits for "self organizing maps", including
the som package among others.

-- Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Oct 9, 2018 at 11:14 PM A DNA RNA <[hidden email]> 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
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: cluster samples using self organizing map in R

Sarah Goslee
In reply to this post by A DNA RNA
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 <[hidden email]> 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

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.