Repository navigation
Expand file tree
/
Copy pathserver.R
More file actions
668 lines (479 loc) · 25.6 KB
/
Copy pathserver.R
File metadata and controls
668 lines (479 loc) · 25.6 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
##########################################################################################################
# THREADNET: SHINY SERVER
# This software may be used according to the terms provided in the
# GNU General Public License (GPL-3.0) https://opensource.org/licenses/GPL-3.0?
# Absolutely no warranty!
##########################################################################################################
# The Shiny server mainly calls functions in other files.
server <- shinyServer(function(input, output, session) {
options(warn=-1)
options(shiny.maxRequestSize=30*1024^2)
##### make the global variables reactive #########
# # One for the event mappings
observe( makeReactiveBinding("GlobalEventMappings", env=.GlobalEnv) )
#
# # One for the event clusters
observe( makeReactiveBinding("GlobalEventClusters", env=.GlobalEnv) )
### Some basic functions that are used to structure the data as it moves through the pipeline
# make dataframe of occurrences that depends only file1
occ <- eventReactive(input$file1,read_occurrences(input$file1))
#selected columns from the raw data, and the subset of the table
selectOcc = reactive(occ()[c("tStamp", input$CFcolumnsID)] )
selectOccFilter = reactive(selectOcc()[input$Data_Tab_Output_2_rows_all,])
# # recode the occurrences for the thresholds...
# filterOcc = reactive({recodeThreshold(selectOcc(),get_CF(), cfthresh())})
#
# Sort and add columns for threadNum and seqNum for the selected POV
threadedOcc = reactive({
ThreadOccByPOV(selectOccFilter(),get_THREAD_CF(),get_EVENT_CF()) })
###### From here on down, we are working with events, not occurrences #######
threadedEventCluster <- reactive({
input$EventButton1
isolate(OccToEvents1(threadedOcc(),
input$EventMapName1,
get_EVENT_CF(),
get_COMPARISON_CF()
) )})
# These go on the occ to event page.They suppress some columns
threadedEvents <- reactive({make_nice_event_DT(threadedEventCluster()[["threads"]])})
# threadedCluster <- reactive({threadedEventCluster()[["cluster"]]})
# this is for the chunks
threadedEventCluster2 <- reactive({
input$EventButton2
isolate(OccToEvents2(threadedOcc(),
input$EventMapName2,
get_EVENT_CF(),
get_COMPARISON_CF()
) )})
# These go on the occ to event page
threadedEvents2 <- reactive({make_nice_event_DT(threadedEventCluster2()[["threads"]])})
# threadedCluster2 <- reactive({threadedEventCluster2()[["cluster"]]})
##################################################
# capture reactive values from the UI that are needed elsewhere
# note the "<<-" assignment, which gives the function global scope
# get_CF returns the choice of contextual factors from the Data tab.
get_CF <<- reactive({ return( input$CFcolumnsID ) })
# get threshold values from the context sliders and buttons on POV tab
# cfthresh <<- reactive(getCFSliderValues( input, length( get_CF() )))
# cfbuttons <<- reactive(getCFButtonValues( input, length( get_CF() )))
# get_POV returns the choice of POV from the POV tab
get_THREAD_CF <<- reactive({ return(input$THREAD_CF_ID) })
get_EVENT_CF <<- reactive({ return(input$EVENT_CF_ID) })
get_COMPARISON_CF <<- reactive({ return(setdiff(get_CF(), union(get_THREAD_CF(),get_EVENT_CF() ))) })
# get an environment here for storing/retriving the information about the events...
get_ENV <<- reactive({ return(input$EventMapName) })
# time scale for use throughout the app
get_timeScale <<- reactive({ return(input$timeScaleID) })
# These sliders controls the zoom level for zooming in-out
get_Zoom_VIZ <<- reactive({ return( ifelse (zoom_upper_limit(get_event_mapping_threads( GlobalEventMappings , input$VisualizeEventMapInputID))==1 ,
"ZM_1", paste0("ZM_",input$VisualizeTabZoomID))) })
get_Zoom_COMP_A <<- reactive({ return( ifelse (zoom_upper_limit(get_event_mapping_threads( GlobalEventMappings , input$CompareMapInputID_A))==1 ,
"ZM_1", paste0("ZM_",input$CompareZoomID_A))) })
get_Zoom_COMP_B <<- reactive({ return( ifelse (zoom_upper_limit(get_event_mapping_threads( GlobalEventMappings , input$CompareMapInputID_B))==1 ,
"ZM_1", paste0("ZM_",input$CompareZoomID_B))) })
get_Zoom_DIA_COMP <<- reactive({ return( ifelse (zoom_upper_limit(get_event_mapping_threads( GlobalEventMappings , input$DiaCompareMapInputID))==1 ,
"ZM_1", paste0("ZM_",input$DiaCompareZoomID))) })
get_Zoom_MOVE <<- reactive({ return( ifelse (zoom_upper_limit(get_event_mapping_threads( GlobalEventMappings , input$MovingWindowMapInputID))==1 ,
"ZM_1", paste0("ZM_",input$MovingWindowZoomID))) })
################## 1.READ DATA TAB ####################
output$Data_Tab_Controls_1 = renderUI({
tags$div(align="center",
fileInput("file1",
"Please select a .csv file",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"))
)
})
output$Data_Tab_Controls_2 = renderUI({
checkboxGroupInput("CFcolumnsID","Select columns to include in analysis:",
cfnames(occ()),
selected=cfnames(occ()),
inline=TRUE)
})
output$Data_Tab_Output_2 = DT::renderDataTable({
selectOcc()
}, filter = "top")
##################### 2.POV tab ################################
# this paints the nice pie charts including the COMBINED column
output$ContextFlowers_2 = renderPlotly({
CF_multi_pie(selectOccFilter(), get_THREAD_CF() )
})
output$ContextFlowers_3 = renderPlotly({
CF_multi_pie(selectOccFilter(), get_EVENT_CF() )
})
output$rawOccurrenceThreadMap <- renderPlotly({
threadMap(threadedOcc(), "POVthreadNum", "POVseqNum", newColName(get_EVENT_CF()), 15 )
})
output$rawOccurrenceThreadMap_2 <- renderPlotly({
threadMap(threadedOcc(), "POVthreadNum", "tStamp", newColName(get_EVENT_CF()), 16 )
})
output$Preview_Thread_Output_1 <- renderText({ paste(numThreads(threadedOcc(), "POVthreadNum"),"threads in the selected data.")})
output$Preview_Network_Tab_Controls_0 <- renderUI({
radioButtons("Timesplit", "Time Measure:", choices = c('POVseqNum','timeGap'), selected="POVseqNum", inline=TRUE)
})
output$rawOccurrenceNetwork <- renderPlotly({
req(input$Timesplit)
eventNetwork(threadedOcc(), "POVthreadNum", newColName(get_EVENT_CF()), input$Timesplit)
})
output$Thread_Tab_Output_1 = DT::renderDataTable({ threadedOcc() })
# need to create unique ID for each radiobutton based on the CF name
output$POV_Tab_Controls_1 <- renderUI({
checkboxGroupInput("COMPARISON_CF_ID","Select columns for comparison:",
cfnames(selectOccFilter()),
selected = get_COMPARISON_CF(),
inline=TRUE)
})
output$POV_Tab_Controls_2 <- renderUI({
checkboxGroupInput("THREAD_CF_ID","Select columns to define threads:",
cfnames(selectOccFilter()),
selected = get_THREAD_CF(),
inline=TRUE)
})
output$POV_Tab_Controls_3 <- renderUI({
checkboxGroupInput("EVENT_CF_ID","Select columns to mark events:",
cfnames(selectOccFilter()),
selected = get_EVENT_CF(),
inline=TRUE)
})
##################### 3.OCC to EVENT tab ################################
output$One_to_One_controls = renderUI({
tags$div(align="left",
tags$h4("One-to-One: Each occurrence in the raw data is interpreted as an event (INPUT = Occurrences)."),
tags$p(" "),
textInput("EventMapName1", label = h4("Enter label for this mapping:"), value = "One-to-One"),
actionButton("EventButton1", "Create New Mapping") )
})
output$Contextual_Chunk_controls = renderUI({
tags$div(align="left",
tags$h4("Context-based chunks: Occurrences are grouped into events based on changes in contextual factors (INPUT = Occurrences)."),
tags$p(paste0("Start new event when ALL of these change:", paste(get_EVENT_CF(),","))),
textInput("EventMapName2", label = h4("Enter label for this mapping"), value = "Chunks_"),
actionButton("EventButton2", "Create New Mapping") )
})
output$Regular_Expression_controls = renderUI({
tags$div(align="left",
tags$h4("Regular Expressions: Use regular expressions to form events -- Not implemented yet"),
tags$p(" "),
selectizeInput("RegExInputID",label = h4("Choose input for this mapping:"), get_event_mapping_names( GlobalEventMappings ) ),
tags$p(" "),
textInput("RegExForEvents", label = h4("Enter regular expression(s)"), value = ""),
tags$p(" "),
textInput("EventMapName3", label = h4("Enter label for this mapping"), value = "RegEx_"),
actionButton("EventButton3", "Create New Mapping") )
})
output$Frequent_Ngram_controls = renderUI({
tags$div(align="left",
tags$h4("Frequent ngrams: Select ngrams to use in forming events -- Not implemented yet"),
tags$p(" "),
selectizeInput("NGramInputID","INPUT:", get_event_mapping_names( GlobalEventMappings ) ),
textInput("EventMapName4", label = h4("Enter label for this mapping"), value = "Ngrams_"),
actionButton("EventButton4", "Create New Mapping") )
})
output$Maximal_Pattern_controls = renderUI({
tags$div(align="left",
tags$h4("Maximal patterns: Form events based on maximal patterns-- Not implemented yet"),
selectizeInput("MaximalPatternInputID",label = h4("Choose input for this mapping:"), get_event_mapping_names( GlobalEventMappings ) ),
textInput("EventMapName5", label = h4("Enter label for this mapping"), value = "Maximal_"),
actionButton("EventButton5", "Create New Mapping") )
})
output$Cluster_Event_controls_1 = renderUI({
tags$div(align="left",
tags$h4("Cluster Events: Group similar events to together to allow zooming"),
selectizeInput("ClusterEventsInputID",label = h4("Choose mapping for clustering:"), get_event_mapping_names( GlobalEventMappings ) ))
})
output$Cluster_Event_controls_2 = renderUI({
tags$div(align="left",
textInput("EventMapName6", label = h4("Enter new label for this mapping + clustering"), value =""),
radioButtons("ClusterMethodID", "Cluster based on:",
choices = c("Sequential similarity", "Contextual Similarity", "Network Structure"),
selected="Sequential similarity", inline=TRUE),
actionButton("EventButton6", "Cluster Events") )
})
output$dendroClusterResult <- renderDendroNetwork({
input$EventButton6
isolate( dendroNetwork(clusterEvents( get_event_mapping_threads( GlobalEventMappings,
input$ClusterEventsInputID),
input$ClusterEventsInputID,
input$EventMapName6,
input$ClusterMethodID,
get_EVENT_CF()),
treeOrientation = "vertical", textColour = "black"))
})
output$Manage_Event_Map_controls= renderUI({
tags$div(align="left",
tags$h4("Select event mapping to export or delete"),
selectizeInput("ManageEventMapInputID",label = h4("Choose mapping:"), get_event_mapping_names( GlobalEventMappings ) ),
actionButton("ExportMappingButton", "Export"),
actionButton("DeleteMappingButton", "Delete") )
})
# reactive functions for the export and delete buttons
observeEvent(
input$DeleteMappingButton,
{delete_event_mapping( GlobalEventMappings, input$ManageEventMapInputID )
output$delete_confirm = renderText(paste(input$ManageEventMapInputID, " deleted."))
})
observeEvent(
input$ExportMappingButton,
{export_event_mapping( GlobalEventMappings, input$ManageEventMapInputID )
output$delete_confirm = renderText(paste(input$ManageEventMapInputID, " exported."))
})
output$One_to_one_Tab_Output_1 = DT::renderDataTable({
threadedEvents()
}, filter = "top")
output$Contextual_Chunks_Tab_Output_1 = DT::renderDataTable({
threadedEvents2()
}, filter = "top")
# output$Event_Tab_Output_4 = renderDendroNetwork({
# #plot(threadedCluster())
# dendroNetwork(threadedCluster(), treeOrientation = "vertical", textColour = "black")
# })
output$dendro_test = renderPlot({
plot(threadedCluster())
})
#
# # show the bar chart
# output$threadGapBarchart <- renderPlotly({
# threadGapBarchart(threadedOcc(),input$Event_method_ID)
# })
# output$Event_Tab_Output_3 = renderPlot({ if (is.null(threadedCluster())) {plot(table(threadedEvents()["ZM_1"]))} else {plot(threadedCluster()) }})
#
# output$Event_Tab_Output_3 = renderPlotly({ ng_bar_chart(threadedEvents(), "threadNum", "ZM_1", 1, 1)} )
##################### 4.VISUALIZE tab ################################
# Controls for the whole set of tabs
output$Visualize_Tab_Controls_1 = renderUI({
selectizeInput("VisualizeEventMapInputID",label = h4("Choose mapping:"), get_event_mapping_names( GlobalEventMappings ), selected='One-to-One' )
})
output$Visualize_Tab_Controls_2 = renderUI({
zoom_limit = zoom_upper_limit(get_event_mapping_threads( GlobalEventMappings , input$VisualizeEventMapInputID))
if ( zoom_limit == 1)
{tags$h4("Zooming not available for this mapping")}
else
{sliderInput("VisualizeTabZoomID",
"Zoom in and out by event similarity:",
1, zoom_limit, 1, step = 1, ticks=FALSE) }
})
# controls for sub-sequence display
output$nGramControls <- renderUI({
tagList(
sliderInput("nGramLengthID","nGram Size", 1,10,2,step=1,ticks=FALSE ),
sliderInput("nGramDisplayThresholdID","Display threshold", 1,50,1,step=1,ticks=FALSE )
)
})
# Get data for the Visualize tab. Need parallel functions for the other tabs.
threadedEventsViz <- reactive({ print(paste0('reactive inputID', input$VisualizeEventMapInputID))
get_event_mapping_threads( GlobalEventMappings, input$VisualizeEventMapInputID ) })
# NGRAM display #
output$nGramBarchart = renderPlotly({
ng_bar_chart(threadedEventsViz(), "threadNum", get_Zoom_VIZ(), input$nGramLengthID, input$nGramDisplayThresholdID)
})
# Whole sequence display
output$WholeSequenceThreadMap <- renderPlotly({
threadMap(threadedEventsViz(), "threadNum", "seqNum", get_Zoom_VIZ(), 15 )
})
# Force network D3 display
# use this to select how to color the nodes in force layout
output$Network_Tab_Controls_2 <- renderUI({
button_choices = intersect(colnames(threadedEventsViz()), cfnames(selectOccFilter()))
tags$div(
radioButtons("NetworkGroupID","Select a dimension for coloring nodes:",
choices = button_choices,
selected = button_choices[1], # always start with the first one
inline=TRUE))
})
# output$circularLayoutNetwork = renderPlotly(
#
# )
output$forceNetworkD3 <- renderForceNetwork({
forceNetworkD3(threadedEventsViz(), "threadNum", input$NetworkGroupID, get_Zoom_VIZ())
})
output$VisualizeCustomNetwork <- renderPlotly({
eventNetwork(threadedEventsViz(), "threadNum", input$NetworkGroupID, get_Zoom_VIZ())
})
##################### 5. COMPARE tab ################################
# Make two parallel sets of input and data. Different mapping on each side
# ####### SUBSET A ##########
output$Comparison_Tab_Controls_A1 <- renderUI({
selectizeInput("CompareMapInputID_A",label = h4("Choose mapping:"), get_event_mapping_names( GlobalEventMappings ) )
})
output$Comparison_Tab_Controls_A2 <- renderUI({
zoom_limit = zoom_upper_limit(get_event_mapping_threads( GlobalEventMappings , input$CompareMapInputID_A))
if (zoom_limit == 1)
{tags$h4("Zooming not available with this mapping")}
else
{sliderInput("CompareZoomID_A",
label=h4("Zoom in and out by event similarity:"),
1,zoom_limit,1, step = 1, ticks=FALSE) }
})
# Get data for the COMPARE tab mapping A
threadedEventsComp_A <- reactive({
get_event_mapping_threads( GlobalEventMappings, input$CompareMapInputID_A ) })
# just one type of plot for now -- need to select different plot types
output$Comparison_Plots_A <- renderPlotly({
threadMap(threadedEventsComp_A(), "threadNum", "seqNum", get_Zoom_COMP_A(), 15 )
})
# ####### SUBSET B ##########
output$Comparison_Tab_Controls_B1 <- renderUI({
selectizeInput("CompareMapInputID_B",label = h4("Choose mapping:"), get_event_mapping_names( GlobalEventMappings ) )
})
output$Comparison_Tab_Controls_B2 <- renderUI({
zoom_limit = zoom_upper_limit(get_event_mapping_threads( GlobalEventMappings , input$CompareMapInputID_B))
if (zoom_limit == 1)
{tags$h4("Zooming not available with this mapping")}
else
{sliderInput("CompareZoomID_B",
label=h4("Zoom in and out by event similarity:"),
1,zoom_limit,1, step = 1, ticks=FALSE) }
})
# Get data for the COMPARE tab mapping B.
threadedEventsComp_B <- reactive({
get_event_mapping_threads( GlobalEventMappings, input$CompareMapInputID_B ) })
# just one type of plot for now -- need to select different plot types
output$Comparison_Plots_B <- renderPlotly({
threadMap(threadedEventsComp_B(), "threadNum", "seqNum", get_Zoom_COMP_B(), 15 )
})
# ########## DIACHRONIC Comparison sub-tab ###########
output$Diachronic_Comparison_Tab_Controls_1 <- renderUI({
selectizeInput("DiaCompareMapInputID",label = h4("Choose mapping:"), get_event_mapping_names( GlobalEventMappings ) )
})
output$Diachronic_Comparison_Tab_Controls_2 <- renderUI({
zoom_limit = zoom_upper_limit(get_event_mapping_threads( GlobalEventMappings , input$DiaCompareMapInputID))
if (zoom_limit == 1)
{tags$h4("Zooming not available with this mapping")}
else
{sliderInput("DiaCompareZoomID",
label=h4("Zoom in and out by event similarity:"),
1,zoom_limit,1, step = 1, ticks=FALSE) }
})
output$Diachronic_Comparison_Tab_Controls_3 <- renderUI({
radioButtons("DiaCompareTimeSubsetID", "How many time intervals to compare:", choices = c(1, 2, 3, 4, 5, 6), selected="1", inline=TRUE)
})
# Get data for the Diachronic COMPARE tab .
threadedEventsDiaComp <- reactive({
get_event_mapping_threads( GlobalEventMappings, input$DiaCompareMapInputID ) })
# controls for the comparison input panels
# Use all of the column names here...
output$Diachronic_Comparison_Tab_Controls_4 <- renderUI({
selectizeInput("selectComparisonID","Compare by:", colnames(threadedEventsDiaComp()))
})
CF_levels = reactive( get_CF_levels( threadedEventsDiaComp(),input$selectComparisonID) )
output$Diachronic_Comparison_Tab_Controls_5 <- renderUI({
tagList(
selectizeInput("selectComparisonGroupsID","Compare specific groups:",
CF_levels(), multiple=TRUE),
sliderInput("nGramLengthCompID","nGram Size", 1,10,2,step=1,ticks=FALSE )
)
})
# Get subsets of events and create sub-plots for them
output$DiachronicComparisonPlots <- renderPlotly(
Comparison_Plots(threadedEventsDiaComp(),
input$selectComparisonID,
input$selectComparisonGroupsID,
input$DiaCompareTimeSubsetID,
input$nGramLengthCompID,
get_Zoom_DIA_COMP()) )
######################## 6. MOVING WINDOW TAB ##############################
output$Moving_Window_Tab_Controls_1 <- renderUI({
selectizeInput("MovingWindowMapInputID",label = h4("Choose mapping:"), get_event_mapping_names( GlobalEventMappings ) )
})
output$Moving_Window_Tab_Controls_2 <- renderUI({
zoom_limit = zoom_upper_limit(get_event_mapping_threads( GlobalEventMappings , input$MovingWindowMapInputID))
if (zoom_limit == 1)
{tags$h4("Zooming not available with this mapping")}
else
{sliderInput("MovingWindowZoomID",
label = h4("Zoom in and out by event similarity:"),
1,zoom_limit,1, step = 1, ticks=FALSE) }
})
output$Moving_Window_Tab_Controls_3 <- renderUI({
sliderInput("MovingWindowSizeID","Window Size", 1, numThreads(threadedEvents(),"threadNum" ),1,step=1,ticks=FALSE )
})
output$Moving_Window_Tab_Controls_4_A <- renderUI({
sliderInput("WindowLocation_A_ID","Window Location", 1,numThreads(threadedEvents(),"threadNum" ),1,step=1,ticks=FALSE )
})
output$Moving_Window_Tab_Controls_4_B <- renderUI({
sliderInput("WindowLocation_B_ID","Window Location", 1,numThreads(threadedEvents(),"threadNum" ),1,step=1,ticks=FALSE )
})
# "Timesplit" appears to be used for the custom network plotly layout
# output$Moving_Tab_Controls_5 <- renderUI({
# tags$div(align="center",
# radioButtons("Timesplit3", "Time Measure:", choices = c('seqNum','timeGap'), selected="seqNum", inline=TRUE))
# })
# Get data for the Moving Window tab.
threadedEventsMove <- reactive({
get_event_mapping_threads( GlobalEventMappings, input$MovingWindowMapInputID ) })
output$MovingWindow_Plot_A <- renderPlotly({
w = get_moving_window(threadedEventsMove(), input$MovingWindowSizeID, input$WindowLocation_A_ID )
threadMap(w, "threadNum", "seqNum", get_Zoom_MOVE(), 15 )
})
output$MovingWindow_Plot_B <- renderPlotly({
w = get_moving_window(threadedEventsMove(), input$MovingWindowSizeID, input$WindowLocation_B_ID )
threadMap(w, "threadNum", "seqNum", get_Zoom_MOVE(), 15 )
})
#
# output$MovingWindow_Plot_A <- renderPlotly({
# w = get_moving_window(threadedEvents(),-input$MovingWindowSizeID, input$WindowLocationID )
# eventNetwork(w, "threadNum", get_Zoom_MOV(), input$Timesplit3) })
#
#
# output$MovingWindow_Plot_B <- renderPlotly({
# w = get_moving_window(threadedEvents(),input$MovingWindowSizeID, input$WindowLocationID )
# eventNetwork(w, "threadNum", get_Zoom_MOV(), input$Timesplit3) })
#
######
output$Pos_Layout_Controls_0 <- renderUI({
radioButtons("Timesplit2", "Time Measure:", choices = c('seqNum'='seqNum.1','timeGap'='timeGap'), selected="seqNum.1", inline=TRUE)
})
event.data <- reactive({
event_data("plotly_click", source="A")
# click_data = event_data("plotly_click", source="A")
# click_data$pointNumber = click_data$pointNumber+1
# click_data$click_name = paste(input$EVENT_CF_ID, click_data$pointNumber, sep="")
# click_data
})
output$hover <- renderPrint({
d <- event_data("plotly_hover")
if (is.null(d)) "Hover events appear here (unhover to clear)" else d
})
#EVENT_CF_levels = reactive( get_CF_levels( threadedEvents(), get_EVENT_CF()) )
eventNetworksubset <- reactive({
req(event.data())
TE = threadedEvents()
#newColName(get_EVENT_CF()) input$EVENT_CF_ID
ENsubset = subset(TE, actor == event.data()$key)
#ENsubset = subset(TE, as.numeric(gsub("\\D", "", actor)) == event.data()$pointNumber)
ENsubset
})
output$eventNetworksubset_data <- renderDataTable({
test<-eventNetworksubset()
test
#event.data()
})
output$test <- renderDataTable({
w = get_moving_window(threadedEvents(),input$MovingWindowSizeID, input$WindowLocationID )
w
})
############################ Admin, params, etc ##############################
output$currentParameterSettings <- renderTable({
# start with an empty stucture and add rows.
p<- NULL
# Add each name-value pair... adjust as necessary. Lists need to be pasted and unlisted...
p <- addRow( p, "File name", input$file1[1] )
p <- addRow( p, "Columns to include", paste( unlist(input$CFcolumnsID), collapse=', ') )
# p <- addRow( p, "Range of occurrences included", paste( unlist(input$occRowsToInclude), collapse=', ') )
# p <- addRow( p, "Temporal granularity", input$timeScaleID )
p <- addRow( p, "Define threads by", paste( unlist(input$THREAD_CF_ID), collapse=', ') )
p <- addRow( p, "Define events by", paste( unlist(input$EVENT_CF_ID), collapse=', ') )
# convert to data frame and add column names
p <- as.data.frame(p)
names(p) <- c("Parameter","Value")
# return the name-value data frame
p
})
addRow <- function(Vals, Name, Value){ return( rbind(Vals, c(as.character(Name), as.character(Value)))) }
############################ Explantory tool tips ##############################
# requires package shinybs
# addTooltip(session, "PctOccToDisplayID", "For large data sets, this can be helpful", placement = "bottom", trigger = "hover",
# options = NULL)
})