Skip to content

Commit

Permalink
Report of EA only created once and not automatically when doing anoth…
Browse files Browse the repository at this point in the history
…er EA (#295)

* Report of EA only created once and not automatically when doing another EA

* small bugs
  • Loading branch information
PaulJonasJost authored Aug 9, 2024
1 parent 1e0b8e7 commit da8ee67
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions program/shinyApp/R/enrichment_analysis/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ enrichment_analysis_geneset_server <- function(
)}
)
# download section
observeEvent(input$only2Report,{
session$userData[[paste0(id, "_Report")]] <- observeEvent(input$only2Report,{
if(!is.null(session$userData[[paste0(id, "_Report_Val")]])){
req(input$only2Report > session$userData[[paste0(id, "_Report_Val")]])
}
notificationID <- showNotification(ui = "Saving...",duration = 0)
tmp_filename <- paste0(getwd(),file_path, paste(id,Sys.time(),".png",sep="_"))
ggsave(
Expand Down Expand Up @@ -175,7 +178,14 @@ enrichment_analysis_geneset_server_reactive <- function(
){
observe({
result <- result_all()[[paste("EnrichmentRes", id, sep = "_")]]
enrichment_analysis_geneset_server(id, result, organism_choice, gene_set_choice, ea_type)
# remove old observers and change base value
if (!is.null(session$userData[[paste0(id, "_Report")]])) {
session$userData[[paste0(id, "_Report_Val")]] <- isolate(
input[[paste0("EnrichmentAnalysis-", id, "-only2Report")]]
)
session$userData[[paste0(id, "_Report")]]$destroy()
}
server <- enrichment_analysis_geneset_server(id, result, organism_choice, gene_set_choice, ea_type)
})
}

Expand All @@ -202,10 +212,12 @@ enrichment_analysis_Server <- function(id, data, params, updates){
'MIR_Legacy', 'GTRD', 'TFT_Legacy', 'CGN', 'CM', 'GO_BP', 'GO_CC', 'GO_MF',
'HPO', 'IMMUNESIGDB', 'VAX'
)

# Delete and Re-create the servers
lapply(gene_sets_to_compare, function(id) {
enrichment_analysis_geneset_server_reactive(
id = id,
result = reactive(ea_reactives$enrichment_results),
result_all = reactive(ea_reactives$enrichment_results),
ea_type = input$ORA_or_GSE,
organism_choice = ea_reactives$organism,
gene_set_choice = ea_reactives$tmp_genes
Expand Down
4 changes: 2 additions & 2 deletions program/shinyApp/R/fun_getCodeSnippets.R
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ if(numberOfScenario >= 14 & numberOfScenario <= 15){

if(numberOfScenario == 15){
stringtosave_1 <- '
if(par_tmp$Enrichment$ValueToAttach == "LFC" | par_tmp$Enrichment$ValueToAttach == "LFC_abs" | input$ValueToAttach == "statistic_value"){
if(par_tmp$Enrichment$ValueToAttach == "LFC" | par_tmp$Enrichment$ValueToAttach == "LFC_abs" | par_tmp$Enrichment$ValueToAttach == "statistic_value"){
#get LFC
ctrl_samples_idx <- which(colData(res_tmp$data)[,par_tmp$Enrichment$sample_annotation_types_cmp_GSEA] %in% par_tmp$Enrichment$Groups2Compare_ref_GSEA)
comparison_samples_idx <- which(colData(res_tmp$data)[,par_tmp$Enrichment$sample_annotation_types_cmp_GSEA] %in% par_tmp$Enrichment$Groups2Compare_treat_GSEA)
Expand All @@ -1019,7 +1019,7 @@ if(par_tmp$Enrichment$ValueToAttach == "LFC" | par_tmp$Enrichment$ValueToAttach
}
else if(par_tmp$Enrichment$ValueToAttach == "LFC_abs"){
geneSetChoice_tmp <- abs(Data2Plot_tmp$LFC)
} else if(input$ValueToAttach == "LFC_abs"){
} else if(par_tmp$Enrichment$ValueToAttach == "LFC_abs"){
geneSetChoice_tmp <- abs(Data2Plot_tmp$LFC)
}
Expand Down

0 comments on commit da8ee67

Please sign in to comment.