-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCHStatisticsShinyApp.R
154 lines (117 loc) · 4.87 KB
/
CHStatisticsShinyApp.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
source('Main.R')
source('AppLib.R')
source('ClusterHeadInformation.R')
library(memoise)
db <- cache_filesystem("~/.rcache")
LoadCHStatisticsData <- function(fullNames, partialNames) {
testSuites <- mclapply(fullNames, loadResultsFromTestSuitePath, mc.cores = 8)
stats <- mapply(function(testSuite, partialName) {
asd <- lapply(testSuite, function(result) {
if(is.na(result)) {
return(NA)
}
# data.frame(name=result@testName, meanOffSlot=meanOffSlot(result), sdOffSlot=sdOffSlot(result), test_suite=partialName, spread=calculateSpread(result))
testName <- sub(".+?-motes-(.+?x.+?)-(random|spread)", "\\1", result@testName)
frame <-calculateClusterHeadStatistics(result)
frame$test_suite = partialName
frame$name = testName
return(frame)
})
do.call("rbind", asd)
}, testSuites, partialNames, SIMPLIFY = F)
# browser()
stats <- do.call("rbind", stats)
stats$name <- factor(stats$name, levels = unique(stats$name[order(stats$spread)]))
return(stats)
}
loadNormal <- Curry(LoadCHStatisticsData, mapplyFunc = mapply, lapplyFunc = lapply)
loadParallel <- Curry(LoadCHStatisticsData, mapplyFunc = Curry(mcmapply, mc.cores = 4), lapplyFun = Curry(mclapply, mc.cores = 4))
#LoadCHStatisticsData <- loadNormal
#LoadCHStatisticsData <- loadParallel
#LoadCHStatisticsData <- memoise(loadParallel, cache=db)
#LoadCHStatisticsData <- memoise(loadNormal, cache=db)
LoadCHStatisticsData <- memoise(LoadCHStatisticsData, cache=db)
createPlot <- function(agg, point, xLab = "Test Name", yLab = "Y Axis") {
return(
ggplot(agg) +
point +
theme(
axis.text.x=element_text(angle=45, hjust=1),
plot.margin=unit(c(1,1,1,2),"cm"),
text = element_text(size=20)
) +
xlab(xLab) +
ylab(yLab) +
scale_y_continuous(breaks = seq(0, 100, 2))
)
}
AverageCHCountPlot <- function(input) {
renderPlot({
partialNames <- input$checkedTests
fullNames <- lookupFullNames(partialNames)
if (length(fullNames) == 0) {
return(plot(1,1))
}
print(input$checkedTests)
stats <- LoadCHStatisticsData(fullNames, partialNames)
agg <- aggregate(promotedCHCount~name+test_suite+spread, stats, function(a) c(mean=mean(a)))
agg <- do.call(data.frame, agg)
return(createPlot(agg, geom_point(aes(name, promotedCHCount, color=test_suite), size=6, position=position_dodge(width=0.3)), yLab = "Average CH Count Before Demote"))
})
}
CHCountAfterDemotionPlot <- function(input) {
renderPlot({
partialNames <- input$checkedTests
fullNames <- lookupFullNames(partialNames)
if (length(fullNames) == 0) {
return(plot(1,1))
}
print(input$checkedTests)
stats <- LoadCHStatisticsData(fullNames, partialNames)
agg <- aggregate(CHCountAfterDemotion~name+test_suite+spread, stats, function(a) c(mean=mean(a)))
agg <- do.call(data.frame, agg)
return(createPlot(agg, geom_point(aes(name, CHCountAfterDemotion, color=test_suite), size=6, position=position_dodge(width=0.3)), yLab = "Average CH Count After Demotion"))
})
}
DemotedCHPlot <- function(input) {
renderPlot({
partialNames <- input$checkedTests
fullNames <- lookupFullNames(partialNames)
if (length(fullNames) == 0) {
return(plot(1,1))
}
print(input$checkedTests)
stats <- LoadCHStatisticsData(fullNames, partialNames)
agg <- aggregate(demotedCHCount~name+test_suite+spread, stats, function(a) c(sum=sum(a)))
agg <- do.call(data.frame, agg)
return(createPlot(agg, geom_point(aes(name, demotedCHCount, color=test_suite), size=6, position=position_dodge(width=0.3)), yLab = "Demoted CH Count"))
})
}
TotalCHPlot <- function(input) {
renderPlot({
partialNames <- input$checkedTests
fullNames <- lookupFullNames(partialNames)
if (length(fullNames) == 0) {
return(plot(1,1))
}
print(input$checkedTests)
stats <- LoadCHStatisticsData(fullNames, partialNames)
agg <- aggregate(promotedCHCount~name+test_suite+spread, stats, function(a) c(sum=sum(a)))
agg <- do.call(data.frame, agg)
return(createPlot(agg, geom_point(aes(name, promotedCHCount, color=test_suite), size=6, position=position_dodge(width=0.3)), yLab = "Total CH Count"))
})
}
AverageAssociatingNodes <- function(input) {
renderPlot({
partialNames <- input$checkedTests
fullNames <- lookupFullNames(partialNames)
if (length(fullNames) == 0) {
return(plot(1,1))
}
print(input$checkedTests)
stats <- LoadCHStatisticsData(fullNames, partialNames)
agg <- aggregate(associatingCHCount~name+test_suite+spread, stats, function(a) c(mean=mean(a)))
agg <- do.call(data.frame, agg)
return(createPlot(agg, geom_point(aes(name, associatingCHCount, color=test_suite), size=6, position=position_dodge(width=0.3)), yLab = "Average Associating CH Count"))
})
}