From fb0874b2333e4e857bcfc8ae2fbaf9a6c32c803c Mon Sep 17 00:00:00 2001 From: PaulJonasJost Date: Wed, 31 Jan 2024 11:49:14 +0100 Subject: [PATCH 1/5] Removed unhelpful comments --- program/shinyApp/R/significance_analysis/ui.R | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/program/shinyApp/R/significance_analysis/ui.R b/program/shinyApp/R/significance_analysis/ui.R index a5e6257f..71ce992a 100644 --- a/program/shinyApp/R/significance_analysis/ui.R +++ b/program/shinyApp/R/significance_analysis/ui.R @@ -2,22 +2,17 @@ significance_analysis_sidebar_ui<- function(ns){ sidebarPanel( id = "sidebar_significance_analysis", h5(" ") %>% helper(type = "markdown", content = "SigAna_Choices"), - # UI to choose type of comparison uiOutput(outputId = ns("type_of_comparison_ui")), - # UI to choose comparisons uiOutput(outputId = ns("chooseComparisons_ui")), # UI to choose test method uiOutput(outputId = ns("chooseTest_ui")), - # UI to choose significance level uiOutput(outputId = ns("chooseSignificanceLevel_ui")), - # UI to choose test correction uiOutput(outputId = ns("chooseTestCorrection_ui")), # Button to start analysis actionButton( inputId = ns("significanceGo"), label = "Get significance analysis" - ), - # Button to refresh the UI + ), hidden(actionButton( inputId = ns("refreshUI"), label = "Refresh UI" @@ -30,34 +25,31 @@ significance_analysis_sidebar_ui<- function(ns){ significance_analysis_main_ui <- function(ns){ mainPanel( id = "main_significance_analysis", - # informative text, whether analysis was done or not htmlOutput(outputId = ns("significance_analysis_info"), container = pre), tabsetPanel( id = ns("significance_analysis_results"), tabPanel( title = "Result Visualization", - # UI for visualization Plot plotOutput(outputId = ns("Significant_Plot_final")), # UI to select comparisons to visualize splitLayout( # Only used for questionmark - cellWidths = c("26%", "74%"), - h4("Visualization Choices") %>% helper(type = "markdown", content = "SigAna_Vis"), - NULL + cellWidths = c("26%", "74%"), + h4("Visualization Choices") %>% helper(type = "markdown", content = "SigAna_Vis"), + NULL ), uiOutput(outputId = ns("chooseComparisonsToVisualize_ui")), - # UI to choose visualization method uiOutput(outputId = ns("chooseVisualization_ui")), - # UI to choose what genes to llok at (e.g. significant, upregulated, downregulated) + # Choose what genes to look at (e.g. significant, upregulated, downregulated) uiOutput(outputId = ns("chooseGenesToLookAt_ui")), hr(style = "border-top: 1px solid #000000;"), - # UI to choose intersections to highlight + # Choose intersections to highlight h5(" ") %>% helper(type = "markdown", content = "SigAna_Intersections"), uiOutput(outputId = ns("chooseIntersections_ui")), # Download highlighted intersections as table downloadButton( - outputId = ns("downloadIntersections"), - label = "Download Intersections", - class = "btn-info" + outputId = ns("downloadIntersections"), + label = "Download Intersections", + class = "btn-info" ), # Download and Report UI splitLayout( From ceeef2cfa00a355546e04e82ad4ec84c556cf1a0 Mon Sep 17 00:00:00 2001 From: PaulJonasJost Date: Wed, 31 Jan 2024 11:50:35 +0100 Subject: [PATCH 2/5] Removed updates as parameter --- program/shinyApp/R/significance_analysis/server.R | 5 +---- program/shinyApp/server.R | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/program/shinyApp/R/significance_analysis/server.R b/program/shinyApp/R/significance_analysis/server.R index d88beafc..b646369c 100644 --- a/program/shinyApp/R/significance_analysis/server.R +++ b/program/shinyApp/R/significance_analysis/server.R @@ -1,4 +1,4 @@ -significance_analysis_server <- function(id, data, params, updates){ +significance_analysis_server <- function(id, data, params){ moduleServer( id, function(input,output,session){ @@ -9,7 +9,6 @@ significance_analysis_server <- function(id, data, params, updates){ dds = NULL, scenario = 0, comparisons_for_plot = "all", - current_updates = 0, coldata = NULL ) ns <- session$ns @@ -182,7 +181,6 @@ significance_analysis_server <- function(id, data, params, updates){ observeEvent(input$refreshUI, { data <- update_data(session$token) params <- update_params(session$token) - sig_ana_reactive$current_updates <- updates() sig_ana_reactive$coldata <- colData(data$data) }) # Analysis initial info @@ -201,7 +199,6 @@ significance_analysis_server <- function(id, data, params, updates){ print("Start the Significance Analysis") # update the data if needed data <- update_data(session$token) - sig_ana_reactive$current_updates <- updates() sig_ana_reactive$coldata <- colData(data$data) # delete old panels if(!is.null(significance_tabs_to_delete)){ diff --git a/program/shinyApp/server.R b/program/shinyApp/server.R index 19b90836..5d0c1ccc 100644 --- a/program/shinyApp/server.R +++ b/program/shinyApp/server.R @@ -1091,8 +1091,7 @@ server <- function(input,output,session){ significance_analysis_server( id = 'SignificanceAnalysis', data = res_tmp[[session$token]], - params = par_tmp[[session$token]], - reactive(updating$count) + params = par_tmp[[session$token]] ) # PCA ---- pca_Server( From ca80617eff8a73166162e2d44b62aff035ae8569 Mon Sep 17 00:00:00 2001 From: PaulJonasJost Date: Thu, 1 Feb 2024 11:23:23 +0100 Subject: [PATCH 3/5] Removed some print statements. Made significance_tabs_to_delete into a reactive value. --- .../shinyApp/R/significance_analysis/server.R | 169 ++++++++---------- .../shinyApp/R/significance_analysis/util.R | 3 - 2 files changed, 75 insertions(+), 97 deletions(-) diff --git a/program/shinyApp/R/significance_analysis/server.R b/program/shinyApp/R/significance_analysis/server.R index b646369c..229e8c68 100644 --- a/program/shinyApp/R/significance_analysis/server.R +++ b/program/shinyApp/R/significance_analysis/server.R @@ -9,7 +9,8 @@ significance_analysis_server <- function(id, data, params){ dds = NULL, scenario = 0, comparisons_for_plot = "all", - coldata = NULL + coldata = NULL, + significance_tabs_to_delete = NULL ) ns <- session$ns ## Sidebar UI section @@ -28,7 +29,7 @@ significance_analysis_server <- function(id, data, params){ multiple = F, selected = NULL ) - } else{ + } else { selectInput( inputId = ns("sample_annotation_types_cmp"), label = "Choose groups to compare", @@ -37,7 +38,6 @@ significance_analysis_server <- function(id, data, params){ selected = NULL ) } - }) # UI to choose comparisons output$chooseComparisons_ui <- renderUI({ @@ -46,7 +46,7 @@ significance_analysis_server <- function(id, data, params){ if(length(annoToSelect) == length(unique(annoToSelect))){ # probably not what user wants, slows done app due to listing a lot of comparisons hence prevent helpText("unique elements, cant perform testing. Try to choose a different option at 'Choose the groups to show the data for'") - }else{ + } else { my_comparisons <- subset(expand.grid(rep(list(unique(annoToSelect)),2)), Var1 != Var2) xy.list <- vector("list", nrow(my_comparisons)) for (i in 1:nrow(my_comparisons)) { @@ -71,7 +71,7 @@ significance_analysis_server <- function(id, data, params){ expr = "DESeq is using a Wald test statistic.\nWe are using the same here.", outputArgs = list(container = pre) ) - }else{ + } else { shinyWidgets::virtualSelectInput( search = T, showSelectedOptionsFirst = T, @@ -83,28 +83,24 @@ significance_analysis_server <- function(id, data, params){ } }) # UI to choose significance level - output$chooseSignificanceLevel_ui <- renderUI({ - sliderInput( - inputId = ns("significance_level"), - label = "Significance level", - min = 0.005, - max = 0.1, - value = 0.05, - step = 0.005 - ) - }) + output$chooseSignificanceLevel_ui <- renderUI({sliderInput( + inputId = ns("significance_level"), + label = "Significance level", + min = 0.005, + max = 0.1, + value = 0.05, + step = 0.005 + )}) # UI to choose test correction - output$chooseTestCorrection_ui <- renderUI({ - selectInput( - inputId = ns("test_correction"), - label = "Test correction", - choices = c( - "None", "Bonferroni", "Benjamini-Hochberg", "Benjamini Yekutieli", - "Holm", "Hommel", "Hochberg", "FDR" - ), - selected = "Benjamini-Hochberg" - ) - }) + output$chooseTestCorrection_ui <- renderUI({selectInput( + inputId = ns("test_correction"), + label = "Test correction", + choices = c( + "None", "Bonferroni", "Benjamini-Hochberg", "Benjamini Yekutieli", + "Holm", "Hommel", "Hochberg", "FDR" + ), + selected = "Benjamini-Hochberg" + )}) # UI to select comparisons to visualize output$chooseComparisonsToVisualize_ui <- renderUI({ req(input$comparisons) @@ -126,10 +122,10 @@ significance_analysis_server <- function(id, data, params){ choices <- c("UpSetR plot") } selectInput( - inputId = ns("visualization_method"), - label = "Visualization method", - choices = choices, - selected = input$visualization_method + inputId = ns("visualization_method"), + label = "Visualization method", + choices = choices, + selected = input$visualization_method ) }) # UI to choose what genes to look at (e.g. significant, upregulated, downregulated) @@ -137,23 +133,23 @@ significance_analysis_server <- function(id, data, params){ req(input$comparisons_to_visualize) # choices dependent on preprocess_method if(params$PreProcessing_Procedure == "vst_DESeq"){ - choices <- c( - "Significant", - "Upregulated", - "Downregulated", - "Significant unadjusted" - ) + choices <- c( + "Significant", + "Upregulated", + "Downregulated", + "Significant unadjusted" + ) } else { - choices <- c( - "Significant", - "Significant unadjusted" - ) + choices <- c( + "Significant", + "Significant unadjusted" + ) } selectInput( - inputId = ns("sig_to_look_at"), - label = "Type of significance to look at", - choices = choices, - selected = input$sig_to_look_at + inputId = ns("sig_to_look_at"), + label = "Type of significance to look at", + choices = choices, + selected = input$sig_to_look_at ) }) # ui to choose intersections to highlight in venn diagram @@ -163,11 +159,11 @@ significance_analysis_server <- function(id, data, params){ req(sig_ana_reactive$plot_last) choices <- append("None", sig_ana_reactive$intersect_names) selectInput( - inputId = ns("intersection_high"), - label = "Intersections to highlight", - choices = choices, - multiple = T, - selected = input$intersection_high + inputId = ns("intersection_high"), + label = "Intersections to highlight", + choices = choices, + multiple = T, + selected = input$intersection_high ) }) # keep updating the info panel while executing @@ -185,44 +181,40 @@ significance_analysis_server <- function(id, data, params){ }) # Analysis initial info observeEvent(input$significanceGo,{ - # shinyjs::html(id = 'significance_analysis_info', "Analysis is running...") sig_ana_reactive$info_text <- "Analysis is running..." - # start the analysis sig_ana_reactive$start_analysis <- sig_ana_reactive$start_analysis + 1 }) # Do the analysis observeEvent(sig_ana_reactive$start_analysis,{ req(sig_ana_reactive$start_analysis > 0) if(input$significanceGo == 1){ - significance_tabs_to_delete <<- NULL + sig_ana_reactive$significance_tabs_to_delete <- NULL } print("Start the Significance Analysis") # update the data if needed data <- update_data(session$token) sig_ana_reactive$coldata <- colData(data$data) # delete old panels - if(!is.null(significance_tabs_to_delete)){ - for (i in 1:length(significance_tabs_to_delete)) { + if(!is.null(sig_ana_reactive$significance_tabs_to_delete)){ + for (i in 1:length(sig_ana_reactive$significance_tabs_to_delete)) { removeTab( inputId = "significance_analysis_results", - target = significance_tabs_to_delete[[i]] + target = sig_ana_reactive$significance_tabs_to_delete[[i]] ) } } # if preproccesing method was DESeq2, then use DESeq2 for testing if(params$PreProcessing_Procedure == "vst_DESeq"){ dds <- data$DESeq_obj - # rewind the comparisons again newList <- input$comparisons contrasts <- vector("list", length(input$comparisons)) - for (i in 1:length(newList)) { + for (i in seq_along(newList)) { contrasts[[i]] <- unlist(strsplit(x = input$comparisons[i],split = ":")) } - # get the results for each contrast and put it all in a big results object sig_results <<- list() - for (i in 1:length(contrasts)) { + for (i in seq_along(contrasts)) { if(identical( list(test_method = "Wald", test_correction = PADJUST_METHOD[[input$test_correction]]), par_tmp[[session$token]]$SigAna[[input$sample_annotation_types_cmp]][[input$comparisons[i]]] @@ -246,15 +238,13 @@ significance_analysis_server <- function(id, data, params){ test_method = "Wald", test_correction = PADJUST_METHOD[[input$test_correction]] ) - ### put in here browser if use of `script_getSigToExcel` } - } - else{ # all other methods require manual testing + } else { # all other methods require manual testing # rewind the comparisons again newList <- input$comparisons contrasts <- vector("list", length(input$comparisons)) contrasts_all <- list() - for (i in 1:length(newList)) { + for (i in seq_along(newList)) { contrasts[[i]] <- unlist(strsplit(x = input$comparisons[i],split = ":")) contrasts_all <- append(contrasts_all, contrasts[[i]]) } @@ -289,7 +279,7 @@ significance_analysis_server <- function(id, data, params){ ns = ns, preprocess_method = params$PreProcessing_Procedure ) - significance_tabs_to_delete[[i]] <<- input$comparisons[i] + sig_ana_reactive$significance_tabs_to_delete[[i]] <- input$comparisons[i] } sig_ana_reactive$info_text <- "Analysis is Done!" # update plot @@ -317,8 +307,7 @@ significance_analysis_server <- function(id, data, params){ # assign scenario=20 for Venn Diagram and scenario=21 for UpSetR if(input$visualization_method == "Venn Diagram"){ sig_ana_reactive$scenario <- 20 - } - else{ + } else { sig_ana_reactive$scenario <- 21 } # get the results @@ -334,10 +323,9 @@ significance_analysis_server <- function(id, data, params){ if(any(input$comparisons_to_visualize == "all")){ # show all comparisons if no more than 4 - if(length(input$comparisons)<5){ + if(length(input$comparisons) < 5){ chosenVizSet <- input$comparisons - }else{ - + } else { chosenVizSet <- input$comparisons[c(1,2)] sig_ana_reactive$info_text <- "Note: Although you choose 'all' to visualize only first 2 comparisons are shown to avoid unwanted computational overhead, as you got more than 4 comparisons. Please choose precisely the comparisons for visualisation." @@ -345,7 +333,7 @@ significance_analysis_server <- function(id, data, params){ }else{ chosenVizSet <- input$comparisons_to_visualize } - for (i in 1:length(chosenVizSet)) { + for (i in seq_along(chosenVizSet)) { to_add_tmp <- rownames( filter_significant_result( result = sig_results[[chosenVizSet[i]]], @@ -362,12 +350,12 @@ significance_analysis_server <- function(id, data, params){ if(length(res2plot) <= 1){ sig_ana_reactive$info_text <- "You either have no significant results or only significant results in one comparison." # if current plots to llok at are adjusted pvalues, suggest to look at raw pvalues - if(input$sig_to_look_at == "Significant"){ - sig_ana_reactive$info_text <- paste0( + if(input$sig_to_look_at == "Significant"){ + sig_ana_reactive$info_text <- paste0( sig_ana_reactive$info_text, "\nYou tried to look at adjusted pvalues.\nYou might want to look at raw pvalues (CAUTION!) or change the significance level." - ) - } + ) + } # clear the plot output$Significant_Plot_final <- renderPlot({}) return(NULL) @@ -384,7 +372,7 @@ significance_analysis_server <- function(id, data, params){ sig_ana_reactive$intersect_names <- ggplot_build( sig_ana_reactive$plot_last )$layout$panel_params[[1]]$x$get_labels() - }else if(input$visualization_method == "Venn diagram"){ + } else if(input$visualization_method == "Venn diagram"){ # set colors for each comparison sig_ana_reactive$plot_last <- ggvenn::ggvenn( res2plot, fill_color=c("#44af69", "#f8333c", "#fcab10", "#2b9eb3"), @@ -403,11 +391,6 @@ significance_analysis_server <- function(id, data, params){ plot=sig_ana_reactive$plot_last, overlap_list=sig_ana_reactive$overlap_list ) - querie_names <- map_intersects_for_highlight( - highlights=input$intersection_high, - plot=sig_ana_reactive$plot_last, - overlap_list=sig_ana_reactive$overlap_list - ) queries <- vector("list", length(querie_names_all)) for(i_querie in seq_along(sig_ana_reactive$intersect_names)){ if(sig_ana_reactive$intersect_names[[i_querie]] %in% input$intersection_high){ @@ -470,8 +453,6 @@ significance_analysis_server <- function(id, data, params){ write.csv(tosave, file, row.names = FALSE) } ) - - # Download and Report Section # download R Code for further plotting output$getR_Code <- downloadHandler( @@ -510,7 +491,6 @@ significance_analysis_server <- function(id, data, params){ paste0(id, Sys.time(), input$file_ext_Sig) }, content = function(file){ - print("Plot saving.") ggsave( filename = file, plot = sig_ana_reactive$plot_last, @@ -536,9 +516,9 @@ significance_analysis_server <- function(id, data, params){ fun_LogIt( message = "- Significance Analysis was performed using DESeq2 pipeline" ) - }else{ + } else { fun_LogIt(message = paste( - "- Significance Analysis was performed using", input$test_method + "- Significance Analysis was performed using", input$test_method )) } # log the significance level @@ -563,9 +543,10 @@ significance_analysis_server <- function(id, data, params){ "- Number of significant genes after correction for", input$comparisons_to_visualize[i], "is", - nrow(sig_results[[input$comparisons_to_visualize[i]]][ - sig_results[[input$comparisons_to_visualize[i]]]$padj < input$significance_level, - ] + nrow( + sig_results[[input$comparisons_to_visualize[i]]][ + sig_results[[input$comparisons_to_visualize[i]]]$padj < input$significance_level, + ] ) )) # log the number of significant genes before correction @@ -573,9 +554,10 @@ significance_analysis_server <- function(id, data, params){ "- Number of significant genes after correction for", input$comparisons_to_visualize[i], "is", - nrow(sig_results[[input$comparisons_to_visualize[i]]][ - sig_results[[input$comparisons_to_visualize[i]]]$pvalue < input$significance_level, - ] + nrow( + sig_results[[input$comparisons_to_visualize[i]]][ + sig_results[[input$comparisons_to_visualize[i]]]$pvalue < input$significance_level, + ] ) )) # log the top 5 significant genes @@ -587,7 +569,7 @@ significance_analysis_server <- function(id, data, params){ decreasing = FALSE ),], 5 ) - }else{ + } else { # get the top 5 significant genes top5 <- head( sig_results[[input$comparisons_to_visualize[i]]][order( @@ -600,8 +582,7 @@ significance_analysis_server <- function(id, data, params){ "- Top 5 significant genes for", input$comparisons_to_visualize[i], "are the following:" - ) - ) + )) fun_LogIt(message = knitr::kable( top5, format = "html", format.args = list(width = 40) ) %>% kableExtra::kable_styling() diff --git a/program/shinyApp/R/significance_analysis/util.R b/program/shinyApp/R/significance_analysis/util.R index 9567073f..505450bf 100644 --- a/program/shinyApp/R/significance_analysis/util.R +++ b/program/shinyApp/R/significance_analysis/util.R @@ -38,9 +38,6 @@ create_new_tab_manual <- function(title, targetPanel, result, contrast, alpha, n # alpha: significance level # ns: namespace function - print("create_new_tab") - print(title) - print(result) # paste together the strings to print # total number of genes compared total_genes <- length(rownames(result)) From 0f141ecf50ed24e65bb51bd678f1e933b60f3013 Mon Sep 17 00:00:00 2001 From: PaulJonasJost Date: Thu, 1 Feb 2024 11:31:51 +0100 Subject: [PATCH 4/5] changed sig_result inot reactive instead of global variable. --- .../shinyApp/R/significance_analysis/server.R | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/program/shinyApp/R/significance_analysis/server.R b/program/shinyApp/R/significance_analysis/server.R index 229e8c68..1d8cc082 100644 --- a/program/shinyApp/R/significance_analysis/server.R +++ b/program/shinyApp/R/significance_analysis/server.R @@ -10,7 +10,8 @@ significance_analysis_server <- function(id, data, params){ scenario = 0, comparisons_for_plot = "all", coldata = NULL, - significance_tabs_to_delete = NULL + significance_tabs_to_delete = NULL, + sig_results = NULL ) ns <- session$ns ## Sidebar UI section @@ -213,17 +214,17 @@ significance_analysis_server <- function(id, data, params){ contrasts[[i]] <- unlist(strsplit(x = input$comparisons[i],split = ":")) } # get the results for each contrast and put it all in a big results object - sig_results <<- list() + sig_ana_reactive$sig_results <<- list() for (i in seq_along(contrasts)) { if(identical( list(test_method = "Wald", test_correction = PADJUST_METHOD[[input$test_correction]]), 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$token]]$SigAna[[input$sample_annotation_types_cmp]][[input$comparisons[i]]] + sig_ana_reactive$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( + sig_ana_reactive$sig_results[[input$comparisons[i]]] <<- DESeq2::results( dds, contrast = c( input$sample_annotation_types_cmp, @@ -233,7 +234,7 @@ significance_analysis_server <- function(id, data, params){ pAdjustMethod = PADJUST_METHOD[[input$test_correction]] ) # 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]]] + res_tmp[[session$token]]$SigAna[[input$sample_annotation_types_cmp]][[input$comparisons[i]]] <<- sig_ana_reactive$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]] @@ -259,7 +260,7 @@ significance_analysis_server <- function(id, data, params){ samples_selected <- colData(data$data)[index_comparisons,] # get the data data_selected <- as.matrix(assay(data$data))[,index_comparisons] - sig_results <<- significance_analysis( + sig_ana_reactive$sig_results <<- significance_analysis( df = as.data.frame(data_selected), samples = as.data.frame(samples_selected), contrasts = contrasts, @@ -269,11 +270,11 @@ significance_analysis_server <- function(id, data, params){ ) } # for each result create a tabPanel - for (i in 1:length(sig_results)) { + for (i in seq_along(sig_ana_reactive$sig_results)) { create_new_tab( title = input$comparisons[i], targetPanel = "significance_analysis_results", - result = sig_results[[input$comparisons[i]]], + result = sig_ana_reactive$sig_results[[input$comparisons[i]]], contrast = contrasts[[i]], alpha = input$significance_level, ns = ns, @@ -336,7 +337,7 @@ significance_analysis_server <- function(id, data, params){ for (i in seq_along(chosenVizSet)) { to_add_tmp <- rownames( filter_significant_result( - result = sig_results[[chosenVizSet[i]]], + result = sig_ana_reactive$sig_results[[chosenVizSet[i]]], alpha = input$significance_level, filter_type = input$sig_to_look_at ) @@ -432,7 +433,7 @@ significance_analysis_server <- function(id, data, params){ ) intersect_set <- vector("list", length(intersects)) intersect_name <- vector("list", length(intersects)) - for(i_inter in 1:length(intersects)){ + for(i_inter in seq_along(intersects)){ # select dataframe for only comparisons considered in intersect df_inter <- as.data.frame(df[,intersects[[i_inter]]]) # as.data.frame for intersects of size 1 rownames(df_inter) <- rownames(df) @@ -461,7 +462,7 @@ significance_analysis_server <- function(id, data, params){ }, content = function(file){ envList <- list( - sig_results = sig_results, + sig_results = sig_ana_reactive$sig_results, input = reactiveValuesToList(input), res2plot = sig_ana_reactive$results_for_plot ) @@ -536,7 +537,7 @@ significance_analysis_server <- function(id, data, params){ )) # for each comparison, log the number of significant genes before and after correction # and the top 5 significant genes - for(i in 1:length(input$comparisons_to_visualize)){ + for(i in seq_along(input$comparisons_to_visualize)){ fun_LogIt(message = paste("####", input$comparisons_to_visualize[i])) # log the number of significant genes after correction fun_LogIt(message = paste( @@ -544,8 +545,8 @@ significance_analysis_server <- function(id, data, params){ input$comparisons_to_visualize[i], "is", nrow( - sig_results[[input$comparisons_to_visualize[i]]][ - sig_results[[input$comparisons_to_visualize[i]]]$padj < input$significance_level, + sig_ana_reactive$sig_results[[input$comparisons_to_visualize[i]]][ + sig_ana_reactive$sig_results[[input$comparisons_to_visualize[i]]]$padj < input$significance_level, ] ) )) @@ -555,8 +556,8 @@ significance_analysis_server <- function(id, data, params){ input$comparisons_to_visualize[i], "is", nrow( - sig_results[[input$comparisons_to_visualize[i]]][ - sig_results[[input$comparisons_to_visualize[i]]]$pvalue < input$significance_level, + sig_ana_reactive$sig_results[[input$comparisons_to_visualize[i]]][ + sig_ana_reactive$sig_results[[input$comparisons_to_visualize[i]]]$pvalue < input$significance_level, ] ) )) @@ -564,16 +565,16 @@ significance_analysis_server <- function(id, data, params){ if(params$PreProcessing_Procedure == "vst_DESeq"){ # get the top 5 significant genes top5 <- head( - sig_results[[input$comparisons_to_visualize[i]]]@result[order( - sig_results[[input$comparisons_to_visualize[i]]]@result$p.adjust, + sig_ana_reactive$sig_results[[input$comparisons_to_visualize[i]]]@result[order( + sig_ana_reactive$sig_results[[input$comparisons_to_visualize[i]]]@result$p.adjust, decreasing = FALSE ),], 5 ) } else { # get the top 5 significant genes top5 <- head( - sig_results[[input$comparisons_to_visualize[i]]][order( - sig_results[[input$comparisons_to_visualize[i]]]$padj, + sig_ana_reactive$sig_results[[input$comparisons_to_visualize[i]]][order( + sig_ana_reactive$sig_results[[input$comparisons_to_visualize[i]]]$padj, decreasing = FALSE ),], 5 ) From f063be663a95c15cc58390e1802b70d56b4979e5 Mon Sep 17 00:00:00 2001 From: PaulJonasJost Date: Thu, 1 Feb 2024 11:32:25 +0100 Subject: [PATCH 5/5] Removed a warning my pycharm. --- program/shinyApp/R/significance_analysis/server.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/shinyApp/R/significance_analysis/server.R b/program/shinyApp/R/significance_analysis/server.R index 1d8cc082..d109a21a 100644 --- a/program/shinyApp/R/significance_analysis/server.R +++ b/program/shinyApp/R/significance_analysis/server.R @@ -197,7 +197,7 @@ significance_analysis_server <- function(id, data, params){ sig_ana_reactive$coldata <- colData(data$data) # delete old panels if(!is.null(sig_ana_reactive$significance_tabs_to_delete)){ - for (i in 1:length(sig_ana_reactive$significance_tabs_to_delete)) { + for (i in seq_along(sig_ana_reactive$significance_tabs_to_delete)) { removeTab( inputId = "significance_analysis_results", target = sig_ana_reactive$significance_tabs_to_delete[[i]]