Skip to content

Commit

Permalink
Fixed error of deleting report events
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJonasJost committed Jan 30, 2025
1 parent d51041b commit f741580
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 47 deletions.
16 changes: 8 additions & 8 deletions program/shinyApp/R/significance_analysis/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ significance_analysis_server <- function(id, data, params){
sig_ana_reactive$coldata <- colData(data$data)
}
req(sig_ana_reactive$coldata)
if(params$PreProcessing_Procedure == "vst_DESeq"){
if(par_tmp[[session$token]]$PreProcessing_Procedure == "vst_DESeq"){
selectInput(
inputId = ns("sample_annotation_types_cmp"),
label = "Choose groups to compare",
choices = params$DESeq_factors,
choices = par_tmp[[session$token]]$DESeq_factors,
multiple = F,
selected = NULL
)
Expand Down Expand Up @@ -84,7 +84,7 @@ significance_analysis_server <- function(id, data, params){
})
# UI to choose test method
output$chooseTest_ui <- renderUI({
if(params$PreProcessing_Procedure == "vst_DESeq"){
if(par_tmp[[session$token]]$PreProcessing_Procedure == "vst_DESeq"){
renderText(
expr = "DESeq is using a Wald test statistic.\nWe are using the same here.",
outputArgs = list(container = pre)
Expand Down Expand Up @@ -131,7 +131,7 @@ significance_analysis_server <- function(id, data, params){
output$chooseGenesToLookAt_ui <- renderUI({
req(input$comparisons_to_visualize)
# choices dependent on preprocess_method
if(params$PreProcessing_Procedure == "vst_DESeq"){
if(par_tmp[[session$token]]$PreProcessing_Procedure == "vst_DESeq"){
choices <- c(
"Significant",
"Upregulated",
Expand Down Expand Up @@ -246,7 +246,7 @@ significance_analysis_server <- function(id, data, params){
}
}
# if preproccesing method was DESeq2, then use DESeq2 for testing
if(params$PreProcessing_Procedure == "vst_DESeq"){
if(par_tmp[[session$token]]$PreProcessing_Procedure == "vst_DESeq"){
if (useBatch){
dds <- data$DESeq_obj_batch_corrected
} else {
Expand Down Expand Up @@ -570,7 +570,7 @@ significance_analysis_server <- function(id, data, params){

)

if(params$PreProcessing_Procedure == "vst_DESeq"){
if(par_tmp[[session$token]]$PreProcessing_Procedure == "vst_DESeq"){
envList$dds <- data$DESeq_obj
}
temp_directory <- file.path(tempdir(), as.integer(Sys.time()))
Expand Down Expand Up @@ -643,7 +643,7 @@ significance_analysis_server <- function(id, data, params){
fun_LogIt(message = "## Differential analysis {.tabset .tabset-fade}")
fun_LogIt(message = "### Info")
# log which tests were performed
if(params$PreProcessing_Procedure == "vst_DESeq"){
if(par_tmp[[session$token]]$PreProcessing_Procedure == "vst_DESeq"){
fun_LogIt(
message = "- Differential Analysis was performed using DESeq2 pipeline"
)
Expand Down Expand Up @@ -692,7 +692,7 @@ significance_analysis_server <- function(id, data, params){
)
))
# log the top 5 significant genes
if(params$PreProcessing_Procedure == "vst_DESeq" & "result" %in% names(sig_ana_reactive$sig_results[[comparisons[i]]])){
if(par_tmp[[session$token]]$PreProcessing_Procedure == "vst_DESeq" & "result" %in% names(sig_ana_reactive$sig_results[[comparisons[i]]])){
top5 <- head(
sig_ana_reactive$sig_results[[comparisons[i]]]@result[order(
sig_ana_reactive$sig_results[[comparisons[i]]]@result$p.adjust,
Expand Down
85 changes: 46 additions & 39 deletions program/shinyApp/R/significance_analysis/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -709,22 +709,22 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns
h5("Volcano plot padj"),
h5("Both Volcano plots"),
h5("Volcano plot pvalue")
),
) %>% helper(type = "markdown", content = "SampleCorr_Downloads"),
splitLayout(
style = "border: 1px solid silver:",
cellWidths = c("35%","35%", "30%"),
actionButton(
inputId = ns("only2Report_Volcano"),
inputId = ns(paste(contrast[1], contrast[2], "only2Report_Volcano", sep = "_")),
label = "Send only to Report",
class = "btn-info"
),
actionButton(
inputId = ns("only2Report_Volcano_both"),
inputId = ns(paste(contrast[1], contrast[2], "only2Report_Volcano_both", sep = "_")),
label = "Send only to Report",
class = "btn-info"
),
actionButton(
inputId = ns("only2Report_Volcano_raw"),
inputId = ns(paste(contrast[1], contrast[2], "only2Report_Volcano_raw", sep = "_")),
label = "Send only to Report",
class = "btn-info"
)
Expand All @@ -737,11 +737,7 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns
label = "Get underlying R code and data",
icon = icon("code")
),
downloadButton(
outputId = ns("getR_Code_Volcano_both"),
label = "Get underlying R code and data",
icon = icon("code")
),
NULL,
downloadButton(
outputId = ns("getR_Code_Volcano_raw"),
label = "Get underlying R code and data",
Expand Down Expand Up @@ -980,38 +976,49 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns
})

# downloadhandlers
observeEvent(input[[ns("only2Report_Volcano")]],{
fun_LogIt(message = "## Differential analysis - Volcano {.tabset .tabset-fade}")
fun_LogIt(message = "### Info")
log_messages_volcano(
sig_ana_reactive$VolcanoPlot + theme(legend.position = "right"),
sig_ana_reactive$data4Volcano,
contrast, file_path
)
fun_LogIt(message = "### Publication Snippet")
fun_LogIt(message = snippet_SigAna(data = res_tmp[[session$token]],
params = par_tmp[[session$token]]))
})
session$userData[[ns(paste(contrast[1], contrast[2], "only2Report_Volcano", sep = "_"))]] <- observeEvent(
input[[ns(paste(contrast[1], contrast[2], "only2Report_Volcano", sep = "_"))]], {
if(!is.null(session$userData[[paste(contrast[1], contrast[2], "only2Report_Volcano_val", sep = "_")]])){
req(input[[ns(paste(contrast[1], contrast[2], "only2Report_Volcano", sep = "_"))]] > session$userData[[paste(contrast[1], contrast[2], "only2Report_Volcano_val", sep = "_")]])
}
fun_LogIt(message = "## Differential analysis - Volcano {.tabset .tabset-fade}")
fun_LogIt(message = "### Info")
log_messages_volcano(sig_ana_reactive$VolcanoPlot, sig_ana_reactive$data4Volcano, contrast, file_path)
fun_LogIt(message = "### Publication Snippet")
fun_LogIt(message = snippet_SigAna(data = res_tmp[[session$token]],
params = par_tmp[[session$token]]))
}
)

observeEvent(input[[ns("only2Report_Volcano_both")]],{
fun_LogIt(message = "## Differential analysis - Volcano {.tabset .tabset-fade}")
fun_LogIt(message = "### Info")
log_messages_volcano(gridExtra::arrangeGrob(sig_ana_reactive$VolcanoPlot_raw, sig_ana_reactive$VolcanoPlot)
, sig_ana_reactive$data4Volcano, contrast, file_path)
# log_messages_volcano(sig_ana_reactive$VolcanoPlot_raw, sig_ana_reactive$data4Volcano, contrast, file_path)
fun_LogIt(message = "### Publication Snippet")
fun_LogIt(message = snippet_SigAna(data = res_tmp[[session$token]],
params = par_tmp[[session$token]]))
})
session$userData[[ns(paste(contrast[1], contrast[2], "only2Report_Volcano_both", sep = "_"))]] <- observeEvent(
input[[ns(paste(contrast[1], contrast[2], "only2Report_Volcano_both", sep = "_"))]],{
if(!is.null(session$userData[[paste(contrast[1], contrast[2], "only2Report_Volcano_both_val", sep = "_")]])){
req(input[[ns(paste(contrast[1], contrast[2], "only2Report_Volcano_both", sep = "_"))]] > session$userData[[paste(contrast[1], contrast[2], "only2Report_Volcano_both_val", sep = "_")]])
}
fun_LogIt(message = "## Differential analysis - Volcano {.tabset .tabset-fade}")
fun_LogIt(message = "### Info")
log_messages_volcano(gridExtra::arrangeGrob(sig_ana_reactive$VolcanoPlot_raw, sig_ana_reactive$VolcanoPlot),
sig_ana_reactive$data4Volcano, contrast, file_path)
#log_messages_volcano(sig_ana_reactive$VolcanoPlot_raw, sig_ana_reactive$data4Volcano, contrast, file_path)
fun_LogIt(message = "### Publication Snippet")
fun_LogIt(message = snippet_SigAna(data = res_tmp[[session$token]],
params = par_tmp[[session$token]]))
}
)

observeEvent(input[[ns("only2Report_Volcano_raw")]],{
fun_LogIt(message = "## Differential analysis - Volcano {.tabset .tabset-fade}")
fun_LogIt(message = "### Info")
log_messages_volcano(sig_ana_reactive$VolcanoPlot_raw, sig_ana_reactive$data4Volcano, contrast, file_path)
fun_LogIt(message = "### Publication Snippet")
fun_LogIt(message = snippet_SigAna(data = res_tmp[[session$token]],
params = par_tmp[[session$token]]))
})
session$userData[[ns(paste(contrast[1], contrast[2], "only2Report_Volcano_raw", sep = "_"))]] <- observeEvent(
input[[ns(paste(contrast[1], contrast[2], "only2Report_Volcano_raw", sep = "_"))]],{
if(!is.null(session$userData[[paste(contrast[1], contrast[2], "only2Report_Volcano_raw_val", sep = "_")]])){
req(input[[ns(paste(contrast[1], contrast[2], "only2Report_Volcano_raw", sep = "_"))]] > session$userData[[paste(contrast[1], contrast[2], "only2Report_Volcano_raw_val", sep = "_")]])
}
fun_LogIt(message = "## Differential analysis - Volcano {.tabset .tabset-fade}")
fun_LogIt(message = "### Info")
log_messages_volcano(sig_ana_reactive$VolcanoPlot_raw, sig_ana_reactive$data4Volcano, contrast, file_path)
fun_LogIt(message = "### Publication Snippet")
fun_LogIt(message = snippet_SigAna(data = res_tmp[[session$token]],
params = par_tmp[[session$token]]))
}
)

output[[ns("getR_Code_Volcano")]] <- downloadHandler(
filename = function(){
Expand Down

0 comments on commit f741580

Please sign in to comment.