-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsom.R
53 lines (44 loc) · 1.38 KB
/
som.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
library(kohonen)
imagesDirectory <- "images/som/"
dir.create(imagesDirectory,
recursive = TRUE,
showWarnings = FALSE)
source("load-cancer.R")
# ---------------------------------------------------------------------------
#
# 1. Self-Organized Maps
#
# ---------------------------------------------------------------------------
#
# 1.1 SOM without conditions using the replicas matrix (binnedPeaksMatrix)
#
# ---------------------------------------------------------------------------
set.seed(2019)
somresult <- som(
scale(binnedPeaksMatrix),
grid = somgrid(xdim = 13, ydim = 3, topo = "hexagonal"),
alpha = c(0.5, 0.01),
rlen = 4000
)
plot(somresult, type = "changes")
plot(somresult, type = "counts")
plot(somresult, type = "quality")
plot(somresult, type = "dist.neighbours")
classification <- somresult$unit.classif
names(classification) <- data$spectraNames
classification
# ---------------------------------------------------------------------------
#
# 1.2 SOM with conditions using the replicas matrix (binnedPeaksMatrix)
#
# ---------------------------------------------------------------------------
set.seed(2019)
somresult <- xyf(
scale(binnedPeaksMatrix),
factor(data$spectraConditions),
grid = somgrid(xdim = 13, ydim = 3, topo = "hexagonal"),
alpha = c(0.5, 0.01),
rlen = 4000
)
plot(somresult, type = "codes")
plot(somresult, type = "dist.neighbours")