-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpeak-rankings.R
127 lines (105 loc) · 3.01 KB
/
peak-rankings.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
imagesDirectory <- "images/important-variables/"
dir.create(imagesDirectory,
recursive = TRUE,
showWarnings = FALSE)
# ---------------------------------------------------------------------------
#
# 1 Fold-changes
#
# ---------------------------------------------------------------------------
source("load-cancer.R")
source("peak-rankings-functions.R")
avgPeaks <-
meanConditionSpectra(
consensusData$datasetConditions,
consensusBinnedPeaksMatrix,
consensusData$spectraConditions
)
# log2(avgPeaks["HEALTHY", "2984.26172166667"] / avgPeaks["LYMPHOMA", "2984.26172166667"])
# log2(avgPeaks["HEALTHY", "2984.26172166667"] / avgPeaks["MYELOMA", "2984.26172166667"])
comparison <- compareConditions(avgPeaks)
comparison.log2 <- log2(comparison)
comparison.index <- 1
data <- sort(comparison.log2[, comparison.index])
data.plot <- data[!is.infinite(data) & abs(data) > 1.5]
png(
paste0(imagesDirectory, "peak-ranking-fold-changes.png"),
width = 1200,
height = 800
)
barplot(
data.plot,
horiz = TRUE,
names = substr(names(data.plot), 1, 8),
las = 1,
space = 1.5,
cex.names = 0.8,
xlim = c(min(data.plot) - 1, max(data.plot) + 1),
main = colnames(comparison)[comparison.index]
)
dev.off()
# ---------------------------------------------------------------------------
#
# 2 t-scores
#
# ---------------------------------------------------------------------------
source("load-cancer.R")
source("distance-measures.R")
# ---------------------------------------------------------------------------
#
# 2.1 Ranking features using the sda.ranking function from the SDA package
#
# Homepage: http://strimmerlab.org/software/sda/
# CRAN: http://cran.r-project.org/package=sda
#
# ---------------------------------------------------------------------------
library("sda")
ddar <-
sda.ranking(
Xtrain = consensusBinnedPeaksMatrix,
L = consensusData$spectraConditions,
fdr = FALSE,
diagonal = TRUE
)
png(
paste0(imagesDirectory, "peak-ranking-t-scores.png"),
width = 1200,
height = 800
)
plot(
ddar,
top = 20,
arrow.col = "blue",
zeroaxis.col = "red",
ylab = "Peaks"
)
dev.off()
# ---------------------------------------------------------------------------
#
# 2.2 Using the "X" top peaks to perform a Hierarchical Clustering Analysis
# (using Jaccard distance)
#
# ---------------------------------------------------------------------------
consensusBinnedPeaksMatrix.topPeaks <-
consensusBinnedPeaksMatrix[, sort(ddar[1:20, "idx"])]
distances.jaccard.consensus <-
jaccard.dist(
rownames(consensusBinnedPeaksMatrix.topPeaks),
toSpectraList(consensusBinnedPeaksMatrix.topPeaks)
)
clustering.jaccard.consensus <- hclust(distances.jaccard.consensus)
png(
paste0(
imagesDirectory,
"peak-ranking-t-scores-hierarchical-clustering.png"
),
width = 1200,
height = 800
)
plot(clustering.jaccard.consensus, main = "Samples HCA (complete linkage)")
rect.hclust(
clustering.jaccard.consensus,
k = 3,
border = c("blue", "red", "green")
)
dev.off()