diff --git a/program/shinyApp/R/enrichment_analysis/server.R b/program/shinyApp/R/enrichment_analysis/server.R
index 0251af57..f9e44cd0 100644
--- a/program/shinyApp/R/enrichment_analysis/server.R
+++ b/program/shinyApp/R/enrichment_analysis/server.R
@@ -725,11 +725,16 @@ enrichment_analysis_Server <- function(id, data, params, updates){
anno_results <- check_annotation_enrichment_analysis(ea_reactives$data)
ea_reactives$data <- anno_results$new_data
ea_reactives$can_start <- anno_results$can_start
- if(anno_results$no_ann){
+ translation_modal <- function(){
showModal(modalDialog(
title = "No annotation type detected",
footer = NULL,
- p("No valid annotation type was detected in your row annotation. Please indicate the type of annotation with which you uploaded your genes."),
+ p(paste0(
+ "No valid annotation type was detected in your row annotation. ",
+ "Please indicate the type of annotation with which you uploaded your genes.\n",
+ "Here are the first 5 rownames of your row annotation: \n",
+ toString(rownames(ea_reactives$data)[1:5])
+ )),
selectInput(
inputId = ns("AnnotationSelection"),
label = "Which annotation are you using?",
@@ -739,6 +744,9 @@ enrichment_analysis_Server <- function(id, data, params, updates){
),
actionButton(inputId = ns("AMC"), label = "Proceed"),
))
+ }
+ if(anno_results$no_ann){
+ translation_modal()
}else if(anno_results$can_start == FALSE){
if(input$ORA_or_GSE == "GeneSetEnrichment"){
ea_reactives$data <- translate_genes_ea(
@@ -757,25 +765,54 @@ enrichment_analysis_Server <- function(id, data, params, updates){
}
ea_reactives$can_start <- TRUE
}
+ # Modal in case translation fails
+ observeEvent(input$translation_again, {
+ # close modal
+ removeModal()
+ # call translation again
+ translation_modal()
+ })
# close modal on button click
observeEvent(input$AMC, {
anno_results$base_annotation <- input$AnnotationSelection
removeModal()
- if(input$ORA_or_GSE == "GeneSetEnrichment"){
- ea_reactives$data <- translate_genes_ea(
- data = ea_reactives$data,
- annotation_results = anno_results,
- input = input
- )
- }else{
- ea_reactives$tmp_genes <<- translate_genes_oa(
- annotation_results = anno_results,
- input = input,
- geneSetChoice = ea_reactives$tmp_genes,
- geneSet2Enrich = input$GeneSet2Enrich
+ tryCatch(
+ {
+ if(input$ORA_or_GSE == "GeneSetEnrichment"){
+ ea_reactives$data <- translate_genes_ea(
+ data = ea_reactives$data,
+ annotation_results = anno_results,
+ input = input
+ )
+ }else{
+ ea_reactives$tmp_genes <- translate_genes_oa(
+ annotation_results = anno_results,
+ input = input,
+ geneSetChoice = ea_reactives$tmp_genes,
+ geneSet2Enrich = input$GeneSet2Enrich
+ )
+ }
+ ea_reactives$can_start <- TRUE
+ },
+ error=function(e){
+ showModal(modalDialog(
+ title = HTML("An Error occured"),
+ footer = actionButton(
+ inputId = ns("translation_again"),
+ label = "Choose another annotation type"
+ ),
+ HTML(paste0(
+ "Error: ",e$message,"
",
+ "It is highly likely that the error is caused by the fact that the ",
+ "gene names in your data set do not match the gene names in the ",
+ "annotation you selected. Please check your data set and annotation ",
+ "and try again.
",
+ "Otherwise, please contact the cOmicsArtist Lea and Paul ",
+ "(cOmicsArtist@outlook.de)."
+ ))
+ ))
+ }
)
- }
- ea_reactives$can_start <- TRUE
})
# start the analysis if ea_reactives$can_start == TRUE
observeEvent(ea_reactives$can_start, {
diff --git a/program/shinyApp/R/enrichment_analysis/translation.R b/program/shinyApp/R/enrichment_analysis/translation.R
index 08b6eace..0b26dad5 100644
--- a/program/shinyApp/R/enrichment_analysis/translation.R
+++ b/program/shinyApp/R/enrichment_analysis/translation.R
@@ -9,28 +9,13 @@ translate_genes_ea <- function(data, annotation_results, input){
}else{
orgDb <- org.Mm.eg.db::org.Mm.eg.db
}
- tryCatch(
- {
- rowData(data)[["ENTREZID"]] <- AnnotationDbi::mapIds(
- orgDb,
- keys = rowData(data)[[annotation_results$base_annotation]],
- column = "ENTREZID",
- keytype = annotation_results$base_annotation
- )
- return(data)
- },
- error = function(e) {
- show_toast(
- title = "You chose the wrong Organism. Please restart the app.",
- type = "info",
- position = "top",
- timerProgressBar = TRUE,
- width = "30%"
- )
- # let the program wait for 5 seconds
- Sys.sleep(3)
- }
+ rowData(data)[["ENTREZID"]] <- AnnotationDbi::mapIds(
+ orgDb,
+ keys = rowData(data)[[annotation_results$base_annotation]],
+ column = "ENTREZID",
+ keytype = annotation_results$base_annotation
)
+ return(data)
}
# input$GeneSet2Enrich