diff --git a/program/shinyApp/R/enrichment_analysis/enrichment_analysis.R b/program/shinyApp/R/enrichment_analysis/enrichment_analysis.R index 0becf147..3ffad644 100644 --- a/program/shinyApp/R/enrichment_analysis/enrichment_analysis.R +++ b/program/shinyApp/R/enrichment_analysis/enrichment_analysis.R @@ -49,7 +49,7 @@ gene_set_enrichment <- function( if(enrichments2do$KEGG){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$KEGG )) + !(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"), @@ -64,15 +64,15 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$KEGG <<- EnrichmentRes_Kegg - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$KEGG <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$KEGG <<- EnrichmentRes_Kegg + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$KEGG <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_Kegg <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$KEGG + EnrichmentRes_Kegg <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$KEGG } } if(enrichments2do$GO){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO )) + !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO )) ){ EnrichmentRes_GO <- clusterProfiler::gseGO( gene = geneSetChoice, @@ -85,16 +85,16 @@ gene_set_enrichment <- function( OrgDb = ifelse(input$OrganismChoice == "hsa","org.Hs.eg.db","org.Mm.eg.db"), pAdjustMethod = "none" # TODO: discuss ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO <<- EnrichmentRes_GO - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO <<- EnrichmentRes_GO + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_GO <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO + EnrichmentRes_GO <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO } } # Hallmarks if(enrichments2do$Hallmarks){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$Hallmarks )) + !(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"), @@ -108,16 +108,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$Hallmarks <<- EnrichmentRes_Hallmarks - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$Hallmarks <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$Hallmarks <<- EnrichmentRes_Hallmarks + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$Hallmarks <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_Hallmarks <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$Hallmarks + EnrichmentRes_Hallmarks <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$Hallmarks } } # C1 if(enrichments2do$C1){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C1 )) + !(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"), @@ -131,17 +131,17 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C1 <<- EnrichmentRes_C1 - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C1 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C1 <<- EnrichmentRes_C1 + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C1 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_C1 <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C1 + EnrichmentRes_C1 <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C1 } } # C2 if(enrichments2do$C2){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C2 )) + !(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"), @@ -155,16 +155,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C2 <<- EnrichmentRes_C2 - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C2 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C2 <<- EnrichmentRes_C2 + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C2 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_C2 <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C2 + EnrichmentRes_C2 <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C2 } } # C3 if(enrichments2do$C3){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C3 )) + !(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"), @@ -178,16 +178,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C3 <<- EnrichmentRes_C3 - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C3 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C3 <<- EnrichmentRes_C3 + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C3 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_C3 <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C3 + EnrichmentRes_C3 <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C3 } } # C4 if(enrichments2do$C4){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C4 )) + !(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"), @@ -201,16 +201,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C4 <<- EnrichmentRes_C4 - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C4 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C4 <<- EnrichmentRes_C4 + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C4 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_C4 <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C4 + EnrichmentRes_C4 <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C4 } } # C5 if(enrichments2do$C5){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C5 )) + !(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"), @@ -224,16 +224,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C5 <<- EnrichmentRes_C5 - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C5 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C5 <<- EnrichmentRes_C5 + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C5 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_C5 <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C5 + EnrichmentRes_C5 <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C5 } } # C6 if(enrichments2do$C6){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C6 )) + !(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"), @@ -247,16 +247,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C6 <<- EnrichmentRes_C6 - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C6 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C6 <<- EnrichmentRes_C6 + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C6 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_C6 <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C6 + EnrichmentRes_C6 <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C6 } } # C7 if(enrichments2do$C7){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C7 )) + !(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"), @@ -270,16 +270,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C7 <<- EnrichmentRes_C7 - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C7 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C7 <<- EnrichmentRes_C7 + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C7 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_C7 <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C7 + EnrichmentRes_C7 <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C7 } } # C8 if(enrichments2do$C8){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C8 )) + !(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"), @@ -293,16 +293,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C8 <<- EnrichmentRes_C8 - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C8 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C8 <<- EnrichmentRes_C8 + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C8 <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_C8 <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$C8 + EnrichmentRes_C8 <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$C8 } } # C2 subset CGP if(enrichments2do$CGP){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CGP )) + !(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"), @@ -317,16 +317,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CGP <<- EnrichmentRes_CGP - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CGP <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CGP <<- EnrichmentRes_CGP + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CGP <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_CGP <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CGP + EnrichmentRes_CGP <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CGP } } # C2 subset CP if(enrichments2do$CP){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CP )) + !(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"), @@ -341,16 +341,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CP <<- EnrichmentRes_CP - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CP <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CP <<- EnrichmentRes_CP + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CP <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_CP <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CP + EnrichmentRes_CP <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CP } } # C2:CP subset BIOCARTA if(enrichments2do$BIOCARTA){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$BIOCARTA )) + !(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"), @@ -365,16 +365,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$BIOCARTA <<- EnrichmentRes_BIOCARTA - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$BIOCARTA <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$BIOCARTA <<- EnrichmentRes_BIOCARTA + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$BIOCARTA <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_BIOCARTA <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$BIOCARTA + EnrichmentRes_BIOCARTA <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$BIOCARTA } } # C2:CP subset PID if(enrichments2do$PID){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$PID )) + !(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"), @@ -389,16 +389,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$PID <<- EnrichmentRes_PID - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$PID <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$PID <<- EnrichmentRes_PID + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$PID <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_PID <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$PID + EnrichmentRes_PID <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$PID } } # C2:CP subset REACTOME if(enrichments2do$REACTOME){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$REACTOME )) + !(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"), @@ -413,16 +413,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$REACTOME <<- EnrichmentRes_REACTOME - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$REACTOME <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$REACTOME <<- EnrichmentRes_REACTOME + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$REACTOME <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_REACTOME <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$REACTOME + EnrichmentRes_REACTOME <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$REACTOME } } # C2:CP subset WIKIPATHWAYS if(enrichments2do$WIKIPATHWAYS){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$WIKIPATHWAYS )) + !(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"), @@ -437,16 +437,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$WIKIPATHWAYS <<- EnrichmentRes_WIKIPATHWAYS - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$WIKIPATHWAYS <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$WIKIPATHWAYS <<- EnrichmentRes_WIKIPATHWAYS + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$WIKIPATHWAYS <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_WIKIPATHWAYS <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$WIKIPATHWAYS + EnrichmentRes_WIKIPATHWAYS <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$WIKIPATHWAYS } } # C3 subset MIR:MIRDB if(enrichments2do$MIRDB){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$MIRDB )) + !(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"), @@ -461,16 +461,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$MIRDB <<- EnrichmentRes_MIRDB - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$MIRDB <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$MIRDB <<- EnrichmentRes_MIRDB + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$MIRDB <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_MIRDB <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$MIRDB + EnrichmentRes_MIRDB <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$MIRDB } } # C3 subset MIR:MIR_Legacy if(enrichments2do$MIR_Legacy){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$MIR_Legacy )) + !(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"), @@ -485,16 +485,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$MIR_Legacy <<- EnrichmentRes_MIR_Legacy - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$MIR_Legacy <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$MIR_Legacy <<- EnrichmentRes_MIR_Legacy + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$MIR_Legacy <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_MIR_Legacy <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$MIR_Legacy + EnrichmentRes_MIR_Legacy <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$MIR_Legacy } } # C3 subset TFT:GTRD if(enrichments2do$GTRD){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GTRD )) + !(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"), @@ -509,16 +509,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GTRD <<- EnrichmentRes_GTRD - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GTRD <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GTRD <<- EnrichmentRes_GTRD + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GTRD <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_GTRD <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GTRD + EnrichmentRes_GTRD <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GTRD } } # C3 subset TFT:TFT_Legacy if(enrichments2do$TFT_Legacy){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$TFT_Legacy )) + !(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"), @@ -533,16 +533,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$TFT_Legacy <<- EnrichmentRes_TFT_Legacy - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$TFT_Legacy <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$TFT_Legacy <<- EnrichmentRes_TFT_Legacy + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$TFT_Legacy <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_TFT_Legacy <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$TFT_Legacy + EnrichmentRes_TFT_Legacy <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$TFT_Legacy } } # C4 subset CGN if(enrichments2do$CGN){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CGN )) + !(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"), @@ -557,16 +557,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CGN <<- EnrichmentRes_CGN - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CGN <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CGN <<- EnrichmentRes_CGN + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CGN <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_CGN <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CGN + EnrichmentRes_CGN <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CGN } } # C4 subset CM if(enrichments2do$CM){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CM )) + !(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"), @@ -581,16 +581,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CM <<- EnrichmentRes_CM - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CM <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CM <<- EnrichmentRes_CM + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CM <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_CM <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$CM + EnrichmentRes_CM <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$CM } } # C5 subset GO BP if(enrichments2do$GO_BP){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_BP )) + !(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"), @@ -605,16 +605,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_BP <<- EnrichmentRes_GO_BP - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_BP <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_BP <<- EnrichmentRes_GO_BP + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_BP <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_GO_BP <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_BP + EnrichmentRes_GO_BP <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_BP } } # C5 subset GO CC if(enrichments2do$GO_CC){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_CC )) + !(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"), @@ -629,16 +629,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_CC <<- EnrichmentRes_GO_CC - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_CC <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_CC <<- EnrichmentRes_GO_CC + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_CC <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_GO_CC <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_CC + EnrichmentRes_GO_CC <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_CC } } # C5 subset GO MF if(enrichments2do$GO_MF){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_MF )) + !(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"), @@ -653,16 +653,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_MF <<- EnrichmentRes_GO_MF - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_MF <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_MF <<- EnrichmentRes_GO_MF + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_MF <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_GO_MF <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$GO_MF + EnrichmentRes_GO_MF <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$GO_MF } } # C5 subset HPO if(enrichments2do$HPO){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$HPO )) + !(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"), @@ -677,16 +677,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$HPO <<- EnrichmentRes_HPO - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$HPO <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$HPO <<- EnrichmentRes_HPO + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$HPO <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_HPO <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$HPO + EnrichmentRes_HPO <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$HPO } } # C7 subset IMMUNESIGDB if(enrichments2do$IMMUNESIGDB){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$IMMUNESIGDB )) + !(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"), @@ -701,16 +701,16 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$IMMUNESIGDB <<- EnrichmentRes_IMMUNESIGDB - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$IMMUNESIGDB <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$IMMUNESIGDB <<- EnrichmentRes_IMMUNESIGDB + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$IMMUNESIGDB <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_IMMUNESIGDB <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$IMMUNESIGDB + EnrichmentRes_IMMUNESIGDB <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$IMMUNESIGDB } } # C7 subset VAX if(enrichments2do$VAX){ if( - !(identical(list("adjustMethod"=adjustMethod, "sort"=sorting),par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$VAX )) + !(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"), @@ -725,10 +725,10 @@ gene_set_enrichment <- function( pAdjustMethod = PADJUST_METHOD[[adjustMethod]], pvalueCutoff = 1 ) - res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$VAX <<- EnrichmentRes_VAX - par_tmp[[session_key]]$EA[[comp_type]][[contrast]]$VAX <<- list("adjustMethod"=adjustMethod, "sort"=sorting) + res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$VAX <<- EnrichmentRes_VAX + par_tmp[[session$token]]$EA[[comp_type]][[contrast]]$VAX <<- list("adjustMethod"=adjustMethod, "sort"=sorting) }else{ - EnrichmentRes_VAX <- res_tmp[[session_key]]$EA[[comp_type]][[contrast]]$VAX + EnrichmentRes_VAX <- res_tmp[[session$token]]$EA[[comp_type]][[contrast]]$VAX } } diff --git a/program/shinyApp/R/enrichment_analysis/overrepresentation_analysis.R b/program/shinyApp/R/enrichment_analysis/overrepresentation_analysis.R index b44aa296..1b65cacf 100644 --- a/program/shinyApp/R/enrichment_analysis/overrepresentation_analysis.R +++ b/program/shinyApp/R/enrichment_analysis/overrepresentation_analysis.R @@ -67,37 +67,37 @@ over_representation_analysis <- function( EnrichmentRes_C8 <- NULL # KEGG if(enrichments2do$KEGG){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$KEGG ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$KEGG ))){ EnrichmentRes_KEGG <- clusterProfiler::enrichKEGG( gene = geneSetChoice, organism = input$OrganismChoice, pvalueCutoff = 0.05, universe = universeSelected_tranlsated ) - res_tmp[[session_key]]$OA$KEGG <<- EnrichmentRes_KEGG - par_tmp[[session_key]]$OA$KEGG <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$KEGG <<- EnrichmentRes_KEGG + par_tmp[[session$token]]$OA$KEGG <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_KEGG <- res_tmp[[session_key]]$OA$KEGG + EnrichmentRes_KEGG <- res_tmp[[session$token]]$OA$KEGG } } # GO if(enrichments2do$GO){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$GO ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$GO ))){ EnrichmentRes_GO <- clusterProfiler::enrichGO( gene = geneSetChoice, ont = input$ontologyForGO, pvalueCutoff = 0.05, OrgDb = ifelse(input$OrganismChoice == "hsa","org.Hs.eg.db","org.Mm.eg.db") ) - res_tmp[[session_key]]$OA$GO <<- EnrichmentRes_GO - par_tmp[[session_key]]$OA$GO <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$GO <<- EnrichmentRes_GO + par_tmp[[session$token]]$OA$GO <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_GO <- res_tmp[[session_key]]$OA$GO + EnrichmentRes_GO <- res_tmp[[session$token]]$OA$GO } } # Reactome if(enrichments2do$REACTOME){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$REACTOME ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$REACTOME ))){ EnrichmentRes_REACTOME <- ReactomePA::enrichPathway( gene = geneSetChoice, pvalueCutoff = 0.05, @@ -105,15 +105,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, readable = T ) - res_tmp[[session_key]]$OA$REACTOME <<- EnrichmentRes_REACTOME - par_tmp[[session_key]]$OA$REACTOME <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$REACTOME <<- EnrichmentRes_REACTOME + par_tmp[[session$token]]$OA$REACTOME <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_REACTOME <- res_tmp[[session_key]]$OA$REACTOME + EnrichmentRes_REACTOME <- res_tmp[[session$token]]$OA$REACTOME } } # Hallmarks if(enrichments2do$Hallmarks){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$Hallmarks ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$Hallmarks ))){ Hallmarkset <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "H", @@ -125,15 +125,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = Hallmarkset ) - res_tmp[[session_key]]$OA$Hallmarks <<- EnrichmentRes_Hallmarks - par_tmp[[session_key]]$OA$Hallmarks <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$Hallmarks <<- EnrichmentRes_Hallmarks + par_tmp[[session$token]]$OA$Hallmarks <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_Hallmarks <- res_tmp[[session_key]]$OA$Hallmarks + EnrichmentRes_Hallmarks <- res_tmp[[session$token]]$OA$Hallmarks } } # C1 if(enrichments2do$C1){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$C1 ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C1 ))){ C1set <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C1", @@ -145,15 +145,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = C1set ) - res_tmp[[session_key]]$OA$C1 <<- EnrichmentRes_C1 - par_tmp[[session_key]]$OA$C1 <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$C1 <<- EnrichmentRes_C1 + par_tmp[[session$token]]$OA$C1 <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_C1 <- res_tmp[[session_key]]$OA$C1 + EnrichmentRes_C1 <- res_tmp[[session$token]]$OA$C1 } } # C2 if(enrichments2do$C2){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$C2 ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C2 ))){ C2set <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C2", @@ -165,15 +165,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = C2set ) - res_tmp[[session_key]]$OA$C2 <<- EnrichmentRes_C2 - par_tmp[[session_key]]$OA$C2 <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$C2 <<- EnrichmentRes_C2 + par_tmp[[session$token]]$OA$C2 <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_C2 <- res_tmp[[session_key]]$OA$C2 + EnrichmentRes_C2 <- res_tmp[[session$token]]$OA$C2 } } # C3 if(enrichments2do$C3){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$C3 ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C3 ))){ C3set <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C3", @@ -185,15 +185,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = C3set ) - res_tmp[[session_key]]$OA$C3 <<- EnrichmentRes_C3 - par_tmp[[session_key]]$OA$C3 <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$C3 <<- EnrichmentRes_C3 + par_tmp[[session$token]]$OA$C3 <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_C3 <- res_tmp[[session_key]]$OA$C3 + EnrichmentRes_C3 <- res_tmp[[session$token]]$OA$C3 } } # C4 if(enrichments2do$C4){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$C4 ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C4 ))){ C4set <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C4", @@ -205,15 +205,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = C4set ) - res_tmp[[session_key]]$OA$C4 <<- EnrichmentRes_C4 - par_tmp[[session_key]]$OA$C4 <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$C4 <<- EnrichmentRes_C4 + par_tmp[[session$token]]$OA$C4 <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_C4 <- res_tmp[[session_key]]$OA$C4 + EnrichmentRes_C4 <- res_tmp[[session$token]]$OA$C4 } } # C5 if(enrichments2do$C5){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$C5 ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C5 ))){ C5set <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C5", @@ -225,15 +225,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = C5set ) - res_tmp[[session_key]]$OA$C5 <<- EnrichmentRes_C5 - par_tmp[[session_key]]$OA$C5 <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$C5 <<- EnrichmentRes_C5 + par_tmp[[session$token]]$OA$C5 <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_C5 <- res_tmp[[session_key]]$OA$C5 + EnrichmentRes_C5 <- res_tmp[[session$token]]$OA$C5 } } # C6 if(enrichments2do$C6){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$C6 ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C6 ))){ C6set <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C6", @@ -245,15 +245,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = C6set ) - res_tmp[[session_key]]$OA$C6 <<- EnrichmentRes_C6 - par_tmp[[session_key]]$OA$C6 <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$C6 <<- EnrichmentRes_C6 + par_tmp[[session$token]]$OA$C6 <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_C6 <- res_tmp[[session_key]]$OA$C6 + EnrichmentRes_C6 <- res_tmp[[session$token]]$OA$C6 } } # C7 ImmuneSigDB subset if(enrichments2do$C7){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$C7 ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C7 ))){ C7set <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C7", @@ -266,15 +266,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = C7set ) - res_tmp[[session_key]]$OA$C7 <<- EnrichmentRes_C7 - par_tmp[[session_key]]$OA$C7 <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$C7 <<- EnrichmentRes_C7 + par_tmp[[session$token]]$OA$C7 <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_C7 <- res_tmp[[session_key]]$OA$C7 + EnrichmentRes_C7 <- res_tmp[[session$token]]$OA$C7 } } # C8 if(enrichments2do$C8){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$C8 ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$C8 ))){ C8set <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C8", @@ -286,15 +286,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = C8set ) - res_tmp[[session_key]]$OA$C8 <<- EnrichmentRes_C8 - par_tmp[[session_key]]$OA$C8 <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$C8 <<- EnrichmentRes_C8 + par_tmp[[session$token]]$OA$C8 <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_C8 <- res_tmp[[session_key]]$OA$C8 + EnrichmentRes_C8 <- res_tmp[[session$token]]$OA$C8 } } # C2 subset CGP if(enrichments2do$CGP){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$CGP ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$CGP ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C2", @@ -307,15 +307,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$CGP <<- EnrichmentRes_CGP - par_tmp[[session_key]]$OA$CGP <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$CGP <<- EnrichmentRes_CGP + par_tmp[[session$token]]$OA$CGP <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_CGP <- res_tmp[[session_key]]$OA$CGP + EnrichmentRes_CGP <- res_tmp[[session$token]]$OA$CGP } } # C2 subset CP if(enrichments2do$CP){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$CP ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$CP ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C2", @@ -328,15 +328,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$CP <<- EnrichmentRes_CP - par_tmp[[session_key]]$OA$CP <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$CP <<- EnrichmentRes_CP + par_tmp[[session$token]]$OA$CP <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_CP <- res_tmp[[session_key]]$OA$CP + EnrichmentRes_CP <- res_tmp[[session$token]]$OA$CP } } # C2:CP subset BIOCARTA if(enrichments2do$BIOCARTA){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$BIOCARTA ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$BIOCARTA ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C2", @@ -349,15 +349,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$BIOCARTA <<- EnrichmentRes_BIOCARTA - par_tmp[[session_key]]$OA$BIOCARTA <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$BIOCARTA <<- EnrichmentRes_BIOCARTA + par_tmp[[session$token]]$OA$BIOCARTA <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_BIOCARTA <- res_tmp[[session_key]]$OA$BIOCARTA + EnrichmentRes_BIOCARTA <- res_tmp[[session$token]]$OA$BIOCARTA } } # C2:CP subset PID if(enrichments2do$PID){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$PID ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$PID ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C2", @@ -370,15 +370,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$PID <<- EnrichmentRes_PID - par_tmp[[session_key]]$OA$PID <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$PID <<- EnrichmentRes_PID + par_tmp[[session$token]]$OA$PID <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_PID <- res_tmp[[session_key]]$OA$PID + EnrichmentRes_PID <- res_tmp[[session$token]]$OA$PID } } # C2:CP subset REACTOME if(enrichments2do$REACTOME){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$REACTOME ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$REACTOME ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C2", @@ -391,15 +391,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$REACTOME <<- EnrichmentRes_REACTOME - par_tmp[[session_key]]$OA$REACTOME <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$REACTOME <<- EnrichmentRes_REACTOME + par_tmp[[session$token]]$OA$REACTOME <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_REACTOME <- res_tmp[[session_key]]$OA$REACTOME + EnrichmentRes_REACTOME <- res_tmp[[session$token]]$OA$REACTOME } } # C2:CP subset WIKIPATHWAYS if(enrichments2do$WIKIPATHWAYS){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$WIKIPATHWAYS ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$WIKIPATHWAYS ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C2", @@ -412,15 +412,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$WIKIPATHWAYS <<- EnrichmentRes_WIKIPATHWAYS - par_tmp[[session_key]]$OA$WIKIPATHWAYS <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$WIKIPATHWAYS <<- EnrichmentRes_WIKIPATHWAYS + par_tmp[[session$token]]$OA$WIKIPATHWAYS <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_WIKIPATHWAYS <- res_tmp[[session_key]]$OA$WIKIPATHWAYS + EnrichmentRes_WIKIPATHWAYS <- res_tmp[[session$token]]$OA$WIKIPATHWAYS } } # C3 subset MIR:MIRDB if(enrichments2do$MIRDB){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$MIRDB ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$MIRDB ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C3", @@ -433,15 +433,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$MIRDB <<- EnrichmentRes_MIRDB - par_tmp[[session_key]]$OA$MIRDB <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$MIRDB <<- EnrichmentRes_MIRDB + par_tmp[[session$token]]$OA$MIRDB <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_MIRDB <- res_tmp[[session_key]]$OA$MIRDB + EnrichmentRes_MIRDB <- res_tmp[[session$token]]$OA$MIRDB } } # C3 subset MIR:MIR_Legacy if(enrichments2do$MIR_Legacy){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$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"), category = "C3", @@ -454,15 +454,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$MIR_Legacy <<- EnrichmentRes_MIR_Legacy - par_tmp[[session_key]]$OA$MIR_Legacy <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$MIR_Legacy <<- EnrichmentRes_MIR_Legacy + par_tmp[[session$token]]$OA$MIR_Legacy <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_MIR_Legacy <- res_tmp[[session_key]]$OA$MIR_Legacy + EnrichmentRes_MIR_Legacy <- res_tmp[[session$token]]$OA$MIR_Legacy } } # C3 subset TFT:GTRD if(enrichments2do$GTRD){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$GTRD ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$GTRD ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C3", @@ -475,15 +475,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$GTRD <<- EnrichmentRes_GTRD - par_tmp[[session_key]]$OA$GTRD <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$GTRD <<- EnrichmentRes_GTRD + par_tmp[[session$token]]$OA$GTRD <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_GTRD <- res_tmp[[session_key]]$OA$GTRD + EnrichmentRes_GTRD <- res_tmp[[session$token]]$OA$GTRD } } # C3 subset TFT:TFT_Legacy if(enrichments2do$TFT_Legacy){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$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"), category = "C3", @@ -496,15 +496,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$TFT_Legacy <<- EnrichmentRes_TFT_Legacy - par_tmp[[session_key]]$OA$TFT_Legacy <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$TFT_Legacy <<- EnrichmentRes_TFT_Legacy + par_tmp[[session$token]]$OA$TFT_Legacy <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_TFT_Legacy <- res_tmp[[session_key]]$OA$TFT_Legacy + EnrichmentRes_TFT_Legacy <- res_tmp[[session$token]]$OA$TFT_Legacy } } # C4 subset CGN if(enrichments2do$CGN){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$CGN ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$CGN ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C4", @@ -517,15 +517,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$CGN <<- EnrichmentRes_CGN - par_tmp[[session_key]]$OA$CGN <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$CGN <<- EnrichmentRes_CGN + par_tmp[[session$token]]$OA$CGN <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_CGN <- res_tmp[[session_key]]$OA$CGN + EnrichmentRes_CGN <- res_tmp[[session$token]]$OA$CGN } } # C4 subset CM if(enrichments2do$CM){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$CM ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$CM ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C4", @@ -538,15 +538,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$CM <<- EnrichmentRes_CM - par_tmp[[session_key]]$OA$CM <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$CM <<- EnrichmentRes_CM + par_tmp[[session$token]]$OA$CM <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_CM <- res_tmp[[session_key]]$OA$CM + EnrichmentRes_CM <- res_tmp[[session$token]]$OA$CM } } # C5 subset GO BP if(enrichments2do$GO_BP){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$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"), category = "C5", @@ -559,15 +559,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$GO_BP <<- EnrichmentRes_GO_BP - par_tmp[[session_key]]$OA$GO_BP <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$GO_BP <<- EnrichmentRes_GO_BP + par_tmp[[session$token]]$OA$GO_BP <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_GO_BP <- res_tmp[[session_key]]$OA$GO_BP + EnrichmentRes_GO_BP <- res_tmp[[session$token]]$OA$GO_BP } } # C5 subset GO CC if(enrichments2do$GO_CC){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$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"), category = "C5", @@ -580,15 +580,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$GO_CC <<- EnrichmentRes_GO_CC - par_tmp[[session_key]]$OA$GO_CC <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$GO_CC <<- EnrichmentRes_GO_CC + par_tmp[[session$token]]$OA$GO_CC <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_GO_CC <- res_tmp[[session_key]]$OA$GO_CC + EnrichmentRes_GO_CC <- res_tmp[[session$token]]$OA$GO_CC } } # C5 subset GO MF if(enrichments2do$GO_MF){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$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"), category = "C5", @@ -601,15 +601,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$GO_MF <<- EnrichmentRes_GO_MF - par_tmp[[session_key]]$OA$GO_MF <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$GO_MF <<- EnrichmentRes_GO_MF + par_tmp[[session$token]]$OA$GO_MF <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_GO_MF <- res_tmp[[session_key]]$OA$GO_MF + EnrichmentRes_GO_MF <- res_tmp[[session$token]]$OA$GO_MF } } # C5 subset HPO if(enrichments2do$HPO){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$HPO ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$HPO ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C5", @@ -622,15 +622,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$HPO <<- EnrichmentRes_HPO - par_tmp[[session_key]]$OA$HPO <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$HPO <<- EnrichmentRes_HPO + par_tmp[[session$token]]$OA$HPO <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_HPO <- res_tmp[[session_key]]$OA$HPO + EnrichmentRes_HPO <- res_tmp[[session$token]]$OA$HPO } } # C7 subset IMMUNESIGDB if(enrichments2do$IMMUNESIGDB){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$IMMUNESIGDB ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$IMMUNESIGDB ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C7", @@ -643,15 +643,15 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$IMMUNESIGDB <<- EnrichmentRes_IMMUNESIGDB - par_tmp[[session_key]]$OA$IMMUNESIGDB <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$IMMUNESIGDB <<- EnrichmentRes_IMMUNESIGDB + par_tmp[[session$token]]$OA$IMMUNESIGDB <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_IMMUNESIGDB <- res_tmp[[session_key]]$OA$IMMUNESIGDB + EnrichmentRes_IMMUNESIGDB <- res_tmp[[session$token]]$OA$IMMUNESIGDB } } # C7 subset VAX if(enrichments2do$VAX){ - if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session_key]]$OA$VAX ))){ + if(!(identical(list("Universe"=input$UniverseOfGene),par_tmp[[session$token]]$OA$VAX ))){ genesets4ea <- msigdbr( species = ifelse(input$OrganismChoice == "hsa","Homo sapiens","Mus musculus"), category = "C7", @@ -664,10 +664,10 @@ over_representation_analysis <- function( universe = universeSelected_tranlsated, TERM2GENE = genesets4ea ) - res_tmp[[session_key]]$OA$VAX <<- EnrichmentRes_VAX - par_tmp[[session_key]]$OA$VAX <<- list("Universe"=input$UniverseOfGene) + res_tmp[[session$token]]$OA$VAX <<- EnrichmentRes_VAX + par_tmp[[session$token]]$OA$VAX <<- list("Universe"=input$UniverseOfGene) }else{ - EnrichmentRes_VAX <- res_tmp[[session_key]]$OA$VAX + EnrichmentRes_VAX <- res_tmp[[session$token]]$OA$VAX } } diff --git a/program/shinyApp/R/enrichment_analysis/server.R b/program/shinyApp/R/enrichment_analysis/server.R index bc91fa91..c57e2c35 100644 --- a/program/shinyApp/R/enrichment_analysis/server.R +++ b/program/shinyApp/R/enrichment_analysis/server.R @@ -791,9 +791,9 @@ enrichment_analysis_Server <- function(id, data, params, updates){ } ea_reactives$ea_info <- "**Enrichment Analysis Done!**" # res_temp Zuweisung - res_tmp[[session_key]]["Enrichment"] <<- ea_reactives$enrichment_results + res_tmp[[session$token]]["Enrichment"] <<- ea_reactives$enrichment_results # par_temp Zuweisung - par_tmp[[session_key]]["Enrichment"] <<- list( + par_tmp[[session$token]]["Enrichment"] <<- list( "ValueToAttach" = input$ValueToAttach, "GeneSet2Enrich" = input$GeneSet2Enrich, "Groups2Compare_ref_GSEA" = input$Groups2Compare_ref_GSEA, diff --git a/program/shinyApp/R/heatmap/server.R b/program/shinyApp/R/heatmap/server.R index c13816ce..2f43a592 100644 --- a/program/shinyApp/R/heatmap/server.R +++ b/program/shinyApp/R/heatmap/server.R @@ -219,10 +219,9 @@ heatmap_server <- function(id, data, params, updates){ input$anno_options, input$row_label_options ) - browser() req(selectedData_processed()) # update the data if needed - data <- update_data(data, session_key) + data <- update_data(session$token) heatmap_reactives$current_updates <- updates() print("Heatmap on selected Data") # Value need to be setted in case there is nothing to plot to avoid crash @@ -363,7 +362,6 @@ heatmap_server <- function(id, data, params, updates){ } if(calculate == 1){ if(input$LFC_toHeatmap){ - browser() ctrl_samples_idx <- which( colData(data$data)[,input$sample_annotation_types_cmp_heatmap]%in%input$Groups2Compare_ref_heatmap ) @@ -375,7 +373,7 @@ heatmap_server <- function(id, data, params, updates){ output$Options_selected_out_3 <- renderText("Choose variable with at least two samples per condition!") doThis_flag <- F } - if(par_tmp[[session_key]]$PreProcessing_Procedure == "simpleCenterScaling"| + if(par_tmp[[session$token]]$PreProcessing_Procedure == "simpleCenterScaling"| any(assay(data$data))< 0){ print("Remember do not use normal center + scaling (negative Values!)") @@ -456,15 +454,15 @@ heatmap_server <- function(id, data, params, updates){ } else { print("Plotting saved result") if(input$LFC_toHeatmap){ - myBreaks <- c(seq(min(res_tmp[[session_key]]$Heatmap$LFC), 0, length.out=ceiling(paletteLength/2) + 1), - seq(max(res_tmp[[session_key]]$Heatmap$LFC)/paletteLength, max(res_tmp[[session_key]]$Heatmap$LFC), length.out=floor(paletteLength/2))) + myBreaks <- c(seq(min(res_tmp[[session$token]]$Heatmap$LFC), 0, length.out=ceiling(paletteLength/2) + 1), + seq(max(res_tmp[[session$token]]$Heatmap$LFC)/paletteLength, max(res_tmp[[session$token]]$Heatmap$LFC), length.out=floor(paletteLength/2))) annotation_col <- rowData(data2Plot)[,input$row_anno_options,drop=F] scenario <- 10 heatmap_plot <- pheatmap( - t(res_tmp[[session_key]]$Heatmap[,"LFC",drop=F]), + t(res_tmp[[session$token]]$Heatmap[,"LFC",drop=F]), main = gsub("^Heatmap","Heatmap_LFC",customTitleHeatmap), - show_rownames = ifelse(nrow(res_tmp[[session_key]]$Heatmap)<=25,TRUE,FALSE), + show_rownames = ifelse(nrow(res_tmp[[session$token]]$Heatmap)<=25,TRUE,FALSE), show_colnames = TRUE, cluster_cols = input$cluster_cols, cluster_rows = FALSE, @@ -475,12 +473,12 @@ heatmap_server <- function(id, data, params, updates){ color = myColor_fill ) } else { - clusterRowspossible <- ifelse(nrow(as.matrix(res_tmp[[session_key]]$Heatmap))>1,input$cluster_rows,F) - if(any(is.na(res_tmp[[session_key]]$Heatmap))){ - idx_of_nas <- which(apply(res_tmp[[session_key]]$Heatmap,1,is.na)) # why do we produce Nas? + clusterRowspossible <- ifelse(nrow(as.matrix(res_tmp[[session$token]]$Heatmap))>1,input$cluster_rows,F) + if(any(is.na(res_tmp[[session$token]]$Heatmap))){ + idx_of_nas <- which(apply(res_tmp[[session$token]]$Heatmap,1,is.na)) # why do we produce Nas? print(idx_of_nas) if(length(idx_of_nas)>0){ - res_tmp[[session_key]]$Heatmap <- res_tmp[[session_key]]$Heatmap[-idx_of_nas,] + res_tmp[[session$token]]$Heatmap <- res_tmp[[session$token]]$Heatmap[-idx_of_nas,] } annotation_col <- colData(data$data)[-idx_of_nas,input$anno_options,drop=F] @@ -497,9 +495,9 @@ heatmap_server <- function(id, data, params, updates){ } scenario <- 11 heatmap_plot <- pheatmap( - as.matrix(res_tmp[[session_key]]$Heatmap), + as.matrix(res_tmp[[session$token]]$Heatmap), main = customTitleHeatmap, - show_rownames = ifelse(nrow(res_tmp[[session_key]]$Heatmap)<=input$row_label_no,TRUE,FALSE), + show_rownames = ifelse(nrow(res_tmp[[session$token]]$Heatmap)<=input$row_label_no,TRUE,FALSE), labels_row = rowData(data$data)[rownames(data2HandOver),input$row_label_options], show_colnames = TRUE, cluster_cols = input$cluster_cols, @@ -534,26 +532,27 @@ heatmap_server <- function(id, data, params, updates){ # Heatmap_Groups2Compare_ctrl_heatmap <- input$Groups2Compare_ctrl_heatmap - # res_tmp[[session_key]] gets data2HandOver or Data2Plot depending on scenario + # res_tmp[[session$token]] gets data2HandOver or Data2Plot depending on scenario if(scenario == 10){ - res_tmp[[session_key]][["Heatmap"]] <<- Data2Plot + res_tmp[[session$token]][["Heatmap"]] <<- Data2Plot }else if(scenario == 11){ - res_tmp[[session_key]][["Heatmap"]] <<- data2HandOver + res_tmp[[session$token]][["Heatmap"]] <<- data2HandOver } - # par_tmp[[session_key]] gets the parameters used for the heatmap + # par_tmp[[session$token]] gets the parameters used for the heatmap ## This exports all reactive Values in the PCA namespace tmp <- getUserReactiveValues(input) - par_tmp[[session_key]]$Heatmap[names(tmp)] <<- tmp + par_tmp[[session$token]]$Heatmap[names(tmp)] <<- tmp output$getR_Code_Heatmap <- downloadHandler( filename = function(){ - paste("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip", sep = "") + paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ - envList<-list( - res_tmp[[session_key]]=res_tmp[[session_key]], - par_tmp[[session_key]]=par_tmp[[session_key]] + # TODO: I think these are the completely wrong objects to save here. Needs Check! + envList <- list( + res_tmp = res_tmp[[session$token]], + par_tmp = par_tmp[[session$token]] ) temp_directory <- file.path(tempdir(), as.integer(Sys.time())) @@ -574,8 +573,8 @@ heatmap_server <- function(id, data, params, updates){ ) output$SavePlot_Heatmap <- downloadHandler( - filename = function() { - paste(Heatmap_customTitleHeatmap, " ",Sys.time(),input$file_ext_Heatmap,sep="") + filename = function() { + paste0(Heatmap_customTitleHeatmap, " ", Sys.time(), input$file_ext_Heatmap) }, content = function(file){ save_pheatmap(heatmap_plot,filename=file,type=gsub("\\.","",input$file_ext_Heatmap)) @@ -583,7 +582,7 @@ heatmap_server <- function(id, data, params, updates){ tmp_filename <- paste0( getwd(), "/www/", - paste(paste(Heatmap_customTitleHeatmap, " ",Sys.time(),input$file_ext_Heatmap,sep="")) + paste0(Heatmap_customTitleHeatmap, " ", Sys.time(), input$file_ext_Heatmap) ) save_pheatmap( heatmap_plot, @@ -622,8 +621,8 @@ heatmap_server <- function(id, data, params, updates){ ) output$SaveGeneList_Heatmap <- downloadHandler( - filename = function() { - paste("GeneList_",customTitleHeatmap, " ",Sys.time(),".csv",sep="") + filename = function() { + paste0("GeneList_", customTitleHeatmap, " ", Sys.time(), ".csv") }, content = function(file){ diff --git a/program/shinyApp/R/pca/server.R b/program/shinyApp/R/pca/server.R index 71a2a68c..97365ebc 100644 --- a/program/shinyApp/R/pca/server.R +++ b/program/shinyApp/R/pca/server.R @@ -150,7 +150,7 @@ pca_Server <- function(id, data, params, row_select, updates){ dummy = "dummy", sample_selection_pca = input$sample_selection_pca, SampleAnnotationTypes_pca = input$SampleAnnotationTypes_pca - ), "PCA", session_key) + ), "PCA") if (check == "No Result yet"){ output$PCA_Info <- renderText("PCA computed.") pca_reactives$calculate <- 1 @@ -188,7 +188,7 @@ pca_Server <- function(id, data, params, row_select, updates){ if(pca_reactives$calculate >= 0){ # update the data if needed # TODO check if the follwoing still needed as update is now done on 1st server level - data2plot <- update_data(data, session_key) + data2plot <- update_data(session$token) # select the neccesary data if(input$data_selection_pca){ data2plot <- select_data( @@ -320,9 +320,9 @@ pca_Server <- function(id, data, params, row_select, updates){ pca_reactives$df_loadings <- df_loadings # assign res_temp - res_tmp[[session_key]][["PCA"]] <<- list(pca) + res_tmp[[session$token]][["PCA"]] <<- list(pca) # assign par_temp as empty list - par_tmp[[session_key]][["PCA"]] <<- list( + par_tmp[[session$token]][["PCA"]] <<- list( # add a dummy parameter to avoid error dummy = "dummy", sample_selection_pca = input$sample_selection_pca, diff --git a/program/shinyApp/R/pca/util.R b/program/shinyApp/R/pca/util.R index 23135161..8fa4719d 100644 --- a/program/shinyApp/R/pca/util.R +++ b/program/shinyApp/R/pca/util.R @@ -1,9 +1,9 @@ -check_calculations <- function(current_parameters, module, session_key){ - if (is.null(res_tmp[[session_key]][[module]])){ # chec whether result is existent +check_calculations <- function(current_parameters, module){ + if (is.null(res_tmp[[session$token]][[module]])){ # chec whether result is existent return("No Result yet") } # check whether all parameters are identical to the current existing result - if (identical(par_tmp[[session_key]][[module]], current_parameters)){ + if (identical(par_tmp[[session$token]][[module]], current_parameters)){ return("Result exists") } # The remaining case is an existing result with other parameters, diff --git a/program/shinyApp/R/sample_correlation/server.R b/program/shinyApp/R/sample_correlation/server.R index 4212398f..b0d7e616 100644 --- a/program/shinyApp/R/sample_correlation/server.R +++ b/program/shinyApp/R/sample_correlation/server.R @@ -40,7 +40,7 @@ sample_correlation_server <- function(id, data, params, updates){ if(sample_corr_reactive$calculate == 1){ # update the data if needed - data <- update_data(data, session_key) + data <- update_data(session$token) sample_corr_reactive$current_updates <- updates() # set the counter to 0 to prevent any further plotting sample_corr_reactive$calculate <- 0 @@ -53,10 +53,10 @@ sample_correlation_server <- function(id, data, params, updates){ data_info = list( rows = length(rownames(data$data)), cols = length(colnames(data$data)), - preprocessing = par_tmp[[session_key]]$PreProcessing_Procedure + preprocessing = par_tmp[[session$token]]$PreProcessing_Procedure ) ), - "SampleCorrelation", session_key + "SampleCorrelation" ) if (check == "No Result yet"){ output$SampleCorr_Info <- renderText( @@ -70,7 +70,7 @@ sample_correlation_server <- function(id, data, params, updates){ output$SampleCorr_Info <- renderText( "Correlation Matrix was already computed, no need to click the Button again." ) - cormat <- res_tmp[[session_key]]$SampleCorrelation + cormat <- res_tmp[[session$token]]$SampleCorrelation } else if (check == "Overwrite"){ output$SampleCorr_Info <- renderText( "Correlation Matrix result overwritten with different parameters." @@ -122,14 +122,14 @@ sample_correlation_server <- function(id, data, params, updates){ annotation_colors = anno_colors ) # assign res_temp["SampleCorrelation"] - res_tmp[[session_key]][["SampleCorrelation"]] <<- cormat + res_tmp[[session$token]][["SampleCorrelation"]] <<- cormat # assign par_temp["SampleCorrelation"] - par_tmp[[session_key]][["SampleCorrelation"]] <<- list( + par_tmp[[session$token]][["SampleCorrelation"]] <<- list( corrMethod = input$corrMethod, data_info = list( rows = length(rownames(data$data)), cols = length(colnames(data$data)), - preprocessing = par_tmp[[session_key]]$PreProcessing_Procedure + preprocessing = par_tmp[[session$token]]$PreProcessing_Procedure ) ) @@ -141,7 +141,7 @@ sample_correlation_server <- function(id, data, params, updates){ customTitleSampleCorrelation <- "SampleCorrelation" } - par_tmp[[session_key]][["SampleCorr"]] <<- list( + par_tmp[[session$token]][["SampleCorr"]] <<- list( customTitleSampleCorrelation = customTitleSampleCorrelation, SampleCorrelationPlot_final = SampleCorrelationPlot_final, cormat = cormat, @@ -161,16 +161,16 @@ sample_correlation_server <- function(id, data, params, updates){ }, content = function(file){ envList = list( - cormat = ifelse(exists("cormat"),par_tmp[[session_key]][["SampleCorr"]]$cormat,NA), - annotationDF = ifelse(exists("annotationDF"),par_tmp[[session_key]][["SampleCorr"]]$annotationDF,NA), - customTitleSampleCorrelation = ifelse(exists("customTitleSampleCorrelation"),par_tmp[[session_key]][["SampleCorr"]]$customTitleSampleCorrelation,NA), - anno_colors = ifelse(exists("anno_colors"),par_tmp[[session_key]][["SampleCorr"]]$anno_colors,NA) + cormat = ifelse(exists("cormat"),par_tmp[[session$token]][["SampleCorr"]]$cormat,NA), + annotationDF = ifelse(exists("annotationDF"),par_tmp[[session$token]][["SampleCorr"]]$annotationDF,NA), + customTitleSampleCorrelation = ifelse(exists("customTitleSampleCorrelation"),par_tmp[[session$token]][["SampleCorr"]]$customTitleSampleCorrelation,NA), + anno_colors = ifelse(exists("anno_colors"),par_tmp[[session$token]][["SampleCorr"]]$anno_colors,NA) ) temp_directory <- file.path(tempdir(), as.integer(Sys.time())) dir.create(temp_directory) - write(getPlotCode(par_tmp[[session_key]][["SampleCorr"]]$sampleCorrelation_scenario), file.path(temp_directory, "Code.R")) + write(getPlotCode(par_tmp[[session$token]][["SampleCorr"]]$sampleCorrelation_scenario), file.path(temp_directory, "Code.R")) saveRDS(envList, file.path(temp_directory, "Data.RDS")) zip::zip( @@ -184,18 +184,18 @@ sample_correlation_server <- function(id, data, params, updates){ output$SavePlot_SampleCorrelation <- downloadHandler( filename = function() { - paste(par_tmp[[session_key]][["SampleCorr"]]$customTitleSampleCorrelation,Sys.time(),input$file_ext_Heatmap,sep = "") + paste(par_tmp[[session$token]][["SampleCorr"]]$customTitleSampleCorrelation,Sys.time(),input$file_ext_Heatmap,sep = "") }, content = function(file){ - save_pheatmap(par_tmp[[session_key]][["SampleCorr"]]$SampleCorrelationPlot_final,filename = file,type=gsub("\\.","",input$file_ext_SampleCorrelation)) + save_pheatmap(par_tmp[[session$token]][["SampleCorr"]]$SampleCorrelationPlot_final,filename = file,type=gsub("\\.","",input$file_ext_SampleCorrelation)) on.exit({ tmp_filename <- paste0( getwd(), "/www/", - paste(paste(par_tmp[[session_key]][["SampleCorr"]]$customTitleSampleCorrelation,Sys.time(),input$file_ext_SampleCorrelation,sep = "")) + paste(paste(par_tmp[[session$token]][["SampleCorr"]]$customTitleSampleCorrelation,Sys.time(),input$file_ext_SampleCorrelation,sep = "")) ) save_pheatmap( - par_tmp[[session_key]][["SampleCorr"]]$SampleCorrelationPlot_final, + par_tmp[[session$token]][["SampleCorr"]]$SampleCorrelationPlot_final, filename = tmp_filename, type = gsub("\\.","",input$file_ext_SampleCorrelation) ) @@ -216,11 +216,11 @@ sample_correlation_server <- function(id, data, params, updates){ tmp_filename <- paste0( getwd(), "/www/", - paste(paste(par_tmp[[session_key]][["SampleCorr"]]$customTitleSampleCorrelation,Sys.time(),".png",sep = "")) + paste(paste(par_tmp[[session$token]][["SampleCorr"]]$customTitleSampleCorrelation,Sys.time(),".png",sep = "")) ) save_pheatmap( - par_tmp[[session_key]][["SampleCorr"]]$SampleCorrelationPlot_final, + par_tmp[[session$token]][["SampleCorr"]]$SampleCorrelationPlot_final, filename = tmp_filename, type = "png" ) diff --git a/program/shinyApp/R/significance_analysis/server.R b/program/shinyApp/R/significance_analysis/server.R index 1622c0a9..c9364996 100644 --- a/program/shinyApp/R/significance_analysis/server.R +++ b/program/shinyApp/R/significance_analysis/server.R @@ -181,8 +181,8 @@ significance_analysis_server <- function(id, data, params, updates){ ) # refresh the UI/data if needed observeEvent(input$refreshUI, { - data <- update_data(data, session_key) - params <- update_params(params, session_key) + data <- update_data(session$token) + params <- update_params(session$token) sig_ana_reactive$current_updates <- updates() sig_ana_reactive$coldata <- colData(data$data) }) @@ -201,7 +201,7 @@ significance_analysis_server <- function(id, data, params, updates){ } print("Start the Significance Analysis") # update the data if needed - data <- update_data(data, session_key) + data <- update_data(session$token) sig_ana_reactive$current_updates <- updates() sig_ana_reactive$coldata <- colData(data$data) # delete old panels @@ -229,10 +229,10 @@ significance_analysis_server <- function(id, data, params, updates){ for (i in 1:length(contrasts)) { if(identical( list(test_method = "Wald", test_correction = PADJUST_METHOD[[input$test_correction]]), - par_tmp[[session_key]]$SigAna[[input$sample_annotation_types_cmp]][[input$comparisons[i]]] + par_tmp[[session$token]]$SigAna[[input$sample_annotation_types_cmp]][[input$comparisons[i]]] )){ print("Results exists, skipping calculations.") - sig_results[[input$comparisons[i]]] <<- res_tmp[[session_key]]$SigAna[[input$sample_annotation_types_cmp]][[input$comparisons[i]]] + sig_results[[input$comparisons[i]]] <<- res_tmp[[session$token]]$SigAna[[input$sample_annotation_types_cmp]][[input$comparisons[i]]] next } sig_results[[input$comparisons[i]]] <<- DESeq2::results( @@ -244,9 +244,9 @@ significance_analysis_server <- function(id, data, params, updates){ ), pAdjustMethod = PADJUST_METHOD[[input$test_correction]] ) - # fill in res_tmp[[session_key]], par_tmp[[session_key]] - res_tmp[[session_key]]$SigAna[[input$sample_annotation_types_cmp]][[input$comparisons[i]]] <<- sig_results[[input$comparisons[i]]] - par_tmp[[session_key]]$SigAna[[input$sample_annotation_types_cmp]][[input$comparisons[i]]] <<- list( + # fill in res_tmp[[session$token]], par_tmp[[session$token]] + res_tmp[[session$token]]$SigAna[[input$sample_annotation_types_cmp]][[input$comparisons[i]]] <<- sig_results[[input$comparisons[i]]] + par_tmp[[session$token]]$SigAna[[input$sample_annotation_types_cmp]][[input$comparisons[i]]] <<- list( test_method = "Wald", test_correction = PADJUST_METHOD[[input$test_correction]] ) diff --git a/program/shinyApp/R/significance_analysis/util.R b/program/shinyApp/R/significance_analysis/util.R index 913b4427..9567073f 100644 --- a/program/shinyApp/R/significance_analysis/util.R +++ b/program/shinyApp/R/significance_analysis/util.R @@ -811,10 +811,10 @@ significance_analysis <- function( # skip if already there if(identical( list(test_method = method, test_correction = correction), - par_tmp[[session_key]]$SigAna[[contrast_level]][[names(contrasts)[comp_name]]] + par_tmp[[session$token]]$SigAna[[contrast_level]][[names(contrasts)[comp_name]]] )){ print("Results exists, skipping calculations.") - sig_results[[names(contrasts)[comp_name]]] <- res_tmp[[session_key]]$SigAna[[contrast_level]][[names(contrasts)[comp_name]]] + sig_results[[names(contrasts)[comp_name]]] <- res_tmp[[session$token]]$SigAna[[contrast_level]][[names(contrasts)[comp_name]]] comp_name <- comp_name + 1 next } @@ -850,9 +850,9 @@ significance_analysis <- function( sig_results[[names(contrasts)[comp_name]]] <- res - # fill res_tmp[[session_key]], par_tmp[[session_key]] - res_tmp[[session_key]]$SigAna[[contrast_level]][[names(contrasts)[comp_name]]] <<- res - par_tmp[[session_key]]$SigAna[[contrast_level]][[names(contrasts)[comp_name]]] <<- list( + # fill res_tmp[[session$token]], par_tmp[[session$token]] + res_tmp[[session$token]]$SigAna[[contrast_level]][[names(contrasts)[comp_name]]] <<- res + par_tmp[[session$token]]$SigAna[[contrast_level]][[names(contrasts)[comp_name]]] <<- list( test_method = method, test_correction = correction ) @@ -925,9 +925,9 @@ getLFC <- function(means){ ) return (df$LFC) } - if(par_tmp[[session_key]]$PreProcessing_Procedure == "log10"){ + if(par_tmp[[session$token]]$PreProcessing_Procedure == "log10"){ lfc_per_gene_log(means, log_base = 10) - }else if(par_tmp[[session_key]]$PreProcessing_Procedure == "ln"){ + }else if(par_tmp[[session$token]]$PreProcessing_Procedure == "ln"){ lfc_per_gene_log(means, log_base = exp(1)) }else{ lfc_per_gene(means) diff --git a/program/shinyApp/R/single_gene_visualisation/server.R b/program/shinyApp/R/single_gene_visualisation/server.R index 64d43d5e..40d0b418 100644 --- a/program/shinyApp/R/single_gene_visualisation/server.R +++ b/program/shinyApp/R/single_gene_visualisation/server.R @@ -16,8 +16,8 @@ single_gene_visualisation_server <- function(id, data, params, updates){ # Refresh UI /Data observeEvent(input$refreshUI,{ print("Refresh UI Single Gene") - data <- update_data(data, session_key) - params <- update_params(params, session_key) + data <- update_data(session$token) + params <- update_params(session$token) single_Gene_vis$current_updates <- updates() ## Ui section ---- @@ -129,7 +129,7 @@ single_gene_visualisation_server <- function(id, data, params, updates){ print(input$Select_Gene) if(single_Gene_vis$calculate == 1){ # update the data if needed - data <- update_data(data, session_key) + data <- update_data(session$token) single_Gene_vis$current_updates <- updates() # set the counter to 0 to prevent any further plotting single_Gene_vis$calculate <- 0 @@ -254,11 +254,11 @@ single_gene_visualisation_server <- function(id, data, params, updates){ } # Where to save the plot (needed currently to be global, to be able to be saved) - res_tmp[[session_key]][["SingleEntVis"]] <<- P_boxplots + res_tmp[[session$token]][["SingleEntVis"]] <<- P_boxplots #SingleEnt_P_boxplots <- P_boxplots - # DO not know if necassary to track in par_tmp[[session_key]] (if not global var needed) - par_tmp[[session_key]][["SingleEntVis"]] <<- list( + # DO not know if necassary to track in par_tmp[[session$token]] (if not global var needed) + par_tmp[[session$token]][["SingleEntVis"]] <<- list( SingleEnt_customTitle_boxplot = SingleEnt_customTitle_boxplot, SingleEnt_Select_Gene = input$Select_Gene, SingleEnt_type_of_data_gene = input$type_of_data_gene, @@ -306,7 +306,7 @@ single_gene_visualisation_server <- function(id, data, params, updates){ output$SavePlot_singleGene <- downloadHandler( filename = function() { paste( - par_tmp[[session_key]]$SingleEntVis$SingleEnt_customTitle_boxplot, + par_tmp[[session$token]]$SingleEntVis$SingleEnt_customTitle_boxplot, " ", Sys.time(), input$file_ext_singleGene,sep="" @@ -316,7 +316,7 @@ single_gene_visualisation_server <- function(id, data, params, updates){ content = function(file){ ggsave( file = file, - plot = res_tmp[[session_key]]$SingleEntVis, + plot = res_tmp[[session$token]]$SingleEntVis, device = gsub("\\.","",input$file_ext_singleGene) ) @@ -325,14 +325,14 @@ single_gene_visualisation_server <- function(id, data, params, updates){ getwd(), "/www/", paste( - par_tmp[[session_key]]$SingleEntVis$SingleEnt_customTitle_boxplot, + par_tmp[[session$token]]$SingleEntVis$SingleEnt_customTitle_boxplot, " ", Sys.time(), input$file_ext_singleGene,sep="") ) ggsave( filename = tmp_filename, - plot = res_tmp[[session_key]]$SingleEntVis, + plot = res_tmp[[session$token]]$SingleEntVis, device = gsub("\\.","",input$file_ext_singleGene) ) fun_LogIt("## Single Entitie") @@ -360,7 +360,7 @@ single_gene_visualisation_server <- function(id, data, params, updates){ getwd(), "/www/", paste( - par_tmp[[session_key]]$SingleEntVis$SingleEnt_customTitle_boxplot, + par_tmp[[session$token]]$SingleEntVis$SingleEnt_customTitle_boxplot, " ", Sys.time(), ".png", @@ -368,27 +368,27 @@ single_gene_visualisation_server <- function(id, data, params, updates){ ) ggsave( filename = tmp_filename, - plot = res_tmp[[session_key]]$SingleEntVis, + plot = res_tmp[[session$token]]$SingleEntVis, device = "png" ) fun_LogIt(message = "## Single Entitie") fun_LogIt(message = paste0( "**Single Entitie** - The following single entitie was plotted: ", - par_tmp[[session_key]]$SingleEntVis$SingleEnt_Select_Gene)) + par_tmp[[session$token]]$SingleEntVis$SingleEnt_Select_Gene)) fun_LogIt(message = paste0( "**Single Entitie** - Values shown are: ", - par_tmp[[session_key]]$SingleEntVis$SingleEnt_type_of_data_gene, " data input")) + par_tmp[[session$token]]$SingleEntVis$SingleEnt_type_of_data_gene, " data input")) fun_LogIt(message = paste0( "**Single Entitie** - Values are grouped for all levels within: ", - par_tmp[[session_key]]$SingleEntVis$SingleEnt_accross_condition, + par_tmp[[session$token]]$SingleEntVis$SingleEnt_accross_condition, " (", - paste0(levels(par_tmp[[session_key]]$SingleEntVis$SingleEnt_GeneData_anno),collapse = ";") + paste0(levels(par_tmp[[session$token]]$SingleEntVis$SingleEnt_GeneData_anno),collapse = ";") ,")")) fun_LogIt(message = paste0( "**Single Entitie** - Test for differences: ", - par_tmp[[session_key]]$SingleEntVis$SingleEnt_testMethod)) + par_tmp[[session$token]]$SingleEntVis$SingleEnt_testMethod)) - if(length(levels(par_tmp[[session_key]]$SingleEntVis$SingleEnt_GeneData_anno))>2){ + if(length(levels(par_tmp[[session$token]]$SingleEntVis$SingleEnt_GeneData_anno))>2){ fun_LogIt( message = paste0("**Single Entitie** - ANOVA performed, reference group is the overall mean") ) diff --git a/program/shinyApp/R/util.R b/program/shinyApp/R/util.R index 58d390dd..62df1bcf 100644 --- a/program/shinyApp/R/util.R +++ b/program/shinyApp/R/util.R @@ -1,10 +1,10 @@ ### general utility functions will be defined here -update_data <- function(data, session_key){ +update_data <- function(session_id){ # for stability reasons, data is ALWAYS pulled here print("Updating data...") - data <- res_tmp[[session_key]] + data <- res_tmp[[session_id]] return(data) } @@ -27,11 +27,11 @@ select_data <- function(data, selected_samples, sample_type){ } -update_params <- function(params, session_key){ +update_params <- function(session_id){ # update parameter if updates is larger than current_updates # could force to always update print("Updating parameters...") - params <- par_tmp[[session_key]] + params <- par_tmp[[session_id]] return(params) } diff --git a/program/shinyApp/server.R b/program/shinyApp/server.R index 5e5652d8..ef5ae465 100644 --- a/program/shinyApp/server.R +++ b/program/shinyApp/server.R @@ -4,9 +4,11 @@ server <- function(input,output,session){ global_Vars <<- reactiveValues() # OUTDATED? - # session sepcific key - session_key <- session$token - + # fill session_if textOutput with current session$token + output$session_id <- renderText({ + paste0("Current session: ", session$token) + }) + # getCurrentVersion(updateDESCRIPTION=T) # Where to Place this ? So it does not always get 'updated'? # Can we add this somehow as necassary to every new release? @@ -75,9 +77,15 @@ server <- function(input,output,session){ res_tmp <<- list() par_tmp <<- list() } - # create an empty list in res/par_tmp[[session_key]] - res_tmp[[session_key]] <<- list() - par_tmp[[session_key]] <<- list() + # create an empty list in res/par_tmp[[session$token]] + res_tmp[[session$token]] <<- list() + par_tmp[[session$token]] <<- list() + # On session end, remove the list from res/par_tmp + session$onSessionEnded(function() { + res_tmp[[session$token]] <<- NULL + par_tmp[[session$token]] <<- NULL + }) + browser() # Init update Object ---- # updating is a reative value that counts up whenever data is updated # this is used to trigger the update of the servers @@ -194,7 +202,7 @@ server <- function(input,output,session){ content = function(file){ # TODO Q: What to save here? only original enough? saveRDS( - object = res_tmp[[session_key]]$data_original, + object = res_tmp[[session$token]]$data_original, file = file ) } @@ -352,11 +360,11 @@ server <- function(input,output,session){ ## Do Upload ---- observeEvent(input$refresh1,{ - par_tmp[[session_key]]['omic_type'] <<- input$omicType + par_tmp[[session$token]]['omic_type'] <<- input$omicType fun_LogIt(message = "## DataInput {.tabset .tabset-fade}") fun_LogIt(message = "### Info") fun_LogIt( - message = paste0("**DataInput** - Uploaded Omic Type: ", par_tmp[[session_key]]['omic_type']) + message = paste0("**DataInput** - Uploaded Omic Type: ", par_tmp[[session$token]]['omic_type']) ) if(!(isTruthy(input$data_preDone) | FLAG_TEST_DATA_SELECTED() | @@ -368,8 +376,8 @@ server <- function(input,output,session){ output$debug <- renderText({"The Test Data Set was used"}) }else{ show_toast( - title = paste0(par_tmp[[session_key]]['omic_type'],"Data Upload"), - text = paste0(par_tmp[[session_key]]['omic_type'],"-data upload was successful"), + title = paste0(par_tmp[[session$token]]['omic_type'],"Data Upload"), + text = paste0(par_tmp[[session$token]]['omic_type'],"-data upload was successful"), position = "top", timer = 1500, timerProgressBar = T @@ -498,32 +506,32 @@ server <- function(input,output,session){ #TODO make the copy and tab show process dependent if we get here a results object or 'simple' rds } # TODO SumExp only needed hence more restructuring needed - res_tmp[[session_key]][['data_original']] <<- data_input[[paste0(input$omicType,"_SumExp")]] + res_tmp[[session$token]][['data_original']] <<- data_input[[paste0(input$omicType,"_SumExp")]] # Make a copy, to leave original data untouched - res_tmp[[session_key]][['data']] <<- res_tmp[[session_key]]$data_original + res_tmp[[session$token]][['data']] <<- res_tmp[[session$token]]$data_original # Count up updating updating$count <- updating$count + 1 print(paste0( - "(before) No. anno options sample_table: ",ncol(res_tmp[[session_key]]$data_original) + "(before) No. anno options sample_table: ",ncol(res_tmp[[session$token]]$data_original) )) - colData(res_tmp[[session_key]]$data) <- - DataFrame(as.data.frame(colData(res_tmp[[session_key]]$data)) %>% + colData(res_tmp[[session$token]]$data) <- + DataFrame(as.data.frame(colData(res_tmp[[session$token]]$data)) %>% purrr::keep(~length(unique(.x)) != 1)) print(paste0( - "(after) No. anno options sample_table: ",ncol(res_tmp[[session_key]]$data) + "(after) No. anno options sample_table: ",ncol(res_tmp[[session$token]]$data) )) print(paste0( - "(before) No. anno options annotation_rows: ",ncol(res_tmp[[session_key]]$data_original) + "(before) No. anno options annotation_rows: ",ncol(res_tmp[[session$token]]$data_original) )) - rowData(res_tmp[[session_key]]$data) <- - DataFrame(as.data.frame(rowData(res_tmp[[session_key]]$data)) %>% + rowData(res_tmp[[session$token]]$data) <- + DataFrame(as.data.frame(rowData(res_tmp[[session$token]]$data)) %>% purrr::keep(~length(unique(.x)) != 1)) print(paste0( - "(after) No. anno options annotation_rows: ",ncol(res_tmp[[session_key]]$data) + "(after) No. anno options annotation_rows: ",ncol(res_tmp[[session$token]]$data) )) fun_LogIt( @@ -532,13 +540,13 @@ server <- function(input,output,session){ ) fun_LogIt( message = paste0("**DataInput** - The raw data dimensions are:", - paste0(dim(res_tmp[[session_key]]$data_original),collapse = ", ")) + paste0(dim(res_tmp[[session$token]]$data_original),collapse = ", ")) ) fun_LogIt(message = "### Publication Snippet") fun_LogIt(message = snippet_dataInput( - data_type = par_tmp[[session_key]]$omic_type, - data_dimension = paste0(dim(res_tmp[[session_key]]$data_original),collapse = ", ") + data_type = par_tmp[[session$token]]$omic_type, + data_dimension = paste0(dim(res_tmp[[session$token]]$data_original),collapse = ", ") )) fun_LogIt(message = "
") return("DataUploadSuccesful") @@ -550,14 +558,14 @@ server <- function(input,output,session){ ## Ui Section ---- observe({ req(data_input_shiny()) - isTruthy(res_tmp[[session_key]]$data) + isTruthy(res_tmp[[session$token]]$data) # Row output$providedRowAnnotationTypes_ui=renderUI({ req(data_input_shiny()) shinyWidgets::virtualSelectInput( inputId = "providedRowAnnotationTypes", label = "Which annotation type do you want to select on?", - choices = c(colnames(rowData(res_tmp[[session_key]]$data_original))), + choices = c(colnames(rowData(res_tmp[[session$token]]$data_original))), multiple = F, search = T, showSelectedOptionsFirst = T @@ -568,7 +576,7 @@ server <- function(input,output,session){ req(data_input_shiny()) req(input$providedRowAnnotationTypes) if(is.numeric( - rowData(res_tmp[[session_key]]$data_original)[,input$providedRowAnnotationTypes]) + rowData(res_tmp[[session$token]]$data_original)[,input$providedRowAnnotationTypes]) ){ selectInput( inputId = "row_selection", @@ -581,7 +589,7 @@ server <- function(input,output,session){ shinyWidgets::virtualSelectInput( inputId = "row_selection", label = "Which entities to use? (Will be the union if multiple selected)", - choices = c("High Values+IQR","all",unique(unlist(strsplit(rowData(res_tmp[[session_key]]$data_original)[,input$providedRowAnnotationTypes],"\\|")))), + choices = c("High Values+IQR","all",unique(unlist(strsplit(rowData(res_tmp[[session$token]]$data_original)[,input$providedRowAnnotationTypes],"\\|")))), selected = "all", multiple = T, search = T, @@ -612,8 +620,8 @@ server <- function(input,output,session){ selectInput( inputId = "providedSampleAnnotationTypes", label = "Which annotation type do you want to select on?", - choices = c(colnames(colData(res_tmp[[session_key]]$data_original))), - selected = c(colnames(colData(res_tmp[[session_key]]$data_original)))[1], + choices = c(colnames(colData(res_tmp[[session$token]]$data_original))), + selected = c(colnames(colData(res_tmp[[session$token]]$data_original)))[1], multiple = F ) }) @@ -624,7 +632,7 @@ server <- function(input,output,session){ label = "Which entities to use? (Will be the union if multiple selected)", choices = c( "all", - unique(colData(res_tmp[[session_key]]$data_original)[,input$providedSampleAnnotationTypes]) + unique(colData(res_tmp[[session$token]]$data_original)[,input$providedSampleAnnotationTypes]) ), selected = "all", multiple = T @@ -677,17 +685,17 @@ server <- function(input,output,session){ ## Do Selection ---- selectedData <- reactive({ shiny::req(input$row_selection, input$sample_selection) - par_tmp[[session_key]][["row_selection"]] <<- input$row_selection + par_tmp[[session$token]][["row_selection"]] <<- input$row_selection print("Alright do Row selection") selected <- c() if(any(input$row_selection == "all")){ - selected <- rownames(rowData(res_tmp[[session_key]]$data_original)) + selected <- rownames(rowData(res_tmp[[session$token]]$data_original)) }else if(!(length(input$row_selection) == 1 & any(input$row_selection == "High Values+IQR"))){ selected <- unique( c(selected, - rownames(rowData(res_tmp[[session_key]]$data_original))[ - which(rowData(res_tmp[[session_key]]$data_original)[,input$providedRowAnnotationTypes]%in%input$row_selection) + rownames(rowData(res_tmp[[session$token]]$data_original))[ + which(rowData(res_tmp[[session$token]]$data_original)[,input$providedRowAnnotationTypes]%in%input$row_selection) ] ) ) @@ -695,17 +703,17 @@ server <- function(input,output,session){ if(any(input$row_selection == "High Values+IQR")){ if(length(input$row_selection) == 1){ toKeep <- filter_rna( - rna = assay(res_tmp[[session_key]]$data_original), + rna = assay(res_tmp[[session$token]]$data_original), prop = input$propensityChoiceUser ) - filteredIQR_Expr <- assay(res_tmp[[session_key]]$data_original)[toKeep,] + filteredIQR_Expr <- assay(res_tmp[[session$token]]$data_original)[toKeep,] selected <- rownames(filteredIQR_Expr) }else{ toKeep <- filter_rna( - rna = assay(res_tmp[[session_key]]$data_original)[selected,], + rna = assay(res_tmp[[session$token]]$data_original)[selected,], prop = input$propensityChoiceUser ) - filteredIQR_Expr <- assay(res_tmp[[session_key]]$data_original)[toKeep,] + filteredIQR_Expr <- assay(res_tmp[[session$token]]$data_original)[toKeep,] selected <- intersect( selected, rownames(filteredIQR_Expr) @@ -717,20 +725,20 @@ server <- function(input,output,session){ # Column Selection samples_selected <- c() if(any(input$sample_selection == "all")){ - samples_selected <- colnames(assay(res_tmp[[session_key]]$data_original)) + samples_selected <- colnames(assay(res_tmp[[session$token]]$data_original)) }else{ samples_selected <- c( samples_selected, - rownames(colData(res_tmp[[session_key]]$data_original))[which( - colData(res_tmp[[session_key]]$data_original)[,input$providedSampleAnnotationTypes] %in% input$sample_selection + rownames(colData(res_tmp[[session$token]]$data_original))[which( + colData(res_tmp[[session$token]]$data_original)[,input$providedSampleAnnotationTypes] %in% input$sample_selection )] ) } # Data set selection print("Alright do Column selection") - res_tmp[[session_key]]$data <<- res_tmp[[session_key]]$data_original[selected,samples_selected] - tmp_data_selected <<- res_tmp[[session_key]]$data_original[selected,samples_selected] + res_tmp[[session$token]]$data <<- res_tmp[[session$token]]$data_original[selected,samples_selected] + tmp_data_selected <<- res_tmp[[session$token]]$data_original[selected,samples_selected] return("Selection Success") }) @@ -811,42 +819,42 @@ server <- function(input,output,session){ print("Do Preprocessing") print(selectedData()) addWarning <- "" - par_tmp[[session_key]]['PreProcessing_Procedure'] <<- input$PreProcessing_Procedure + par_tmp[[session$token]]['PreProcessing_Procedure'] <<- input$PreProcessing_Procedure processedData_all <- tmp_data_selected # as general remove all genes which are constant over all rows print("As general remove all entities which are constant over all samples") - res_tmp[[session_key]]$data <<- tmp_data_selected[rownames(tmp_data_selected[which(apply(assay(tmp_data_selected),1,sd) != 0),]),] + res_tmp[[session$token]]$data <<- tmp_data_selected[rownames(tmp_data_selected[which(apply(assay(tmp_data_selected),1,sd) != 0),]),] - print(dim(res_tmp[[session_key]]$data)) + print(dim(res_tmp[[session$token]]$data)) # explicitly set rownames to avoid any errors. - # new object Created for res_tmp[[session_key]] - res_tmp[[session_key]]$data <<- res_tmp[[session_key]]$data[rownames(res_tmp[[session_key]]$data),] + # new object Created for res_tmp[[session$token]] + res_tmp[[session$token]]$data <<- res_tmp[[session$token]]$data[rownames(res_tmp[[session$token]]$data),] if(input$PreProcessing_Procedure != "none"){ if(input$PreProcessing_Procedure == "filterOnly"){ - if(par_tmp[[session_key]]$omic_type == "Transcriptomics"){ + if(par_tmp[[session$token]]$omic_type == "Transcriptomics"){ print("Also remove anything of rowCount <=10") print(dim(tmp_data_selected)) - res_tmp[[session_key]]$data <<- tmp_data_selected[which(rowSums(assay(tmp_data_selected)) > 10),] + res_tmp[[session$token]]$data <<- tmp_data_selected[which(rowSums(assay(tmp_data_selected)) > 10),] } - if(par_tmp[[session_key]]$omic_type == "Metabolomics"){ + if(par_tmp[[session$token]]$omic_type == "Metabolomics"){ print("Remove anything which has a row median of 0") print(dim(tmp_data_selected)) - res_tmp[[session_key]]$data <<- tmp_data_selected[which(apply(assay(tmp_data_selected),1,median)!=0),] + res_tmp[[session$token]]$data <<- tmp_data_selected[which(apply(assay(tmp_data_selected),1,median)!=0),] } addWarning <- "Only Filtering of low abundant is done only if Transcriptomics or Metabolomics was chosen\n" }else{ - if(par_tmp[[session_key]]$omic_type == "Transcriptomics"){ + if(par_tmp[[session$token]]$omic_type == "Transcriptomics"){ print("Also remove anything of rowCount <=10") print(dim(tmp_data_selected)) - res_tmp[[session_key]]$data <<- tmp_data_selected[which(rowSums(assay(tmp_data_selected)) > 10),] + res_tmp[[session$token]]$data <<- tmp_data_selected[which(rowSums(assay(tmp_data_selected)) > 10),] } - if(par_tmp[[session_key]]$omic_type == "Metabolomics"){ + if(par_tmp[[session$token]]$omic_type == "Metabolomics"){ print("Remove anything which has a row median of 0") print(dim(tmp_data_selected)) @@ -854,27 +862,27 @@ server <- function(input,output,session){ } } - print(dim(res_tmp[[session_key]]$data)) + print(dim(res_tmp[[session$token]]$data)) print(paste0("Do chosen Preprocessing:",input$PreProcessing_Procedure)) if(input$PreProcessing_Procedure == "simpleCenterScaling"){ processedData <- as.data.frame(t( scale( - x = as.data.frame(t(as.data.frame(assay(res_tmp[[session_key]]$data)))), + x = as.data.frame(t(as.data.frame(assay(res_tmp[[session$token]]$data)))), scale = T, center = T ) ) ) - assay(res_tmp[[session_key]]$data) <<- as.data.frame(processedData) + assay(res_tmp[[session$token]]$data) <<- as.data.frame(processedData) } if(input$PreProcessing_Procedure == "vst_DESeq"){ - par_tmp[[session_key]]["DESeq_advanced"] <<- FALSE - if(par_tmp[[session_key]]$omic_type == "Transcriptomics"){ + par_tmp[[session$token]]["DESeq_advanced"] <<- FALSE + if(par_tmp[[session$token]]$omic_type == "Transcriptomics"){ design_formula <- paste("~", input$DESeq_formula_main) # only do this locally - colData(res_tmp[[session_key]]$data)[,input$DESeq_formula_main] <- as.factor( - colData(res_tmp[[session_key]]$data)[,input$DESeq_formula_main] + colData(res_tmp[[session$token]]$data)[,input$DESeq_formula_main] <- as.factor( + colData(res_tmp[[session$token]]$data)[,input$DESeq_formula_main] ) if(length(input$DESeq_formula_sub) > 0){ design_formula <- paste( @@ -883,63 +891,63 @@ server <- function(input,output,session){ ) # turn each factor into a factor for(i in input$DESeq_formula_sub){ - colData(res_tmp[[session_key]]$data)[,i] <- as.factor( - colData(res_tmp[[session_key]]$data)[,i] + colData(res_tmp[[session$token]]$data)[,i] <- as.factor( + colData(res_tmp[[session$token]]$data)[,i] ) } - par_tmp[[session_key]][["DESeq_factors"]] <<- c( + par_tmp[[session$token]][["DESeq_factors"]] <<- c( input$DESeq_formula_main,input$DESeq_formula_sub ) } else{ - par_tmp[[session_key]][["DESeq_factors"]] <<- c(input$DESeq_formula_main) + par_tmp[[session$token]][["DESeq_factors"]] <<- c(input$DESeq_formula_main) } # if advanced formula is used, overwrite the other formula if(input$DESeq_show_advanced){ if(startsWith(input$DESeq_formula_advanced, "~")){ print("Advanced formula used") design_formula <- input$DESeq_formula_advanced - par_tmp[[session_key]]["DESeq_advanced"] <<- TRUE + par_tmp[[session$token]]["DESeq_advanced"] <<- TRUE } } print(design_formula) - par_tmp[[session_key]]["DESeq_formula"] <<- design_formula + par_tmp[[session$token]]["DESeq_formula"] <<- design_formula # on purpose local - print(colData(res_tmp[[session_key]]$data)[,input$DESeq_formula_main]) + print(colData(res_tmp[[session$token]]$data)[,input$DESeq_formula_main]) dds <- DESeq2::DESeqDataSetFromMatrix( - countData = assay(res_tmp[[session_key]]$data), - colData = colData(res_tmp[[session_key]]$data), + countData = assay(res_tmp[[session$token]]$data), + colData = colData(res_tmp[[session$token]]$data), design = as.formula(design_formula) ) de_seq_result <- DESeq2::DESeq(dds) - res_tmp[[session_key]]$DESeq_obj <<- de_seq_result + res_tmp[[session$token]]$DESeq_obj <<- de_seq_result dds_vst <- vst( object = de_seq_result, blind = TRUE ) - assay(res_tmp[[session_key]]$data) <<- as.data.frame(assay(dds_vst)) + assay(res_tmp[[session$token]]$data) <<- as.data.frame(assay(dds_vst)) }else{ addWarning <- "DESeq makes only sense for transcriptomics data - data treated as if 'none' was selected!" } } if(input$PreProcessing_Procedure == "Scaling_0_1"){ processedData <- as.data.frame(t( - apply(assay(res_tmp[[session_key]]$data),1,function(x){ + apply(assay(res_tmp[[session$token]]$data),1,function(x){ (x - min(x))/(max(x) - min(x)) }) )) - assay(res_tmp[[session_key]]$data) <<- as.data.frame(processedData) + assay(res_tmp[[session$token]]$data) <<- as.data.frame(processedData) } if(input$PreProcessing_Procedure == "ln"){ processedData <- as.data.frame(log( - as.data.frame(assay(res_tmp[[session_key]]$data)) + as.data.frame(assay(res_tmp[[session$token]]$data)) )) - assay(res_tmp[[session_key]]$data) <<- as.data.frame(processedData) + assay(res_tmp[[session$token]]$data) <<- as.data.frame(processedData) } if(input$PreProcessing_Procedure == "log10"){ - processedData <- as.data.frame(assay(res_tmp[[session_key]]$data)) + processedData <- as.data.frame(assay(res_tmp[[session$token]]$data)) if(any(processedData<0)){ addWarning <- "Negative entries, cannot take log10!!" } @@ -951,10 +959,10 @@ server <- function(input,output,session){ processedData <- as.data.frame(log10( processedData + 1) ) - assay(res_tmp[[session_key]]$data) <<- as.data.frame(processedData) + assay(res_tmp[[session$token]]$data) <<- as.data.frame(processedData) } if(input$PreProcessing_Procedure == "pareto_scaling"){ - processedData <- as.data.frame(assay(res_tmp[[session_key]]$data)) + processedData <- as.data.frame(assay(res_tmp[[session$token]]$data)) centered <- as.data.frame(t( apply(processedData, 1, function(x){x - mean(x)}) )) @@ -962,24 +970,24 @@ server <- function(input,output,session){ apply(centered, 1, function(x){x/sqrt(sd(x))}) )) - assay(res_tmp[[session_key]]$data) <<- as.data.frame(pareto.matrix) + assay(res_tmp[[session$token]]$data) <<- as.data.frame(pareto.matrix) } } - if(any(is.na(assay(res_tmp[[session_key]]$data)))){ + if(any(is.na(assay(res_tmp[[session$token]]$data)))){ print("This might be problem due to mismatched Annotation Data?!") - nrow_before <- nrow(assay(res_tmp[[session_key]]$data)) + nrow_before <- nrow(assay(res_tmp[[session$token]]$data)) nrow_after <- nrow( - res_tmp[[session_key]]$data[complete.cases(assay(res_tmp[[session_key]]$data)),] + res_tmp[[session$token]]$data[complete.cases(assay(res_tmp[[session$token]]$data)),] ) addWarning <- paste0("There were NA's after pre-processing, any row containg such was completly removed! (before/after): ",nrow_before,"/",nrow_after,"") if(!(nrow_after > 0)){ addWarning <- paste0(addWarning, "
There is nothing left, choose different pre-processing other-wise App will crash!") } - res_tmp[[session_key]]$data <<- res_tmp[[session_key]]$data[complete.cases(assay(res_tmp[[session_key]]$data)),] + res_tmp[[session$token]]$data <<- res_tmp[[session$token]]$data[complete.cases(assay(res_tmp[[session$token]]$data)),] } - print(colnames(res_tmp[[session_key]]$data)) + print(colnames(res_tmp[[session$token]]$data)) showTab(inputId = "tabsetPanel1", target = "Sample Correlation") showTab(inputId = "tabsetPanel1", target = "Significance Analysis") @@ -997,11 +1005,11 @@ server <- function(input,output,session){ shinyjs::click("single_gene_visualisation-refreshUI",asis = T) paste0(addWarning, "The data has the dimensions of: ", - paste0(dim(res_tmp[[session_key]]$data),collapse = ", "), + paste0(dim(res_tmp[[session$token]]$data),collapse = ", "), "
","Be aware that depending on omic-Type, basic pre-processing has been done anyway even when selecting none", "",ifelse(any(as.data.frame(assay(res_tmp[[session_key]]$data)) < 0),"Be aware that processed data has negative values, hence no log fold changes can be calculated","")) + "
",ifelse(any(as.data.frame(assay(res_tmp[[session$token]]$data)) < 0),"Be aware that processed data has negative values, hence no log fold changes can be calculated","")) }) @@ -1026,9 +1034,9 @@ server <- function(input,output,session){ ## Log preprocessing ---- observeEvent(input$Do_preprocessing,{ print(selectedData_processed()) - if(par_tmp[[session_key]]$omic_type == "Transcriptomics"){ + if(par_tmp[[session$token]]$omic_type == "Transcriptomics"){ tmp_logMessage <- "Remove anything which row Count <= 10" - }else if(par_tmp[[session_key]]$omic_type == "Metabolomics"){ + }else if(par_tmp[[session$token]]$omic_type == "Metabolomics"){ tmp_logMessage <- "Remove anything which has a row median of 0" }else{ tmp_logMessage <- "none" @@ -1046,20 +1054,20 @@ server <- function(input,output,session){ fun_LogIt( message = paste0( "**PreProcessing** - The resulting dimensions are: ", - paste0(dim(res_tmp[[session_key]]$data),collapse = ", ") + paste0(dim(res_tmp[[session$token]]$data),collapse = ", ") ) ) }) - output$debug <- renderText(dim(res_tmp[[session_key]]$data)) + output$debug <- renderText(dim(res_tmp[[session$token]]$data)) ## UP TILL HERE ## # Sample Correlation ---- # calling server without reactive it will be init upon start, with no update # of respective data inputs hence need of at least one reactive! sample_correlation_server( id = "sample_correlation", - data = res_tmp[[session_key]], - params = par_tmp[[session_key]], + data = res_tmp[[session$token]], + params = par_tmp[[session$token]], reactive(updating$count) #omic_type = reactive(input$omicType), # par_tmp$omic_type #row_select = reactive(input$row_selection) #par_tmp$row_selection ? # only for title? @@ -1068,30 +1076,30 @@ server <- function(input,output,session){ # significance analysis ---- significance_analysis_server( id = 'SignificanceAnalysis', - data = res_tmp[[session_key]], - params = par_tmp[[session_key]], + data = res_tmp[[session$token]], + params = par_tmp[[session$token]], reactive(updating$count) ) # PCA ---- pca_Server( id = "PCA", - data = res_tmp[[session_key]], - params = par_tmp[[session_key]], + data = res_tmp[[session$token]], + params = par_tmp[[session$token]], reactive(input$row_selection), reactive(updating$count) ) # Heatmap ---- heatmap_server( id = 'Heatmap', - data = res_tmp[[session_key]], - params = par_tmp[[session_key]], + data = res_tmp[[session$token]], + params = par_tmp[[session$token]], reactive(updating$count) ) # Single Gene Visualisations ---- single_gene_visualisation_server( id = 'single_gene_visualisation', - data = res_tmp[[session_key]], - params = par_tmp[[session_key]], + data = res_tmp[[session$token]], + params = par_tmp[[session$token]], reactive(updating$count) ) @@ -1099,8 +1107,8 @@ server <- function(input,output,session){ # Enrichment Analysis ---- enrichment_analysis_Server( id = 'EnrichmentAnalysis', - data = res_tmp[[session_key]], - params = par_tmp[[session_key]], + data = res_tmp[[session$token]], + params = par_tmp[[session$token]], reactive(updating$count) ) } diff --git a/program/shinyApp/ui.R b/program/shinyApp/ui.R index 2405b4e2..9697173f 100644 --- a/program/shinyApp/ui.R +++ b/program/shinyApp/ui.R @@ -185,6 +185,7 @@ ui <- shiny::fluidPage( helpText("Metabolon Help", align = "center") %>% helper(type = "markdown", content = "Metabolon_help", size = "l", colour = "blue", style = "position: relative;top: -18px;left: 15px;; zoom: 200%;"), NULL ), + tabsetPanel( id = "tabsetPanel1", ################################################################################ @@ -241,6 +242,12 @@ ui <- shiny::fluidPage( bottom = 0, left = 10, fixed = TRUE,style = "background-color: #a9d96a;" ) ) + ), + # Pannel displaying the current session id + absolutePanel( + # text output needs to be defined in server + textOutput("session_id"), + bottom = 0, right = 10, fixed = TRUE ) )