diff --git a/R/module-qc-server.R b/R/module-qc-server.R index 428eb47..175f8f7 100644 --- a/R/module-qc-server.R +++ b/R/module-qc-server.R @@ -170,17 +170,19 @@ qcServer <- function(input, output, session,parent_session, loadpage_input,get_d which.Protein = protein, originalPlot = original, summaryPlot = input$summ, - address = file, isPlotly = TRUE + address="Ex_", isPlotly = TRUE )[[1]] - return(plot) + # return(plot) } else if (loadpage_input()$BIO == "PTM"){ - dataProcessPlotsPTM(preprocess_data(), + plot <- dataProcessPlotsPTM(preprocess_data(), type=input$type1, which.PTM = protein, + originalPlot = original, summaryPlot = input$summ, - address = file) + address="Ex_", isPlotly = TRUE)[[1]] + # return(plot) } else{ plot <- dataProcessPlots(data = preprocess_data(), @@ -194,12 +196,14 @@ qcServer <- function(input, output, session,parent_session, loadpage_input,get_d originalPlot = original, summaryPlot = input$summ, save_condition_plot_result = FALSE, - address = file, + address="Ex_", isPlotly = TRUE )[[1]] - return(plot) + # return(plot) } + enable("plotresults_qc") + return(plot) } else { return(NULL) @@ -367,17 +371,25 @@ qcServer <- function(input, output, session,parent_session, loadpage_input,get_d # } # }) + + ### OUTPUT #### + output$plotresults_qc = downloadHandler( + filename = function() { + paste("SummaryPlot-", Sys.Date(), ".zip", sep="") + }, + content = function(file) { + files <- list.files(getwd(), pattern = "^Ex_", full.names = TRUE) + file_info <- file.info(files) + latest_file <- files[which.max(file_info$mtime)] + print(latest_file) + file.copy(latest_file, file) + } + ) + output$showplot = renderUI({ ns<- session$ns - - # PTM plotly plots are still under development - if (loadpage_input()$BIO == "PTM") { - output$theplot = renderPlot(theplot()) - op <- plotOutput(ns("theplot")) - } else { - output$theplot = renderPlotly(theplot()) - op <- plotlyOutput(ns("theplot")) - } + output$theplot = renderPlotly(theplot()) + op <- plotlyOutput(ns("theplot")) tagList( op, diff --git a/R/module-qc-ui.R b/R/module-qc-ui.R index 346eeba..550cc6d 100644 --- a/R/module-qc-ui.R +++ b/R/module-qc-ui.R @@ -227,7 +227,7 @@ qcUI <- function(id) { "No feature legend"="NA")) ), - + p("Use the camera icon on the top right of the plot to download as PNG"), uiOutput(ns("Which")), tags$br() ), @@ -235,8 +235,10 @@ qcUI <- function(id) { # tags$br(), # tags$br(), # tags$h4("Calculation in progress...")), - uiOutput(ns("showplot")), + disabled(downloadButton(ns("plotresults_qc"), "Save plot results as Zip")), + uiOutput(ns("showplot")) # disabled(downloadButton(ns("saveplot"), "Save this plot")) + ), tabPanel("Download Data", #verbatimTextOutput('effect'), diff --git a/R/module-statmodel-server.R b/R/module-statmodel-server.R index 0991fe5..6cb2e61 100644 --- a/R/module-statmodel-server.R +++ b/R/module-statmodel-server.R @@ -399,15 +399,31 @@ statmodelServer <- function(input, output, session,parent_session, loadpage_inpu } if (loadpage_input()$BIO=="PTM"){ - plot1 = groupComparisonPlotsPTM(data_comparison(), - input$typeplot, - sig=input$sig, - FCcutoff=input$FC, - logBase.pvalue=as.integer(input$logp), - ProteinName = input$pname, - which.Comparison = input$whichComp, - address = FALSE) - + tryCatch({ + if(toupper(input$typeplot) == "COMPARISONPLOT") { + remove_modal_spinner() + stop( 'Comparison Plot is not offered by MSstatsPTM at the moment' ) + } + plot = groupComparisonPlotsPTM(data_comparison(), + input$typeplot, + sig=input$sig, + FCcutoff=input$FC, + logBase.pvalue=as.integer(input$logp), + ProteinName = input$pname, + numProtein=input$nump, + which.Comparison = input$whichComp, + address = "Ex_", + isPlotly = TRUE) + if(length(plot) == 3) { # return adjusted if we have it + plot1 = plot[[3]] + } else { + plot1 = plot[[1]] + } + remove_modal_spinner() + },error = function(e){ + remove_modal_spinner() + stop( '** Cannnot generate multiple plots in a screen. Please refine selection or save to a pdf. **' )} + ) } else if(loadpage_input()$DDA_DIA=="TMT"){ tryCatch({ @@ -717,18 +733,10 @@ statmodelServer <- function(input, output, session,parent_session, loadpage_inpu observeEvent(input$viewresults, { ns <- session$ns - # PTM plotly plots are still under development - if (loadpage_input()$BIO == "PTM") { - output$comp_plots = renderPlot({ - group_comparison(FALSE, FALSE) - }) - op <- plotOutput(ns("comp_plots")) - } else { - output$comp_plots = renderPlotly({ - group_comparison(FALSE, FALSE) - }) - op <- plotlyOutput(ns("comp_plots"), height = input$height) - } + output$comp_plots = renderPlotly({ + group_comparison(FALSE, FALSE) + }) + op <- plotlyOutput(ns("comp_plots"), height = input$height) insertUI( selector = paste0("#", ns("comparison_plots")), ui=tags$div( diff --git a/R/module-statmodel-ui.R b/R/module-statmodel-ui.R index 7769faa..2d17955 100644 --- a/R/module-statmodel-ui.R +++ b/R/module-statmodel-ui.R @@ -158,7 +158,10 @@ statmodelUI <- function(id) { Volcano Plot comparison, you must save the results \ as a HTML."), conditionalPanel( - condition = "input['loadpage-BIO'] !== 'PTM'", + condition = "input['loadpage-BIO'] == 'PTM' && input['statmodel-typeplot'] == 'ComparisonPlot'", + p("Comparison Plot is not offered by MSstatsPTM at the moment")), + conditionalPanel( + condition = "input['loadpage-BIO'] !== 'PTM_'", actionButton(ns("viewresults"), "View plot in browser (only for one \ comparison/protein)")),