@@ -40,17 +40,14 @@ ui <- shiny::fluidPage(
40
40
41
41
shiny :: tags $ hr(),
42
42
# Select allele mismatch value
43
- shiny :: textInput (inputId = " alleleMismatchValue" , label = " Allowed Allele-mismatch" , value = " 3 " ),
43
+ shiny :: numericInput (inputId = " alleleMismatchValue" , label = " Allowed Allele-mismatch" , value = 3 , min = 0 , step = 1 ),
44
44
# If the user asks for the plot, generate it and show it
45
45
shiny :: conditionalPanel(condition = " input.generateAllelematchProfile >= 1" ,
46
46
plotOutput(outputId = " allelematchProfilePlot" ),
47
47
),
48
- shiny :: conditionalPanel(condition = " input.generateAllelematchProfile == 0" ,
49
- actionButton(inputId = " generateAllelematchProfile" , " Generate Mismatch Plot" ),
50
- ),
51
-
52
- h4(" Type the column name of the specified columns." ),
53
- h5(" If header is deseleted, type the indexes of the columns." ),
48
+ shiny :: actionButton(inputId = " generateAllelematchProfile" , " Generate Mismatch Plot" ),
49
+ shiny :: h4(" Type the column name of the specified columns." ),
50
+ shiny :: h5(" If header is deseleted, type the indexes of the columns." ),
54
51
55
52
56
53
# Select Index Column
@@ -87,7 +84,7 @@ ui <- shiny::fluidPage(
87
84
# Allow the user to select and handle all of the multiple matches that occured
88
85
div(h4(" Handle Multiple Matches" )),
89
86
90
- textInput (inputId = " multipleMatchIndex" , label = " View Details (Index of Multiple Matched Sample): " , placeholder = " tex 2 " ),
87
+ shiny :: numericInput (inputId = " multipleMatchIndex" , label = " View Details (Index of Multiple Matched Sample): " , value = 0 , min = 0 , step = 1 ),
91
88
DT :: dataTableOutput(" multipleMatchesTable" ),
92
89
93
90
# TODO:: Allow the user to handle these (similar to matching new data)
@@ -128,9 +125,11 @@ ui <- shiny::fluidPage(
128
125
shiny :: conditionalPanel(condition = " input.new_data_mode == 'single'" ,
129
126
shiny :: textInput(inputId = " new_data_index" , label = " Index: " ),
130
127
shiny :: dateInput(inputId = " new_data_date" , label = " Date: " ),
131
- shiny :: textInput(inputId = " new_data_nornt " , label = " North: " ),
128
+ shiny :: textInput(inputId = " new_data_north " , label = " North: " ),
132
129
shiny :: textInput(inputId = " new_data_east" , label = " East: " ),
130
+ shiny :: h5(shiny :: textOutput(outputId = " currentGenderStyle" )),
133
131
shiny :: textInput(inputId = " new_data_gender" , label = " Gender: " ),
132
+ shiny :: h5(" Make sure the order is the same as the rest of the data, in alignment with the order given to the right." ),
134
133
shiny :: textInput(inputId = " new_data_locus" , label = " Locus (separated by ' '):" )
135
134
),
136
135
# If multiple is choosen, open those options
@@ -146,7 +145,7 @@ ui <- shiny::fluidPage(
146
145
),
147
146
shiny :: tags $ hr(),
148
147
# How many mismatchs to allow when mathcing new data to the rest of the dataset
149
- shiny :: textInput (inputId = " new_data_mismatch" , label = " Mismatch For New Data" ),
148
+ shiny :: numericInput (inputId = " new_data_mismatch" , label = " Mismatch For New Data" , value = 3 , min = 0 , step = 1 ),
150
149
# Load the file or strings into data and compare with the dataset
151
150
shiny :: actionButton(inputId = " search_new_data" , label = " Match New Data To Dataset" ),
152
151
shiny :: tags $ hr(),
@@ -176,10 +175,13 @@ server <- function(input, output, session) {
176
175
})
177
176
178
177
groupIndividuals <- function () {
178
+ req(input $ file1 )
179
179
req(as.numeric(input $ alleleMismatchValue ))
180
180
181
181
# Reload the data incase the colmn-names have changed
182
- load_main_data()
182
+ c(data_temp , am_data_temp ) %<- % load_main_data(input $ file1 $ datapath )
183
+ data <<- data_temp
184
+ am_data <<- am_data_temp
183
185
184
186
# Unpack the different data returned by our wrapper of allelematch into temp variables
185
187
c(search_data_temp , multiple_matches_temp , unclassified_temp ) %<- % GenotypeCheck :: create_search_data(data , am_data , as.numeric(input $ alleleMismatchValue ))
@@ -190,9 +192,8 @@ server <- function(input, output, session) {
190
192
unclassified <<- unclassified_temp
191
193
}
192
194
193
- load_main_data <- function () {
194
- req(input $ file1 )
195
-
195
+ # load the main data file
196
+ load_main_data <- function (file ) {
196
197
# Read the locus data from the ui
197
198
locus_columns <- strsplit(input $ locusColumnNames , " ," )[[1 ]]
198
199
@@ -211,10 +212,12 @@ server <- function(input, output, session) {
211
212
}
212
213
213
214
# Load the data, this will be the meta data
214
- data << - GenotypeCheck :: import_data(input $ file1 $ datapath , index_column = index_column , additional_data = additional_data , locus_names = locus_columns )
215
+ data <- GenotypeCheck :: import_data(file , index_column = index_column , additional_data = additional_data , locus_names = locus_columns )
215
216
216
217
# Create allaematch dataset, ignore some meta-data as it can be read from the "data" above, the index (SEP) is the same
217
- am_data <<- GenotypeCheck :: create_allelematch_dataset(data , ignore_columns = names(additional_data ))
218
+ am_data <- GenotypeCheck :: create_allelematch_dataset(data , ignore_columns = names(additional_data ))
219
+
220
+ list (data , am_data )
218
221
}
219
222
220
223
update_output_preprocess_data <- function () {
@@ -247,6 +250,10 @@ server <- function(input, output, session) {
247
250
output $ amtUnclassified <- renderText(
248
251
paste0(" There were: " , length(unclassified $ index ), " samples that were unclassified." )
249
252
)
253
+
254
+ output $ currentGenderStyle <- renderText(
255
+ paste(" The datasets gender-style is: " , paste0(data $ gender [! duplicated(data $ gender )], sep = " , " , collapse = " " ))
256
+ )
250
257
}
251
258
252
259
# Observe when user types an index to view details
@@ -339,13 +346,48 @@ server <- function(input, output, session) {
339
346
req(input $ file1 )
340
347
341
348
# Reload the data incase teh colmnnames have changed
342
- load_main_data()
349
+ c(data_temp , am_data_temp ) %<- % load_main_data(input $ file1 $ datapath )
350
+ data <<- data_temp
351
+ am_data <<- am_data_temp
343
352
344
353
# Render the plot to the ui
345
354
output $ allelematchProfilePlot <- shiny :: renderPlot({
346
355
GenotypeCheck :: generate_allelemtach_profile_plot(am_data )
347
356
})
348
357
})
358
+
359
+ shiny :: observeEvent(input $ search_new_data , {
360
+ if (input $ new_data_mode == " single" ) {
361
+ # Make sure the essential data is given, the rest is meta-data and it would be annoying if it were required
362
+ req(input $ new_data_index )
363
+ req(input $ new_data_locus )
364
+ req(input $ new_data_mismatch )
365
+
366
+ # Read the locus data from the ui
367
+ locus_columns <- strsplit(input $ locusColumnNames , " ," )[[1 ]]
368
+
369
+ # Split the locus string and name the columns accordingly in the same order that have been given in the panel to the right
370
+ # Order is important here
371
+ multilocus <- strsplit(input $ new_data_locus , " " )[[1 ]]
372
+
373
+ names(multilocus ) <- locus_columns
374
+
375
+ # Create the new data, a dataframe with one row
376
+ new_data <- data.frame (list (index = input $ new_data_index ), date = input $ new_data_date , north = input $ new_data_north ,
377
+ east = input $ new_data_east , gender = input $ new_data_gender ) %> %
378
+ cbind(data.frame (as.list(multilocus )))
379
+ } else if (input $ new_data_mode == " multiple" ) {
380
+ # If a file is given, use the already exsiting function to load and parse it according to the specifications on the right
381
+ c(new_data , new_am_data ) %<- % load_main_data(input $ new_data_file $ datapath )
382
+ }
383
+ # Get the search_data-type of data for the new data
384
+ c(new_search_data , new_multiple_match , new_unclassified ) %<- % GenotypeCheck :: match_new_data(data = data , new_data = new_data , additional_data_columns = names(additional_data ), allele_mismatch = input $ new_data_mismatch )
385
+
386
+ # DEBUG: Temp
387
+ print(new_search_data )
388
+ print(new_multiple_match )
389
+ print(new_unclassified )
390
+ })
349
391
}
350
392
351
393
# Create a shiny app
0 commit comments