diff --git a/R/app_ui.R b/R/app_ui.R index 45c2112..9986fc5 100644 --- a/R/app_ui.R +++ b/R/app_ui.R @@ -44,18 +44,18 @@ app_ui <- function(request) { sidebarMenu(id = "MainMenu", flat = FALSE, tags$li(class = "header", style = "color: grey; margin-top: 10px; margin-bottom: 10px; padding-left: 15px;", "Menu"), - menuItem("Home", tabName = "welcome", icon = icon("house")), + menuItem("Home", tabName = "welcome", icon = icon("house")), tags$li(class = "header", style = "color: grey; margin-top: 18px; margin-bottom: 10px; padding-left: 15px;", "Genotype Processing"), menuItem("DArT Report2VCF", tabName = "dosage2vcf", icon = icon("share-from-square")), menuItem("Updog Dosage Calling", tabName = "updog", icon = icon("list-ol")), menuItem("VCF Filtering", tabName = "filtering", icon = icon("filter")), + tags$li(class = "header", style = "color: grey; margin-top: 18px; margin-bottom: 10px; padding-left: 15px;", "Summary Metrics"), + menuItem("Genomic Diversity", tabName = "diversity", icon = icon("chart-pie")), tags$li(class = "header", style = "color: grey; margin-top: 18px; margin-bottom: 10px; padding-left: 15px;", "Population Structure"), menuItem("PCA", tabName = "pca", icon = icon("chart-simple")), menuItem("DAPC", tabName = "dapc", icon = icon("circle-nodes")), - tags$li(class = "header", style = "color: grey; margin-top: 18px; margin-bottom: 10px; padding-left: 15px;", "Summary Metrics"), - menuItem("Genomic Diversity", tabName = "diversity", icon = icon("chart-pie")), tags$li(class = "header", style = "color: grey; margin-top: 18px; margin-bottom: 10px; padding-left: 15px;", "GWAS"), - menuItem("GWASpoly", tabName = "gwas", icon = icon("think-peaks")), + menuItem("GWASpoly", tabName = "gwas", icon = icon("think-peaks")), tags$li(class = "header", style = "color: grey; margin-top: 18px; margin-bottom: 10px; padding-left: 15px;", "Genomic Selection"), menuItem( span("Predictive Ability", bs4Badge("beta", position = "right", color = "success")), diff --git a/R/mod_DosageCall.R b/R/mod_DosageCall.R index 50a161b..da40f42 100644 --- a/R/mod_DosageCall.R +++ b/R/mod_DosageCall.R @@ -88,7 +88,8 @@ mod_DosageCall_ui <- function(id){ p(HTML("Parameters description:"), actionButton(ns("goPar"), icon("arrow-up-right-from-square", verify_fa = FALSE) )), hr(), p(HTML("Results description:"), actionButton(ns("goRes"), icon("arrow-up-right-from-square", verify_fa = FALSE) )), hr(), p(HTML("How to cite:"), actionButton(ns("goCite"), icon("arrow-up-right-from-square", verify_fa = FALSE) )), hr(), - p(HTML("Updog tutorial:"), actionButton(ns("goUpdog"), icon("arrow-up-right-from-square", verify_fa = FALSE), onclick ="window.open('https://dcgerard.github.io/updog/', '_blank')" )), + p(HTML("Updog tutorial:"), actionButton(ns("goUpdog"), icon("arrow-up-right-from-square", verify_fa = FALSE), onclick ="window.open('https://dcgerard.github.io/updog/', '_blank')" )), hr(), + actionButton(ns("dosage_summary"), "Summary"), circle = FALSE, status = "warning", icon = icon("info"), width = "500px", @@ -429,6 +430,68 @@ mod_DosageCall_server <- function(input, output, session, parent_session){ ex <- system.file("iris_DArT_MADC.csv", package = "BIGapp") file.copy(ex, file) }) + + ##Summary Info + dosage_summary_info <- function() { + #Handle possible NULL values for inputs + genotype_file_name <- if (!is.null(input$madc_file$name)) input$madc_file$name else "No file selected" + report_file_name <- if (!is.null(input$madc_passport$name)) input$madc_passport$name else "No file selected" + selected_ploidy <- if (!is.null(input$ploidy)) as.character(input$ploidy) else "Not selected" + + #Print the summary information + cat( + "BIGapp Dosage Calling Summary\n", + "\n", + paste0("Date: ", Sys.Date()), "\n", + paste("R Version:", R.Version()$version.string), "\n", + "\n", + "### Input Files ###\n", + "\n", + paste("Input Genotype File:", genotype_file_name), "\n", + paste("Input Passport File:", report_file_name), "\n", + "\n", + "### User Selected Parameters ###\n", + "\n", + paste("Selected Ploidy:", selected_ploidy), "\n", + paste("Selected Updog Model:", input$updog_model), "\n", + "\n", + "### R Packages Used ###\n", + "\n", + paste("BIGapp:", packageVersion("BIGapp")), "\n", + paste("BIGr:", packageVersion("BIGr")), "\n", + paste("Updog:", packageVersion("updog")), "\n", + paste("dplyr:", packageVersion("dplyr")), "\n", + sep = "" + ) + } + + # Popup for analysis summary + observeEvent(input$dosage_summary, { + showModal(modalDialog( + title = "Summary Information", + size = "l", + easyClose = TRUE, + footer = tagList( + modalButton("Close"), + downloadButton("download_dosage_info", "Download") + ), + pre( + paste(capture.output(dosage_summary_info()), collapse = "\n") + ) + )) + }) + + + # Download Summary Info + output$download_dosage_info <- downloadHandler( + filename = function() { + paste("DosageCalling_summary_", Sys.Date(), ".txt", sep = "") + }, + content = function(file) { + # Write the summary info to a file + writeLines(paste(capture.output(dosage_summary_info()), collapse = "\n"), file) + } + ) } ## To be copied in the UI diff --git a/R/mod_Filtering.R b/R/mod_Filtering.R index ef3f23b..4bc37e2 100644 --- a/R/mod_Filtering.R +++ b/R/mod_Filtering.R @@ -46,10 +46,8 @@ mod_Filtering_ui <- function(id){ div(style="display:inline-block; float:right",dropdownButton( tags$h3("Updog Filter Parameters"), "You can download examples of the expected file here: \n", - downloadButton(ns('download_vcf'), "Download VCF Example File"), - # "Add description of each filter. Presently, all filtering parameters that are typically used for processing - # a VCF file from Updog dosage calling are included. If a VCF file does not contain these values, it will only be - # filtered for read depth, missing data, and maf.", + downloadButton(ns('download_vcf'), "Download VCF Example File"), hr(), + actionButton(ns("filtering_summary"), "Summary"), circle = FALSE, status = "warning", icon = icon("info"), width = "300px", @@ -624,6 +622,74 @@ mod_Filtering_server <- function(input, output, session, parent_session){ ex <- system.file("iris_DArT_VCF.vcf.gz", package = "BIGapp") file.copy(ex, file) }) + + ##Summary Info + filtering_summary_info <- function() { + #Handle possible NULL values for inputs + genotype_file_name <- if (!is.null(input$updog_rdata$name)) input$updog_rdata$name else "No file selected" + selected_ploidy <- if (!is.null(input$filter_ploidy)) as.character(input$filter_ploidy) else "Not selected" + + #Print the summary information + cat( + "BIGapp VCF Filtering Summary\n", + "\n", + paste0("Date: ", Sys.Date()), "\n", + paste(R.Version()$version.string), "\n", + "\n", + "### Input Files ###\n", + "\n", + paste("Input Genotype File:", genotype_file_name), "\n", + "\n", + "### User Selected Parameters ###\n", + "\n", + paste("Selected Ploidy:", selected_ploidy), "\n", + paste("MAF Filter:", input$filter_maf), "\n", + paste("Min Read Depth (Marker per Sample):", input$size_depth), "\n", + paste("Remove SNPs with >= % missing data:", input$snp_miss), "\n", + paste("Remove Samples with >= % missing data:", input$sample_miss), "\n", + paste("Use Updog Filtering Parameters?:", input$use_updog), "\n", + paste("Max OD (Updog filter):", ifelse(input$use_updog,input$OD_filter, "NA")), "\n", + paste("Bias Minimum (Updog filter):", ifelse(input$use_updog,input$Bias[1], "NA")), "\n", + paste("Bias Maximum (Updog filter):", ifelse(input$use_updog,input$Bias[2], "NA")), "\n", + paste("Max Prop_mis (Updog filter):", ifelse(input$use_updog,input$Prop_mis,"NA")), "\n", + paste("Minimum maxpostprob (Updog filter):", ifelse(input$use_updog,input$maxpostprob_filter,"NA")), "\n", + "\n", + "### R Packages Used ###\n", + "\n", + paste("BIGapp:", packageVersion("BIGapp")), "\n", + paste("BIGr:", packageVersion("BIGr")), "\n", + paste("Updog:", packageVersion("updog")), "\n", + sep = "" + ) + } + + # Popup for analysis summary + observeEvent(input$filtering_summary, { + showModal(modalDialog( + title = "Summary Information", + size = "l", + easyClose = TRUE, + footer = tagList( + modalButton("Close"), + downloadButton("download_filtering_info", "Download") + ), + pre( + paste(capture.output(filtering_summary_info()), collapse = "\n") + ) + )) + }) + + + # Download Summary Info + output$download_filtering_info <- downloadHandler( + filename = function() { + paste("Filtering_summary_", Sys.Date(), ".txt", sep = "") + }, + content = function(file) { + # Write the summary info to a file + writeLines(paste(capture.output(filtering_summary_info()), collapse = "\n"), file) + } + ) } ## To be copied in the UI diff --git a/R/mod_GS.R b/R/mod_GS.R index 51d57fe..6ff4c37 100644 --- a/R/mod_GS.R +++ b/R/mod_GS.R @@ -46,9 +46,8 @@ mod_GS_ui <- function(id){ "You can download examples of the expected input input files here: \n", downloadButton(ns('download_vcft'), "Download Training VCF Example File"), downloadButton(ns('download_pheno'), "Download Passport Example File"), - downloadButton(ns('download_vcfp'), "Download Prediction VCF Example File"), - - #"GP uses the rrBLUP package: It can impute missing data, adapt to different ploidy, perform 5-fold cross validations with different number of iterations, run multiple traits, and accept multiple fixed effects.", + downloadButton(ns('download_vcfp'), "Download Prediction VCF Example File"),hr(), + actionButton(ns("pred_summary"), "Summary"), circle = FALSE, status = "warning", icon = icon("info"), width = "300px", @@ -720,6 +719,76 @@ mod_GS_server <- function(input, output, session, parent_session){ ex <- system.file("iris_passport_file.csv", package = "BIGapp") file.copy(ex, file) }) + + ##Summary Info + pred_summary_info <- function() { + # Handle possible NULL values for inputs + dosage_file_name <- if (!is.null(input$pred_known_file$name)) input$pred_known_file$name else "No file selected" + est_file_name <- if (!is.null(input$pred_est_file$name)) input$pred_est_file$name else "No file selected" + passport_file_name <- if (!is.null(input$pred_trait_file$name)) input$pred_trait_file$name else "No file selected" + selected_ploidy <- if (!is.null(input$pred_est_ploidy)) as.character(input$pred_est_ploidy) else "Not selected" + + # Print the summary information + cat( + "BIGapp Selection Summary\n", + "\n", + paste0("Date: ", Sys.Date()), "\n", + paste("R Version:", R.Version()$version.string), "\n", + "\n", + "### Input Files ###\n", + "\n", + paste("Input Genotype File 1:", dosage_file_name), "\n", + paste("Input Genotype File 2:", est_file_name), "\n", + paste("Input Passport File:", passport_file_name), "\n", + "\n", + "### User Selected Parameters ###\n", + "\n", + paste("Selected Ploidy:", selected_ploidy), "\n", + paste("Selected Trait(s):", input$pred_trait_info2), "\n", + paste("Selected Fixed Effects:", input$pred_fixed_info2), "\n", + #paste("Selected Model:", input$pred_fixed_info2), "\n", + #paste("Selected Matrix:", input$pred_fixed_info2), "\n", + "\n", + "### R Packages Used ###\n", + "\n", + paste("BIGapp:", packageVersion("BIGapp")), "\n", + paste("AGHmatrix:", packageVersion("AGHmatrix")), "\n", + paste("ggplot2:", packageVersion("ggplot2")), "\n", + paste("rrBLUP:", packageVersion("rrBLUP")), "\n", + paste("vcfR:", packageVersion("vcfR")), "\n", + paste("dplyr:", packageVersion("dplyr")), "\n", + paste("tidyr:", packageVersion("tidyr")), "\n", + sep = "" + ) + } + + # Popup for analysis summary + observeEvent(input$pred_summary, { + showModal(modalDialog( + title = "Summary Information", + size = "l", + easyClose = TRUE, + footer = tagList( + modalButton("Close"), + downloadButton("download_pred_info", "Download") + ), + pre( + paste(capture.output(pred_summary_info()), collapse = "\n") + ) + )) + }) + + + # Download Summary Info + output$download_pred_info <- downloadHandler( + filename = function() { + paste("pred_summary_", Sys.Date(), ".txt", sep = "") + }, + content = function(file) { + # Write the summary info to a file + writeLines(paste(capture.output(pred_summary_info()), collapse = "\n"), file) + } + ) } ## To be copied in the UI diff --git a/R/mod_GSAcc.R b/R/mod_GSAcc.R index 17fe578..560fe17 100644 --- a/R/mod_GSAcc.R +++ b/R/mod_GSAcc.R @@ -58,7 +58,8 @@ mod_GSAcc_ui <- function(id){ tags$h3("GP Parameters"), "You can download examples of the expected input input files here: \n", downloadButton(ns('download_vcf'), "Download VCF Example File"), - downloadButton(ns('download_pheno'), "Download Passport Example File"), + downloadButton(ns('download_pheno'), "Download Passport Example File"),hr(), + actionButton(ns("predAcc_summary"), "Summary"), circle = FALSE, status = "warning", icon = icon("info"), width = "300px", @@ -783,6 +784,74 @@ mod_GSAcc_server <- function(input, output, session, parent_session){ ex <- system.file("iris_passport_file.csv", package = "BIGapp") file.copy(ex, file) }) + + ##Summary Info + predAcc_summary_info <- function() { + # Handle possible NULL values for inputs + dosage_file_name <- if (!is.null(input$pred_file$name)) input$pred_file$name else "No file selected" + passport_file_name <- if (!is.null(input$trait_file$name)) input$trait_file$name else "No file selected" + selected_ploidy <- if (!is.null(input$pred_ploidy)) as.character(input$pred_ploidy) else "Not selected" + + # Print the summary information + cat( + "BIGapp Selection Model CV Summary\n", + "\n", + paste0("Date: ", Sys.Date()), "\n", + paste("R Version:", R.Version()$version.string), "\n", + "\n", + "### Input Files ###\n", + "\n", + paste("Input Genotype File:", dosage_file_name), "\n", + paste("Input Passport File:", passport_file_name), "\n", + "\n", + "### User Selected Parameters ###\n", + "\n", + paste("Selected Ploidy:", selected_ploidy), "\n", + paste("Selected Trait(s):", input$pred_trait_info), "\n", + paste("Selected Fixed Effects:", input$pred_fixed_info), "\n", + paste("Selected Model:", advanced_options$pred_model), "\n", + paste("Selected Matrix:", advanced_options$pred_matrix), "\n", + "\n", + "### R Packages Used ###\n", + "\n", + paste("BIGapp:", packageVersion("BIGapp")), "\n", + paste("AGHmatrix:", packageVersion("AGHmatrix")), "\n", + paste("ggplot2:", packageVersion("ggplot2")), "\n", + paste("rrBLUP:", packageVersion("rrBLUP")), "\n", + paste("vcfR:", packageVersion("vcfR")), "\n", + paste("dplyr:", packageVersion("dplyr")), "\n", + paste("tidyr:", packageVersion("tidyr")), "\n", + sep = "" + ) + } + + # Popup for analysis summary + observeEvent(input$predAcc_summary, { + showModal(modalDialog( + title = "Summary Information", + size = "l", + easyClose = TRUE, + footer = tagList( + modalButton("Close"), + downloadButton("download_predAcc_info", "Download") + ), + pre( + paste(capture.output(predAcc_summary_info()), collapse = "\n") + ) + )) + }) + + + # Download Summary Info + output$download_predAcc_info <- downloadHandler( + filename = function() { + paste("predAcc_summary_", Sys.Date(), ".txt", sep = "") + }, + content = function(file) { + # Write the summary info to a file + writeLines(paste(capture.output(predAcc_summary_info()), collapse = "\n"), file) + } + ) } ## To be copied in the UI diff --git a/R/mod_PCA.R b/R/mod_PCA.R index 2e52cf9..b9a56ed 100644 --- a/R/mod_PCA.R +++ b/R/mod_PCA.R @@ -35,7 +35,7 @@ mod_PCA_ui <- function(id){ tags$h3("PCA Inputs"), "You can download examples of the expected files here: \n", downloadButton(ns('download_vcf'), "Download VCF Example File"), - downloadButton(ns('download_pheno'), "Download Passport Example File"), + downloadButton(ns('download_pheno'), "Download Passport Example File"),hr(), actionButton(ns("pca_summary"), "Summary"), circle = FALSE, status = "warning", diff --git a/R/mod_dapc.R b/R/mod_dapc.R index abcffbb..1399866 100644 --- a/R/mod_dapc.R +++ b/R/mod_dapc.R @@ -25,8 +25,8 @@ mod_dapc_ui <- function(id){ div(style="display:inline-block; float:right",dropdownButton( tags$h3("DAPC Inputs"), "You can download an examples of the expected input file here: \n", - downloadButton(ns('download_vcf'), "Download VCF Example File"), - #"DAPC Input file and analysis info. The DAPC analysis is broken down into two steps. The first step (Step 1), uses Kmeans clustering to estimate the most likely number of clusters within the dataset. This is visualized in the BIC plot and is typically the minimum BIC value. Step 2 is the DAPC analysis where the most likely value for K (number of clusters) is input and the cluster memberships are determined in the DAPC results", + downloadButton(ns('download_vcf'), "Download VCF Example File"),hr(), + actionButton(ns("dapc_summary"), "Summary"), circle = FALSE, status = "warning", icon = icon("info"), width = "300px", @@ -425,6 +425,70 @@ mod_dapc_server <- function(input, output, session, parent_session){ ex <- system.file("iris_DArT_VCF.vcf.gz", package = "BIGapp") file.copy(ex, file) }) + + ##Summary Info + dapc_summary_info <- function() { + #Handle possible NULL values for inputs + dosage_file_name <- if (!is.null(input$dosage_file$name)) input$dosage_file$name else "No file selected" + #passport_file_name <- if (!is.null(input$passport_file$name)) input$passport_file$name else "No file selected" + selected_ploidy <- if (!is.null(input$dapc_ploidy)) as.character(input$dapc_ploidy) else "Not selected" + + #Print the summary information + cat( + "BIGapp DAPC Summary\n", + "\n", + paste0("Date: ", Sys.Date()), "\n", + paste("R Version:", R.Version()$version.string), "\n", + "\n", + "### Input Files ###\n", + "\n", + paste("Input Genotype File:", dosage_file_name), "\n", + #paste("Input Passport File:", passport_file_name), "\n", + "\n", + "### User Selected Parameters ###\n", + "\n", + paste("Selected Ploidy:", selected_ploidy), "\n", + paste("Maximum K:", input$dapc_kmax), "\n", + paste("Number of Clusters (K):", input$dapc_k), "\n", + "\n", + "### R Packages Used ###\n", + "\n", + paste("BIGapp:", packageVersion("BIGapp")), "\n", + paste("adegenet:", packageVersion("adegenet")), "\n", + paste("ggplot2:", packageVersion("ggplot2")), "\n", + paste("vcfR:", packageVersion("vcfR")), "\n", + paste("RColorBrewer:", packageVersion("RColorBrewer")), "\n", + sep = "" + ) + } + + # Popup for analysis summary + observeEvent(input$dapc_summary, { + showModal(modalDialog( + title = "Summary Information", + size = "l", + easyClose = TRUE, + footer = tagList( + modalButton("Close"), + downloadButton("download_dapc_info", "Download") + ), + pre( + paste(capture.output(dapc_summary_info()), collapse = "\n") + ) + )) + }) + + + # Download Summary Info + output$download_dapc_info <- downloadHandler( + filename = function() { + paste("dapc_summary_", Sys.Date(), ".txt", sep = "") + }, + content = function(file) { + # Write the summary info to a file + writeLines(paste(capture.output(dapc_summary_info()), collapse = "\n"), file) + } + ) } ## To be copied in the UI diff --git a/R/mod_diversity.R b/R/mod_diversity.R index dc4bba9..a9c3141 100644 --- a/R/mod_diversity.R +++ b/R/mod_diversity.R @@ -20,7 +20,8 @@ mod_diversity_ui <- function(id){ div(style="display:inline-block; float:right",dropdownButton( tags$h3("Diversity Parameters"), "You can download an examples of the expected input file here: \n", - downloadButton(ns('download_vcf'), "Download VCF Example File"), + downloadButton(ns('download_vcf'), "Download VCF Example File"),hr(), + actionButton(ns("diversity_summary"), "Summary"), circle = FALSE, status = "warning", icon = icon("info"), width = "300px", @@ -428,6 +429,65 @@ mod_diversity_server <- function(input, output, session, parent_session){ ex <- system.file("iris_DArT_VCF.vcf.gz", package = "BIGapp") file.copy(ex, file) }) + + ##Summary Info + diversity_summary_info <- function() { + # Handle possible NULL values for inputs + dosage_file_name <- if (!is.null(input$diversity_file$name)) input$diversity_file$name else "No file selected" + selected_ploidy <- if (!is.null(input$diversity_ploidy)) as.character(input$diversity_ploidy) else "Not selected" + + # Print the summary information + cat( + "BIGapp Summary Metrics Summary\n", + "\n", + paste0("Date: ", Sys.Date()), "\n", + paste(R.Version()$version.string), "\n", + "\n", + "### Input Files ###\n", + "\n", + paste("Input Genotype File:", dosage_file_name), "\n", + "\n", + "### User Selected Parameters ###\n", + "\n", + paste("Selected Ploidy:", selected_ploidy), "\n", + "\n", + "### R Packages Used ###\n", + "\n", + paste("BIGapp:", packageVersion("BIGapp")), "\n", + paste("BIGr:", packageVersion("BIGr")), "\n", + paste("ggplot2:", packageVersion("ggplot2")), "\n", + paste("vcfR:", packageVersion("vcfR")), "\n", + sep = "" + ) + } + + # Popup for analysis summary + observeEvent(input$diversity_summary, { + showModal(modalDialog( + title = "Summary Information", + size = "l", + easyClose = TRUE, + footer = tagList( + modalButton("Close"), + downloadButton("download_diversity_info", "Download") + ), + pre( + paste(capture.output(diversity_summary_info()), collapse = "\n") + ) + )) + }) + + + # Download Summary Info + output$download_diversity_info <- downloadHandler( + filename = function() { + paste("diversity_summary_", Sys.Date(), ".txt", sep = "") + }, + content = function(file) { + # Write the summary info to a file + writeLines(paste(capture.output(diversity_summary_info()), collapse = "\n"), file) + } + ) } ## To be copied in the UI diff --git a/R/mod_dosage2vcf.R b/R/mod_dosage2vcf.R index 2514163..5b13655 100644 --- a/R/mod_dosage2vcf.R +++ b/R/mod_dosage2vcf.R @@ -30,6 +30,7 @@ mod_dosage2vcf_ui <- function(id){ p(HTML("Parameters description:"), actionButton(ns("goPar"), icon("arrow-up-right-from-square", verify_fa = FALSE) )), hr(), p(HTML("Graphics description:"), actionButton(ns("goRes"), icon("arrow-up-right-from-square", verify_fa = FALSE) )), hr(), p(HTML("How to cite:"), actionButton(ns("goCite"), icon("arrow-up-right-from-square", verify_fa = FALSE) )), hr(), + actionButton(ns("d2vcf_summary"), "Summary"), circle = FALSE, status = "warning", icon = icon("info"), width = "500px", @@ -227,6 +228,65 @@ mod_dosage2vcf_server <- function(input, output, session, parent_session){ updateProgressBar(session = session, id = "dosage2vcf_pb", value = 100, title = "Complete! - Downloading VCF") } ) + + ##Summary Info + d2vcf_summary_info <- function() { + #Handle possible NULL values for inputs + report_file_name <- if (!is.null(input$report_file$name)) input$report_file$name else "No file selected" + counts_file_name <- if (!is.null(input$counts_file$name)) input$counts_file$name else "No file selected" + selected_ploidy <- if (!is.null(input$dosage2vcf_ploidy)) as.character(input$dosage2vcf_ploidy) else "Not selected" + + #Print the summary information + cat( + "BIGapp Dosage2VCF Summary\n", + "\n", + paste0("Date: ", Sys.Date()), "\n", + paste("R Version:", R.Version()$version.string), "\n", + "\n", + "### Input Files ###\n", + "\n", + paste("Input Dosage Report File:", report_file_name), "\n", + paste("Input Counts File:", counts_file_name), "\n", + "\n", + "### User Selected Parameters ###\n", + "\n", + paste("Selected Ploidy:", selected_ploidy), "\n", + "\n", + "### R Packages Used ###\n", + "\n", + paste("BIGapp:", packageVersion("BIGapp")), "\n", + paste("BIGr:", packageVersion("BIGr")), "\n", + sep = "" + ) + } + + # Popup for analysis summary + observeEvent(input$d2vcf_summary, { + showModal(modalDialog( + title = "Summary Information", + size = "l", + easyClose = TRUE, + footer = tagList( + modalButton("Close"), + downloadButton("download_d2vcf_info", "Download") + ), + pre( + paste(capture.output(d2vcf_summary_info()), collapse = "\n") + ) + )) + }) + + + # Download Summary Info + output$download_d2vcf_info <- downloadHandler( + filename = function() { + paste("Dosage2VCF_summary_", Sys.Date(), ".txt", sep = "") + }, + content = function(file) { + # Write the summary info to a file + writeLines(paste(capture.output(d2vcf_summary_info()), collapse = "\n"), file) + } + ) } ## To be copied in the UI diff --git a/R/mod_gwas.R b/R/mod_gwas.R index beeafb0..beae246 100644 --- a/R/mod_gwas.R +++ b/R/mod_gwas.R @@ -42,7 +42,8 @@ mod_gwas_ui <- function(id){ p(HTML("Parameters description:"), actionButton(ns("goGWASpar"), icon("arrow-up-right-from-square", verify_fa = FALSE) )), hr(), p(HTML("Results description:"), actionButton(ns("goGWASgraph"), icon("arrow-up-right-from-square", verify_fa = FALSE) )), hr(), p(HTML("How to cite:"), actionButton(ns("goGWAScite"), icon("arrow-up-right-from-square", verify_fa = FALSE) )), hr(), - p(HTML("GWASpoly tutorial:"), actionButton(ns("goGWASpoly"), icon("arrow-up-right-from-square", verify_fa = FALSE), onclick ="window.open('https://jendelman.github.io/GWASpoly/GWASpoly.html', '_blank')" )), + p(HTML("GWASpoly tutorial:"), actionButton(ns("goGWASpoly"), icon("arrow-up-right-from-square", verify_fa = FALSE), onclick ="window.open('https://jendelman.github.io/GWASpoly/GWASpoly.html', '_blank')" )),hr(), + actionButton(ns("gwas_summary"), "Summary"), circle = FALSE, status = "warning", icon = icon("info"), width = "300px", @@ -727,6 +728,72 @@ mod_gwas_server <- function(input, output, session, parent_session){ ex <- system.file("iris_passport_file.csv", package = "BIGapp") file.copy(ex, file) }) + + ##Summary Info + gwas_summary_info <- function() { + #Handle possible NULL values for inputs + dosage_file_name <- if (!is.null(input$gwas_file$name)) input$gwas_file$name else "No file selected" + passport_file_name <- if (!is.null(input$phenotype_file$name)) input$phenotype_file$name else "No file selected" + selected_ploidy <- if (!is.null(input$gwas_ploidy)) as.character(input$gwas_ploidy) else "Not selected" + + #Print the summary information + cat( + "BIGapp GWAS Summary\n", + "\n", + paste0("Date: ", Sys.Date()), "\n", + paste("R Version:", R.Version()$version.string), "\n", + "\n", + "### Input Files ###\n", + "\n", + paste("Input Genotype File:", dosage_file_name), "\n", + paste("Input Passport File:", passport_file_name), "\n", + "\n", + "### User Selected Parameters ###\n", + "\n", + paste("Selected Ploidy:", selected_ploidy), "\n", + paste("Significance Threshold Method:", input$gwas_threshold), "\n", + paste("Selected Trait:", input$trait_info), "\n", + paste("Selected Fixed Effects:", input$fixed_info), "\n", + "\n", + "### R Packages Used ###\n", + "\n", + paste("BIGapp:", packageVersion("BIGapp")), "\n", + paste("AGHmatrix:", packageVersion("AGHmatrix")), "\n", + paste("ggplot2:", packageVersion("ggplot2")), "\n", + paste("GWASpoly:", packageVersion("GWASpoly")), "\n", + paste("vcfR:", packageVersion("vcfR")), "\n", + paste("Matrix:", packageVersion("Matrix")), "\n", + sep = "" + ) + } + + # Popup for analysis summary + observeEvent(input$gwas_summary, { + showModal(modalDialog( + title = "Summary Information", + size = "l", + easyClose = TRUE, + footer = tagList( + modalButton("Close"), + downloadButton("download_gwas_info", "Download") + ), + pre( + paste(capture.output(gwas_summary_info()), collapse = "\n") + ) + )) + }) + + + # Download Summary Info + output$download_gwas_info <- downloadHandler( + filename = function() { + paste("gwas_summary_", Sys.Date(), ".txt", sep = "") + }, + content = function(file) { + # Write the summary info to a file + writeLines(paste(capture.output(gwas_summary_info()), collapse = "\n"), file) + } + ) } ## To be copied in the UI