From 0b34f92867f5e95f5cfd19bbee55c2b357e301bc Mon Sep 17 00:00:00 2001 From: PaulJonasJost Date: Mon, 29 Jan 2024 10:56:23 +0100 Subject: [PATCH 1/4] removed assignment as the return value is questionable. --- program/shinyApp/R/enrichment_analysis/ui.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/program/shinyApp/R/enrichment_analysis/ui.R b/program/shinyApp/R/enrichment_analysis/ui.R index 5174d203..4142097b 100644 --- a/program/shinyApp/R/enrichment_analysis/ui.R +++ b/program/shinyApp/R/enrichment_analysis/ui.R @@ -6,7 +6,6 @@ geneset_panel_UI <- function( tabPanel( title = id_wo_ns, - # textOutput("Info", container = pre), tabsetPanel( tabPanel( title = paste(id_wo_ns, " Enrichment"), @@ -179,7 +178,7 @@ enrichment_analysis_UI <- function(id){ # Enrichment ######################################### h4("NOTE THAT THIS ONLY MAKES SENSE FOR TRANSCRIPTOMICS DATA AT THE MOMENT!"), - enrichment_analysis_sidebar <- ea_sidebar(ns), - enrichment_analysis_main <- ea_main(ns), + ea_sidebar(ns), + ea_main(ns), ) } From d56bcf06c92dab574cd074085971f2e9259e8fbd Mon Sep 17 00:00:00 2001 From: PaulJonasJost Date: Mon, 29 Jan 2024 13:26:37 +0100 Subject: [PATCH 2/4] Moved some things to constant for better readability. --- program/shinyApp/R/C.R | 67 ++++++++++++- .../shinyApp/R/enrichment_analysis/server.R | 98 +------------------ 2 files changed, 70 insertions(+), 95 deletions(-) diff --git a/program/shinyApp/R/C.R b/program/shinyApp/R/C.R index 76426abe..60d72e4f 100644 --- a/program/shinyApp/R/C.R +++ b/program/shinyApp/R/C.R @@ -29,4 +29,69 @@ list2env(envList,envir = globalenv()) # if you want to combine multiple plots use the `with` notation instead e.g. # plot <- with(envList, {ggplot(..)+geom_point()}) -# Happy Adjusting! :)" \ No newline at end of file +# Happy Adjusting! :)" + +# Geneset enrichment list reset +GENESETS_RESET <<- list( + "Hallmarks" = F, + "C1" = F, + "C2" = F, + "CGP" = F, + "CP" = F, + "BIOCARTA" = F, + "KEGG" = F, + "PID" = F, + "REACTOME" = F, + "WIKIPATHWAYS" = F, + "C3" = F, + "MIRDB" = F, + "MIR_Legacy" = F, + "GTRD" = F, + "TFT_Legacy" = F, + "C4" = F, + "CGN" = F, + "CM" = F, + "C5" = F, + "GO" = F, + "GO_BP" = F, + "GO_CC" = F, + "GO_MF" = F, + "HPO" = F, + "C6" = F, + "C7" = F, + "IMMUNESIGDB" = F, + "VAX" = F, + "C8" = F +) +ENRICHMENT_RESULT_RESET <<- list( + "EnrichmentRes_Hallmarks" = NULL, + "EnrichmentRes_C1" = NULL, + "EnrichmentRes_C2" = NULL, + "EnrichmentRes_CGP" = NULL, + "EnrichmentRes_CP" = NULL, + "EnrichmentRes_BIOCARTA" = NULL, + "EnrichmentRes_KEGG" = NULL, + "EnrichmentRes_PID" = NULL, + "EnrichmentRes_REACTOME" = NULL, + "EnrichmentRes_WIKIPATHWAYS" = NULL, + "EnrichmentRes_C3" = NULL, + "EnrichmentRes_MIRDB" = NULL, + "EnrichmentRes_MIR_Legacy" = NULL, + "EnrichmentRes_GTRD" = NULL, + "EnrichmentRes_TFT_Legacy" = NULL, + "EnrichmentRes_C4" = NULL, + "EnrichmentRes_CGN" = NULL, + "EnrichmentRes_CM" = NULL, + "EnrichmentRes_C5" = NULL, + "EnrichmentRes_GO" = NULL, + "EnrichmentRes_GO_BP" = NULL, + "EnrichmentRes_GO_CC" = NULL, + "EnrichmentRes_GO_MF" = NULL, + "EnrichmentRes_HPO" = NULL, + "EnrichmentRes_C6" = NULL, + "EnrichmentRes_C7" = NULL, + "EnrichmentRes_IMMUNESIGDB" = NULL, + "EnrichmentRes_VAX" = NULL, + "EnrichmentRes_C8" = NULL, + "geneSetChoice_tranlsated" = NULL +) \ No newline at end of file diff --git a/program/shinyApp/R/enrichment_analysis/server.R b/program/shinyApp/R/enrichment_analysis/server.R index f9e44cd0..97d3aad3 100644 --- a/program/shinyApp/R/enrichment_analysis/server.R +++ b/program/shinyApp/R/enrichment_analysis/server.R @@ -162,38 +162,8 @@ enrichment_analysis_Server <- function(id, data, params, updates){ ) ns <- session$ns ## initialize result as NULL - ea_reactives$enrichment_results <- list( - "EnrichmentRes_Hallmarks" = NULL, - "EnrichmentRes_C1" = NULL, - "EnrichmentRes_C2" = NULL, - "EnrichmentRes_CGP" = NULL, - "EnrichmentRes_CP" = NULL, - "EnrichmentRes_BIOCARTA" = NULL, - "EnrichmentRes_KEGG" = NULL, - "EnrichmentRes_PID" = NULL, - "EnrichmentRes_REACTOME" = NULL, - "EnrichmentRes_WIKIPATHWAYS" = NULL, - "EnrichmentRes_C3" = NULL, - "EnrichmentRes_MIRDB" = NULL, - "EnrichmentRes_MIR_Legacy" = NULL, - "EnrichmentRes_GTRD" = NULL, - "EnrichmentRes_TFT_Legacy" = NULL, - "EnrichmentRes_C4" = NULL, - "EnrichmentRes_CGN" = NULL, - "EnrichmentRes_CM" = NULL, - "EnrichmentRes_C5" = NULL, - "EnrichmentRes_GO" = NULL, - "EnrichmentRes_GO_BP" = NULL, - "EnrichmentRes_GO_CC" = NULL, - "EnrichmentRes_GO_MF" = NULL, - "EnrichmentRes_HPO" = NULL, - "EnrichmentRes_C6" = NULL, - "EnrichmentRes_C7" = NULL, - "EnrichmentRes_IMMUNESIGDB" = NULL, - "EnrichmentRes_VAX" = NULL, - "EnrichmentRes_C8" = NULL, - "geneSetChoice_tranlsated" = NULL - ) + ea_reactives$enrichment_results <- ENRICHMENT_RESULT_RESET + # TODO: Call this in a loop. ## Call Modules enrichment_analysis_geneset_server_reactive( id = 'KEGG', @@ -577,71 +547,11 @@ enrichment_analysis_Server <- function(id, data, params, updates){ } }) # create List to track which enrichements are to do - ea_reactives$enrichments2do <- list( - "Hallmarks" = F, - "C1" = F, - "C2" = F, - "CGP" = F, - "CP" = F, - "BIOCARTA" = F, - "KEGG" = F, - "PID" = F, - "REACTOME" = F, - "WIKIPATHWAYS" = F, - "C3" = F, - "MIRDB" = F, - "MIR_Legacy" = F, - "GTRD" = F, - "TFT_Legacy" = F, - "C4" = F, - "CGN" = F, - "CM" = F, - "C5" = F, - "GO" = F, - "GO_BP" = F, - "GO_CC" = F, - "GO_MF" = F, - "HPO" = F, - "C6" = F, - "C7" = F, - "IMMUNESIGDB" = F, - "VAX" = F, - "C8" = F - ) + ea_reactives$enrichments2do <- GENESETS_RESET # change values in list to true if selected observeEvent(input$GeneSetChoice, { # reset list - ea_reactives$enrichments2do <- list( - "Hallmarks" = F, - "C1" = F, - "C2" = F, - "CGP" = F, - "CP" = F, - "BIOCARTA" = F, - "KEGG" = F, - "PID" = F, - "REACTOME" = F, - "WIKIPATHWAYS" = F, - "C3" = F, - "MIRDB" = F, - "MIR_Legacy" = F, - "GTRD" = F, - "TFT_Legacy" = F, - "C4" = F, - "CGN" = F, - "CM" = F, - "C5" = F, - "GO" = F, - "GO_BP" = F, - "GO_CC" = F, - "GO_MF" = F, - "HPO" = F, - "C6" = F, - "C7" = F, - "IMMUNESIGDB" = F, - "VAX" = F, - "C8" = F - ) + ea_reactives$enrichments2do <- GENESETS_RESET for(i in 1:length(input$GeneSetChoice)){ ea_reactives$enrichments2do[[input$GeneSetChoice[i]]] <- T } From 963dc37e24e13d25764e4bcce5406a17b059a8bb Mon Sep 17 00:00:00 2001 From: PaulJonasJost Date: Mon, 29 Jan 2024 18:42:21 +0100 Subject: [PATCH 3/4] Removed ornaism as a choice as we chose it before already. --- .../enrichment_analysis/enrichment_analysis.R | 66 ++++++++------- .../overrepresentation_analysis.R | 71 +++++++++------- .../shinyApp/R/enrichment_analysis/server.R | 84 +++++++++---------- .../R/enrichment_analysis/translation.R | 8 +- program/shinyApp/server.R | 1 + 5 files changed, 120 insertions(+), 110 deletions(-) diff --git a/program/shinyApp/R/enrichment_analysis/enrichment_analysis.R b/program/shinyApp/R/enrichment_analysis/enrichment_analysis.R index d40d112a..ab83cb1e 100644 --- a/program/shinyApp/R/enrichment_analysis/enrichment_analysis.R +++ b/program/shinyApp/R/enrichment_analysis/enrichment_analysis.R @@ -1,5 +1,5 @@ gene_set_enrichment <- function( - input, + organism, geneSetChoice, data, enrichments2do, @@ -46,13 +46,19 @@ gene_set_enrichment <- function( EnrichmentRes_IMMUNESIGDB <- NULL EnrichmentRes_VAX <- NULL EnrichmentRes_C8 <- NULL + + # set Species + species <- "Mus musculus" + if(organism == "Human genes (GRCh38.p14)"){ + species <- "Homo sapiens" + } if(enrichments2do$KEGG){ if( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$KEGG )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CP:KEGG" ) %>% dplyr::select(gs_name, entrez_gene) @@ -82,7 +88,7 @@ gene_set_enrichment <- function( maxGSSize = 800, pvalueCutoff = 0.05, verbose = TRUE, - OrgDb = ifelse(input$OrganismChoice == "hsa","org.Hs.eg.db","org.Mm.eg.db"), + OrgDb = ifelse(organism == "Human genes (GRCh38.p14)","org.Hs.eg.db","org.Mm.eg.db"), pAdjustMethod = PADJUST_METHOD[[adjustMethod]] ) res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO <<- EnrichmentRes_GO @@ -97,7 +103,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$Hallmarks )) ){ Hallmarkset <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "H", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_Hallmarks <- GSEA( @@ -120,7 +126,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C1 )) ){ C1set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C1", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C1 <- GSEA( @@ -144,7 +150,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C2 )) ){ C2set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C2 <- GSEA( @@ -167,7 +173,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C3 )) ){ C3set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C3", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C3 <- GSEA( @@ -190,7 +196,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C4 )) ){ C4set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C4", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C4 <- GSEA( @@ -213,7 +219,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C5 )) ){ C5set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C5", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C5 <- GSEA( @@ -236,7 +242,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C6 )) ){ C6set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C6", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C6 <- GSEA( @@ -259,7 +265,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C7 )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C7" ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C7 <- GSEA( @@ -282,7 +288,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C8 )) ){ C8set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C8", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C8 <- GSEA( @@ -305,7 +311,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CGP )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CGP" ) %>% dplyr::select(gs_name, entrez_gene) @@ -329,7 +335,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CP )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CP" ) %>% dplyr::select(gs_name, entrez_gene) @@ -353,7 +359,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$BIOCARTA )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CP:BIOCARTA" ) %>% dplyr::select(gs_name, entrez_gene) @@ -377,7 +383,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$PID )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CP:PID" ) %>% dplyr::select(gs_name, entrez_gene) @@ -401,7 +407,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$REACTOME )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CP:REACTOME" ) %>% dplyr::select(gs_name, entrez_gene) @@ -425,7 +431,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$WIKIPATHWAYS )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CP:WIKIPATHWAYS" ) %>% dplyr::select(gs_name, entrez_gene) @@ -449,7 +455,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$MIRDB )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C3", subcategory = "MIR:MIRDB" ) %>% dplyr::select(gs_name, entrez_gene) @@ -473,7 +479,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$MIR_Legacy )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C3", subcategory = "MIR:MIR_Legacy" ) %>% dplyr::select(gs_name, entrez_gene) @@ -497,7 +503,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GTRD )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C3", subcategory = "TFT:GTRD" ) %>% dplyr::select(gs_name, entrez_gene) @@ -521,7 +527,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$TFT_Legacy )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C3", subcategory = "TFT:TFT_Legacy" ) %>% dplyr::select(gs_name, entrez_gene) @@ -545,7 +551,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CGN )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C4", subcategory = "CGN" ) %>% dplyr::select(gs_name, entrez_gene) @@ -569,7 +575,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CM )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C4", subcategory = "CM" ) %>% dplyr::select(gs_name, entrez_gene) @@ -593,7 +599,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_BP )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C5", subcategory = "GO:BP" ) %>% dplyr::select(gs_name, entrez_gene) @@ -617,7 +623,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_CC )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C5", subcategory = "GO:CC" ) %>% dplyr::select(gs_name, entrez_gene) @@ -641,7 +647,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_MF )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C5", subcategory = "GO:MF" ) %>% dplyr::select(gs_name, entrez_gene) @@ -665,7 +671,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$HPO )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C5", subcategory = "HPO" ) %>% dplyr::select(gs_name, entrez_gene) @@ -689,7 +695,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$IMMUNESIGDB )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C7", subcategory = "IMMUNESIGDB" ) %>% dplyr::select(gs_name, entrez_gene) @@ -713,7 +719,7 @@ gene_set_enrichment <- function( !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$VAX )) ){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C7", subcategory = "VAX" ) %>% dplyr::select(gs_name, entrez_gene) diff --git a/program/shinyApp/R/enrichment_analysis/overrepresentation_analysis.R b/program/shinyApp/R/enrichment_analysis/overrepresentation_analysis.R index 733d50f6..623a4fbc 100644 --- a/program/shinyApp/R/enrichment_analysis/overrepresentation_analysis.R +++ b/program/shinyApp/R/enrichment_analysis/overrepresentation_analysis.R @@ -1,6 +1,6 @@ over_representation_analysis <- function( input, - output, + organism, geneSetChoice, data, enrichments2do, @@ -9,6 +9,12 @@ over_representation_analysis <- function( # Overrepresentation analysis # no translation needed as already done before. + # set Species + species <- "Mus musculus" + if(organsim == "Human genes (GRCh38.p14)"){ + species <- "Homo sapiens" + } + if(!isTruthy(input$UniverseOfGene)){ universeSelected_tranlsated <- NULL } else if(input$UniverseOfGene == "default"){ @@ -28,7 +34,7 @@ over_representation_analysis <- function( universeSelected, fromType = "ENSEMBL", toType = "ENTREZID", - OrgDb = ifelse(input$OrganismChoice == "hsa","org.Hs.eg.db","org.Mm.eg.db") + OrgDb = ifelse(species == "Homo sapiens","org.Hs.eg.db","org.Mm.eg.db") )$ENTREZID print(paste0( "Universe genes translated (hence actually used): ", @@ -67,12 +73,13 @@ over_representation_analysis <- function( EnrichmentRes_IMMUNESIGDB <- NULL EnrichmentRes_VAX <- NULL EnrichmentRes_C8 <- NULL + # KEGG if(enrichments2do$KEGG){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$KEGG ))){ EnrichmentRes_KEGG <- clusterProfiler::enrichKEGG( gene = geneSetChoice, - organism = input$OrganismChoice, + organism = ifelse(species=="Homo sapiens","hsa","mmu"), pvalueCutoff = 0.05, pAdjustMethod = PADJUST_METHOD[[adjustMethod]], universe = universeSelected_tranlsated @@ -91,7 +98,7 @@ over_representation_analysis <- function( ont = "ALL", pvalueCutoff = 0.05, pAdjustMethod = PADJUST_METHOD[[adjustMethod]], - OrgDb = ifelse(input$OrganismChoice == "hsa","org.Hs.eg.db","org.Mm.eg.db") + OrgDb = ifelse(species=="Homo sapiens","org.Hs.eg.db","org.Mm.eg.db") ) res_tmp[[session$token]]$OA$GO <<- EnrichmentRes_GO par_tmp[[session$token]]$OA$GO <<- list("Universe"=input$UniverseOfGene) @@ -106,7 +113,7 @@ over_representation_analysis <- function( gene = geneSetChoice, pvalueCutoff = 0.05, pAdjustMethod = PADJUST_METHOD[[adjustMethod]], - organism = ifelse(input$OrganismChoice == "hsa","human","mouse"), + organism = ifelse(species=="Homo sapiens","human","mouse"), universe = universeSelected_tranlsated, readable = T ) @@ -120,7 +127,7 @@ over_representation_analysis <- function( if(enrichments2do$Hallmarks){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$Hallmarks ))){ Hallmarkset <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "H", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_Hallmarks <- clusterProfiler::enricher( @@ -140,7 +147,7 @@ over_representation_analysis <- function( if(enrichments2do$C1){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C1 ))){ C1set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C1", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C1 <- clusterProfiler::enricher( @@ -160,7 +167,7 @@ over_representation_analysis <- function( if(enrichments2do$C2){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C2 ))){ C2set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C2 <- clusterProfiler::enricher( @@ -180,7 +187,7 @@ over_representation_analysis <- function( if(enrichments2do$C3){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C3 ))){ C3set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C3", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C3 <- clusterProfiler::enricher( @@ -200,7 +207,7 @@ over_representation_analysis <- function( if(enrichments2do$C4){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C4 ))){ C4set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C4", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C4 <- clusterProfiler::enricher( @@ -220,7 +227,7 @@ over_representation_analysis <- function( if(enrichments2do$C5){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C5 ))){ C5set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C5", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C5 <- clusterProfiler::enricher( @@ -240,7 +247,7 @@ over_representation_analysis <- function( if(enrichments2do$C6){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C6 ))){ C6set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C6", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C6 <- clusterProfiler::enricher( @@ -260,7 +267,7 @@ over_representation_analysis <- function( if(enrichments2do$C7){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C7 ))){ C7set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C7", subcategory = "IMMUNESIGDB" ) %>% dplyr::select(gs_name, entrez_gene) @@ -281,7 +288,7 @@ over_representation_analysis <- function( if(enrichments2do$C8){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C8 ))){ C8set <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C8", ) %>% dplyr::select(gs_name, entrez_gene) EnrichmentRes_C8 <- clusterProfiler::enricher( @@ -301,7 +308,7 @@ over_representation_analysis <- function( if(enrichments2do$CGP){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$CGP ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CGP" ) %>% dplyr::select(gs_name, entrez_gene) @@ -322,7 +329,7 @@ over_representation_analysis <- function( if(enrichments2do$CP){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$CP ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CP" ) %>% dplyr::select(gs_name, entrez_gene) @@ -343,7 +350,7 @@ over_representation_analysis <- function( if(enrichments2do$BIOCARTA){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$BIOCARTA ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CP:BIOCARTA" ) %>% dplyr::select(gs_name, entrez_gene) @@ -364,7 +371,7 @@ over_representation_analysis <- function( if(enrichments2do$PID){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$PID ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CP:PID" ) %>% dplyr::select(gs_name, entrez_gene) @@ -385,7 +392,7 @@ over_representation_analysis <- function( if(enrichments2do$REACTOME){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$REACTOME ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CP:REACTOME" ) %>% dplyr::select(gs_name, entrez_gene) @@ -406,7 +413,7 @@ over_representation_analysis <- function( if(enrichments2do$WIKIPATHWAYS){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$WIKIPATHWAYS ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C2", subcategory = "CP:WIKIPATHWAYS" ) %>% dplyr::select(gs_name, entrez_gene) @@ -427,7 +434,7 @@ over_representation_analysis <- function( if(enrichments2do$MIRDB){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$MIRDB ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C3", subcategory = "MIR:MIRDB" ) %>% dplyr::select(gs_name, entrez_gene) @@ -448,7 +455,7 @@ over_representation_analysis <- function( if(enrichments2do$MIR_Legacy){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$MIR_Legacy ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C3", subcategory = "MIR:MIR_Legacy" ) %>% dplyr::select(gs_name, entrez_gene) @@ -469,7 +476,7 @@ over_representation_analysis <- function( if(enrichments2do$GTRD){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$GTRD ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C3", subcategory = "TFT:GTRD" ) %>% dplyr::select(gs_name, entrez_gene) @@ -490,7 +497,7 @@ over_representation_analysis <- function( if(enrichments2do$TFT_Legacy){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$TFT_Legacy ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C3", subcategory = "TFT:TFT_Legacy" ) %>% dplyr::select(gs_name, entrez_gene) @@ -511,7 +518,7 @@ over_representation_analysis <- function( if(enrichments2do$CGN){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$CGN ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C4", subcategory = "CGN" ) %>% dplyr::select(gs_name, entrez_gene) @@ -532,7 +539,7 @@ over_representation_analysis <- function( if(enrichments2do$CM){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$CM ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C4", subcategory = "CM" ) %>% dplyr::select(gs_name, entrez_gene) @@ -553,7 +560,7 @@ over_representation_analysis <- function( if(enrichments2do$GO_BP){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$GO_BP ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C5", subcategory = "GO:BP" ) %>% dplyr::select(gs_name, entrez_gene) @@ -574,7 +581,7 @@ over_representation_analysis <- function( if(enrichments2do$GO_CC){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$GO_CC ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C5", subcategory = "GO:CC" ) %>% dplyr::select(gs_name, entrez_gene) @@ -595,7 +602,7 @@ over_representation_analysis <- function( if(enrichments2do$GO_MF){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$GO_MF ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C5", subcategory = "GO:MF" ) %>% dplyr::select(gs_name, entrez_gene) @@ -616,7 +623,7 @@ over_representation_analysis <- function( if(enrichments2do$HPO){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$HPO ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C5", subcategory = "HPO" ) %>% dplyr::select(gs_name, entrez_gene) @@ -637,7 +644,7 @@ over_representation_analysis <- function( if(enrichments2do$IMMUNESIGDB){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$IMMUNESIGDB ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C7", subcategory = "IMMUNESIGDB" ) %>% dplyr::select(gs_name, entrez_gene) @@ -658,7 +665,7 @@ over_representation_analysis <- function( if(enrichments2do$VAX){ if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$VAX ))){ genesets4ea <- msigdbr( - species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), + species = species, category = "C7", subcategory = "VAX" ) %>% dplyr::select(gs_name, entrez_gene) diff --git a/program/shinyApp/R/enrichment_analysis/server.R b/program/shinyApp/R/enrichment_analysis/server.R index 97d3aad3..b1a8bfda 100644 --- a/program/shinyApp/R/enrichment_analysis/server.R +++ b/program/shinyApp/R/enrichment_analysis/server.R @@ -158,7 +158,8 @@ enrichment_analysis_Server <- function(id, data, params, updates){ ea_reactives <- reactiveValues( ea_info = "Choose between ORA or GSEA!", can_start = FALSE, - data = NULL + data = NULL, + organism = NULL ) ns <- session$ns ## initialize result as NULL @@ -169,70 +170,70 @@ enrichment_analysis_Server <- function(id, data, params, updates){ id = 'KEGG', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'GO', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'REACTOME', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'Hallmarks', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'C1', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'C2', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'C3', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'C4', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'C5', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'C6', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) # Currently C7 subset Immunesigdb @@ -240,144 +241,139 @@ enrichment_analysis_Server <- function(id, data, params, updates){ id = 'C7', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'C8', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'CGP', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'CP', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'BIOCARTA', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'PID', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'WIKIPATHWAYS', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'MIRDB', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'MIR_Legacy', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'GTRD', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'TFT_Legacy', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'CGN', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'CM', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'GO_BP', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'GO_CC', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'GO_MF', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'HPO', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'IMMUNESIGDB', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) enrichment_analysis_geneset_server_reactive( id = 'VAX', result = reactive(ea_reactives$enrichment_results), ea_type = input$ORA_or_GSE, - organism_choice = input$OrganismChoice, + organism_choice = ea_reactives$organism, gene_set_choice = ea_reactives$tmp_genes ) ## Ui section - output$OrganismChoice_ui <- renderUI({ - selectInput( - inputId = ns("OrganismChoice"), - label = "Specificy your current organism", - choices = c("hsa", "mmu"), - selected = "mmu" - ) - }) + output$OrganismChoice_ui <- renderText(paste0( + "The organism you chose is ",ea_reactives$organism, "." + )) output$ORA_or_GSE_ui <- renderUI({ radioButtons( inputId = ns("ORA_or_GSE"), @@ -395,6 +391,7 @@ enrichment_analysis_Server <- function(id, data, params, updates){ # refresh the UI/data if needed observeEvent(input$refreshUI, { ea_reactives$data <- update_data(session$token)$data + ea_reactives$organism <- par_tmp[[session$token]]['organism'] }) # UI to choose test correction output$AdjustmentMethod_ui <- renderUI({ @@ -729,7 +726,7 @@ enrichment_analysis_Server <- function(id, data, params, updates){ req(ea_reactives$can_start == TRUE) if(input$ORA_or_GSE == "GeneSetEnrichment"){ ea_reactives$enrichment_results <- gene_set_enrichment( - input, + ea_reactives$organism, ea_reactives$tmp_genes, ea_reactives$data, ea_reactives$enrichments2do, @@ -742,7 +739,7 @@ enrichment_analysis_Server <- function(id, data, params, updates){ }else{ ea_reactives$enrichment_results <- over_representation_analysis( input, - output, + ea_reactives$organism, ea_reactives$tmp_genes, data, ea_reactives$enrichments2do, @@ -760,7 +757,6 @@ enrichment_analysis_Server <- function(id, data, params, updates){ "Groups2Compare_treat_GSEA" = input$Groups2Compare_treat_GSEA, "sample_annotation_types_cmp_GSEA" = input$sample_annotation_types_cmp_GSEA, "ORA_or_GSE" = input$ORA_or_GSE, - "OrganismChoice" = input$OrganismChoice, "UniverseOfGene" = input$UniverseOfGene ) }) @@ -849,7 +845,7 @@ enrichment_analysis_Server <- function(id, data, params, updates){ geneSetChoice(), fromType = "ENSEMBL", toType = "ENTREZID", - OrgDb = ifelse(input$OrganismChoice == "hsa","org.Hs.eg.db","org.Mm.eg.db") + OrgDb = ifelse(ea_reactives$organism == "hsa","org.Hs.eg.db","org.Mm.eg.db") )$ENTREZID testingMatrix <- data.frame( GeneID = geneSetChoice_tranlsated$ENTREZID, @@ -867,7 +863,7 @@ enrichment_analysis_Server <- function(id, data, params, updates){ geneSetChoice(), fromType = "ENSEMBL", toType = "ENTREZID", - OrgDb = ifelse(input$OrganismChoice == "hsa","org.Hs.eg.db","org.Mm.eg.db"))$ENTREZID + OrgDb = ifelse(ea_reactives$organism == "hsa","org.Hs.eg.db","org.Mm.eg.db"))$ENTREZID geneSetChoice_final <- geneSetChoice_tranlsated output$WorkAroundLegend <- renderPrint({paste0("Colored if present in provided gene set")}) @@ -878,7 +874,7 @@ enrichment_analysis_Server <- function(id, data, params, updates){ PathviewRes <- pathview( gene.data = geneSetChoice_final, pathway.id = real_PathwayID, - species = input$OrganismChoice, + species = ea_reactives$organism, limit = ifelse(is.matrix(geneSetChoice_final),list(gene=max(abs(geneSetChoice_final)), cpd=1),list(gene=1,cpd=1)), low = "#379fcc", mid = "grey", diff --git a/program/shinyApp/R/enrichment_analysis/translation.R b/program/shinyApp/R/enrichment_analysis/translation.R index 0b26dad5..dda1116a 100644 --- a/program/shinyApp/R/enrichment_analysis/translation.R +++ b/program/shinyApp/R/enrichment_analysis/translation.R @@ -3,8 +3,8 @@ translate_genes_ea <- function(data, annotation_results, input){ # copy rownames with corresponding annotation as columnname rowData(data)[[annotation_results$base_annotation]] <- rownames(rowData(data)) # can this be just data? } - # translate to entrez id - if(input$OrganismChoice == "hsa"){ + # translate to entrez id, currently only Humand and Mouse supported + if(par_tmp[[session$token]]['organism'] == "Human genes (GRCh38.p14)"){ orgDb <- org.Hs.eg.db::org.Hs.eg.db }else{ orgDb <- org.Mm.eg.db::org.Mm.eg.db @@ -26,8 +26,8 @@ translate_genes_oa <- function( geneSet2Enrich, data ){ - # set OrgDb to organism - if(input$OrganismChoice == "hsa"){ + # translate to entrez id, currently only Humand and Mouse supported + if(par_tmp[[session$token]]['organism'] == "Human genes (GRCh38.p14)"){ orgDb <- org.Hs.eg.db::org.Hs.eg.db }else{ orgDb <- org.Mm.eg.db::org.Mm.eg.db diff --git a/program/shinyApp/server.R b/program/shinyApp/server.R index 96e904b9..d265f844 100644 --- a/program/shinyApp/server.R +++ b/program/shinyApp/server.R @@ -358,6 +358,7 @@ server <- function(input,output,session){ ## Do Upload ---- observeEvent(input$refresh1,{ par_tmp[[session$token]]['omic_type'] <<- input$omicType + par_tmp[[session$token]]['organism'] <<- input$AddGeneSymbols_organism fun_LogIt(message = "## DataInput {.tabset .tabset-fade}") fun_LogIt(message = "### Info") fun_LogIt( From 911ceb46dfe7ee391e58b0af1726a73dbbdb43ae Mon Sep 17 00:00:00 2001 From: Paul Jonas Jost <70631928+PaulJonasJost@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:07:03 +0100 Subject: [PATCH 4/4] Update program/shinyApp/R/enrichment_analysis/server.R Co-authored-by: Lea Seep <74967328+LeaSeep@users.noreply.github.com> --- program/shinyApp/R/enrichment_analysis/server.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/shinyApp/R/enrichment_analysis/server.R b/program/shinyApp/R/enrichment_analysis/server.R index b1a8bfda..0e874e7a 100644 --- a/program/shinyApp/R/enrichment_analysis/server.R +++ b/program/shinyApp/R/enrichment_analysis/server.R @@ -372,7 +372,7 @@ enrichment_analysis_Server <- function(id, data, params, updates){ ) ## Ui section output$OrganismChoice_ui <- renderText(paste0( - "The organism you chose is ",ea_reactives$organism, "." + "The organism you have chosen is ",ea_reactives$organism, "." )) output$ORA_or_GSE_ui <- renderUI({ radioButtons(