diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..b09a0bc
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,47 @@
+FROM rocker/r-ver:4.4.2
+RUN apt-get update && apt-get install -y cmake libz-dev libcurl4-openssl-dev libssl-dev
+RUN R -e 'install.packages("remotes")'
+RUN Rscript -e 'remotes::install_version("adegenet",upgrade="never", version = "2.1.10")'
+RUN Rscript -e 'remotes::install_version("curl",upgrade="never", version = "6.0.1")'
+RUN Rscript -e 'remotes::install_version("DT",upgrade="never", version = "0.33")'
+RUN Rscript -e 'remotes::install_version("dplyr",upgrade="never", version = "1.1.4")'
+RUN Rscript -e 'remotes::install_version("vcfR",upgrade="never", version = "1.15.0")'
+RUN Rscript -e 'remotes::install_version("ggplot2",upgrade="never", version = "3.5.1")'
+RUN Rscript -e 'remotes::install_version("tidyr",upgrade="never", version = "1.3.1")'
+RUN Rscript -e 'remotes::install_version("curl",upgrade="never", version = "6.0.1")'
+RUN Rscript -e 'remotes::install_version("shiny",upgrade="never", version = "1.9.1")'
+RUN Rscript -e 'remotes::install_version("config",upgrade="never", version = "0.3.2")'
+RUN Rscript -e 'remotes::install_version("bs4Dash",upgrade="never", version = "2.3.4")'
+RUN Rscript -e 'remotes::install_version("golem",upgrade="never", version = "0.5.1")'
+RUN Rscript -e 'remotes::install_version("purrr",upgrade="never", version = "1.0.2")'
+RUN Rscript -e 'remotes::install_version("markdown",upgrade="never", version = "1.13")'
+RUN Rscript -e 'remotes::install_version("scales",upgrade="never", version = "1.3.0")'
+RUN Rscript -e 'remotes::install_version("plotly",upgrade="never", version = "4.10.4")'
+RUN Rscript -e 'remotes::install_version("shinyWidgets",upgrade="never", version = "0.8.7")'
+RUN Rscript -e 'remotes::install_version("shinyjs",upgrade="never", version = "2.1.0")'
+RUN Rscript -e 'remotes::install_version("shinydisconnect",upgrade="never", version = "0.1.1")'
+RUN Rscript -e 'remotes::install_version("shinyalert",upgrade="never", version = "3.1.0")'
+RUN Rscript -e 'remotes::install_version("stringr",upgrade="never", version = "1.5.1")'
+RUN Rscript -e 'remotes::install_version("updog",upgrade="never", version = "2.1.5")'
+RUN Rscript -e 'remotes::install_version("AGHmatrix",upgrade="never", version = "2.1.4")'
+RUN Rscript -e 'remotes::install_version("factoextra",upgrade="never", version = "1.0.7")'
+RUN Rscript -e 'remotes::install_version("httr",upgrade="never", version = "1.4.7")'
+RUN Rscript -e 'remotes::install_version("future",upgrade="never", version = "1.34.0")'
+RUN Rscript -e 'remotes::install_version("shinycssloaders",upgrade="never", version = "1.1.0")'
+RUN Rscript -e 'remotes::install_version("RColorBrewer",upgrade="never", version = "1.1.3")'
+RUN Rscript -e 'remotes::install_version("tibble",upgrade="never", version = "3.2.1")'
+RUN Rscript -e 'remotes::install_version("rrBLUP",upgrade="never", version = "4.6.3")'
+RUN Rscript -e 'remotes::install_version("MASS",upgrade="never", version = "7.3.60.2")'
+RUN Rscript -e 'remotes::install_version("Matrix",upgrade="never", version = "1.7.0")'
+RUN Rscript -e 'remotes::install_version("matrixcalc",upgrade="never", version = "1.0.6")'
+RUN Rscript -e 'remotes::install_github("Breeding-Insight/BIGr",upgrade="never")'
+RUN Rscript -e 'remotes::install_github("jendelman/GWASpoly",upgrade="never")'
+
+RUN mkdir /build_zone
+ADD . /build_zone
+WORKDIR /build_zone
+RUN R -e 'remotes::install_local(upgrade="never")'
+RUN rm -rf /build_zone
+EXPOSE 80
+CMD R -e "options('shiny.port'=80,shiny.host='0.0.0.0');BIGapp::run_app()"
+
diff --git a/R/mod_DosageCall.R b/R/mod_DosageCall.R
index ed737b7..fd7e5cd 100644
--- a/R/mod_DosageCall.R
+++ b/R/mod_DosageCall.R
@@ -6,7 +6,6 @@
#'
#' @noRd
#'
-#' @importFrom shinyjs enable disable useShinyjs
#' @importFrom shiny NS tagList
#' @importFrom future availableCores
#' @importFrom bs4Dash renderValueBox
@@ -16,6 +15,7 @@
mod_DosageCall_ui <- function(id){
ns <- NS(id)
tagList(
+ useShinyjs(),
fluidPage(
disconnectMessage(
text = "An unexpected error occurred, please reload the application and check the input file(s).",
@@ -55,9 +55,9 @@ mod_DosageCall_ui <- function(id){
)
)
),
- textInput(ns("output_name"), "Output File Name"),
- numericInput(ns("ploidy"), "Species Ploidy", min = 1, value = NULL),
- selectInput(ns("updog_model"), "Updog Model", choices = c("norm","hw","bb","s1","s1pp","f1","f1pp","flex","uniform"), selected = "norm"),
+ textInput(ns("output_name"), "Output File Name*"),
+ numericInput(ns("ploidy"), "Species Ploidy*", min = 1, value = NULL),
+ selectInput(ns("updog_model"), "Updog Model*", choices = c("norm","hw","bb","s1","s1pp","f1","f1pp","flex","uniform"), selected = "norm"),
conditionalPanel(
condition = "input.updog_model == 'f1' | input.updog_model == 'f1pp'",
ns = ns,
@@ -65,12 +65,12 @@ mod_DosageCall_ui <- function(id){
style = "padding-left: 20px;", # Add padding/indentation
textInput(
inputId = ns("parent1"),
- label = "Enter parent1 ID:",
+ label = "Enter parent1 ID*:",
value = NULL
),
textInput(
inputId = ns("parent2"),
- label = "Enter parent2 ID:",
+ label = "Enter parent2 ID*:",
value = NULL
)
)
@@ -82,15 +82,14 @@ mod_DosageCall_ui <- function(id){
style = "padding-left: 20px;", # Add padding/indentation
textInput(
inputId = ns("parent"),
- label = "Enter parent ID:",
+ label = "Enter parent ID*:",
value = NULL
)
)
),
- numericInput(ns("cores"), "Number of CPU Cores", min = 1, max = (future::availableCores() - 1), value = 1),
+ numericInput(ns("cores"), "Number of CPU Cores*", min = 1, max = (future::availableCores() - 1), value = 1),
actionButton(ns("run_analysis"), "Run Analysis"),
- useShinyjs(),
- downloadButton(ns('download_updog_vcf'), "Download VCF File", class = "butt"),
+ uiOutput(ns('mybutton')),
div(style="display:inline-block; float:right",dropdownButton(
HTML("Input files"),
@@ -123,7 +122,6 @@ mod_DosageCall_ui <- function(id){
#' @import vcfR
#' @import updog
#' @importFrom BIGr updog2vcf
-#' @importFrom shinyjs enable disable
#' @import dplyr
#'
#' @noRd
@@ -207,8 +205,6 @@ mod_DosageCall_server <- function(input, output, session, parent_session){
valueBox(snp_number(), "Markers in uploaded file", icon = icon("dna"), color = "info")
})
- disable("download_updog_vcf")
-
##This is for performing Updog Dosage Calling
updog_out <- eventReactive(input$run_analysis,{
@@ -374,7 +370,7 @@ mod_DosageCall_server <- function(input, output, session, parent_session){
return()
}
-
+
if (nrow(matrices$ref_matrix) == 0 || nrow(matrices$size_matrix) == 0) {
shinyalert(
title = "Data Warning!",
@@ -390,7 +386,7 @@ mod_DosageCall_server <- function(input, output, session, parent_session){
showCancelButton = FALSE,
animation = TRUE
)
-
+
return()
}
@@ -410,14 +406,9 @@ mod_DosageCall_server <- function(input, output, session, parent_session){
})
# Only make available the download button when analysis is finished
- observe({
- if (!is.null(updog_out())) {
- Sys.sleep(1)
- # enable the download button
- enable("download_updog_vcf")
- } else {
- disable("download_updog_vcf")
- }
+ output$mybutton <- renderUI({
+ if(isTruthy(updog_out()))
+ downloadButton(ns("download_updog_vcf"), "Download VCF file", class = "butt")
})
output$download_updog_vcf <- downloadHandler(
@@ -426,6 +417,7 @@ mod_DosageCall_server <- function(input, output, session, parent_session){
paste0(output_name, ".vcf.gz")
},
content = function(file) {
+
#Save Updog output as VCF file
temp <- tempfile()
updog2vcf(
@@ -459,14 +451,14 @@ 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",
@@ -493,7 +485,7 @@ mod_DosageCall_server <- function(input, output, session, parent_session){
sep = ""
)
}
-
+
# Popup for analysis summary
observeEvent(input$dosage_summary, {
showModal(modalDialog(
@@ -509,8 +501,8 @@ mod_DosageCall_server <- function(input, output, session, parent_session){
)
))
})
-
-
+
+
# Download Summary Info
output$download_dosage_info <- downloadHandler(
filename = function() {
diff --git a/R/mod_Filtering.R b/R/mod_Filtering.R
index 511bcc2..0803e9a 100644
--- a/R/mod_Filtering.R
+++ b/R/mod_Filtering.R
@@ -51,8 +51,7 @@ mod_Filtering_ui <- function(id){
)
),
actionButton(ns("run_filters"), "Apply Filters"),
- useShinyjs(),
- downloadButton(ns("start_updog_filter"), "Download", icon = icon("download"), class = "butt"),
+ uiOutput(ns("mybutton")),
div(style="display:inline-block; float:right",dropdownButton(
HTML("Input files"),
p(downloadButton(ns('download_vcf'),""), "VCF Example File"),
@@ -75,8 +74,7 @@ mod_Filtering_ui <- function(id){
valueBoxOutput(ns("snp_removed_box"), width = NULL),
box(title = "Plot Controls", status = "warning", solidHeader = TRUE, collapsible = TRUE,
sliderInput(ns("hist_bins"),"Histogram Bins", min = 1, max = 1200, value = c(50), step = 1), width = NULL,
- div(style="display:inline-block; float:left",dropdownButton(
- tags$h3("Save Image"),
+ div(style="display:inline-block; float:left", dropdownButton(
selectInput(inputId = ns('filter_hist'), label = 'Figure', choices = c("Bias Histogram",
"OD Histogram",
"Prop_mis Histogram",
@@ -88,7 +86,7 @@ mod_Filtering_ui <- function(id){
sliderInput(inputId = ns('image_height'), label = 'Height', value = 5, min = 1, max = 20, step = 0.5),
downloadButton(ns("download_filter_hist"), "Save"),
circle = FALSE,
- status = "danger",
+ status = "danger", label = "Save Image",
icon = icon("floppy-disk"), width = "300px",
tooltip = tooltipOptions(title = "Click to see inputs!")
))
@@ -112,37 +110,37 @@ mod_Filtering_ui <- function(id){
mod_Filtering_server <- function(input, output, session, parent_session){
ns <- session$ns
-
+
# Help links
observeEvent(input$goPar, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "VCF_Filtering_tabset",
selected = "VCF_Filtering_par")
# expand specific box
updateBox(id = "VCF_Filtering_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goRes, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "VCF_Filtering_tabset",
selected = "VCF_Filtering_results")
# expand specific box
updateBox(id = "VCF_Filtering_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goCite, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "VCF_Filtering_tabset",
selected = "VCF_Filtering_cite")
@@ -177,8 +175,6 @@ mod_Filtering_server <- function(input, output, session, parent_session){
)
})
- disable("start_updog_filter")
-
output$din_tabs <- renderUI({
tabBox(width =12, collapsible = FALSE, status = "info",
id = "updog_tab", height = "600px",
@@ -351,17 +347,11 @@ mod_Filtering_server <- function(input, output, session, parent_session){
})
# Only make available the download button when analysis is finished
- observe({
- if (!is.null(vcf())) {
- Sys.sleep(1)
- # enable the download button
- enable("start_updog_filter")
- } else {
- disable("start_updog_filter")
- }
+ output$mybutton <- renderUI({
+ if(isTruthy(vcf()))
+ downloadButton(ns("start_updog_filter"), "Download VCF file", class = "butt")
})
-
#Updog filtering
output$start_updog_filter <- downloadHandler(
filename = function() {
@@ -671,13 +661,13 @@ 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",
@@ -711,7 +701,7 @@ mod_Filtering_server <- function(input, output, session, parent_session){
sep = ""
)
}
-
+
# Popup for analysis summary
observeEvent(input$filtering_summary, {
showModal(modalDialog(
@@ -727,8 +717,8 @@ mod_Filtering_server <- function(input, output, session, parent_session){
)
))
})
-
-
+
+
# Download Summary Info
output$download_filtering_info <- downloadHandler(
filename = function() {
diff --git a/R/mod_GS.R b/R/mod_GS.R
index cf65eb8..8f25715 100644
--- a/R/mod_GS.R
+++ b/R/mod_GS.R
@@ -112,7 +112,7 @@ mod_GS_ui <- function(id){
downloadButton(ns("download_pred_results_file"), "Save Files")),
circle = FALSE,
status = "danger",
- icon = icon("floppy-disk"), width = "300px",
+ icon = icon("floppy-disk"), width = "300px", label = "Save Image",
tooltip = tooltipOptions(title = "Click to see inputs!")
))
)
@@ -144,38 +144,38 @@ mod_GS_server <- function(input, output, session, parent_session){
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "Genomic_Prediction_tabset",
selected = "Genomic_Prediction_par")
# expand specific box
updateBox(id = "Genomic_Prediction_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goRes, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "Genomic_Prediction_tabset",
selected = "Genomic_Prediction_results")
# expand specific box
updateBox(id = "Genomic_Prediction_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goCite, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "Genomic_Prediction_tabset",
selected = "Genomic_Prediction_cite")
# expand specific box
updateBox(id = "Genomic_Prediction_box", action = "toggle", session = parent_session)
})
-
+
#Default model choices
advanced_options_pred <- reactiveValues(
pred_model = "GBLUP",
@@ -183,12 +183,12 @@ mod_GS_server <- function(input, output, session, parent_session){
pred_est_file = NULL,
ped_file = NULL
)
-
+
pred_outputs <- reactiveValues(corr_output = NULL,
comb_output = NULL,
all_GEBVs = NULL,
avg_GEBVs = NULL)
-
+
#List the ped file name if previously uploaded
output$uploaded_file_name <- renderText({
if (!is.null(advanced_options_pred$ped_file)) {
@@ -197,7 +197,7 @@ mod_GS_server <- function(input, output, session, parent_session){
"" # Return an empty string if no file has been uploaded
}
})
-
+
output$uploaded_file_name_pred <- renderText({
if (!is.null(advanced_options_pred$pred_est_file)) {
paste("Previously uploaded file:", advanced_options_pred$pred_est_file$name)
@@ -205,7 +205,7 @@ mod_GS_server <- function(input, output, session, parent_session){
"" # Return an empty string if no file has been uploaded
}
})
-
+
#UI popup window for input
observeEvent(input$advanced_options_pred, {
showModal(modalDialog(
@@ -254,9 +254,9 @@ mod_GS_server <- function(input, output, session, parent_session){
)
))
})
-
-
-
+
+
+
#Close popup window when user "saves options"
observeEvent(input$save_advanced_options_pred, {
advanced_options_pred$pred_model <- input$pred_model
@@ -264,10 +264,10 @@ mod_GS_server <- function(input, output, session, parent_session){
advanced_options_pred$pred_est_file <- input$pred_est_file
advanced_options_pred$ped_file <- input$ped_file
# Save other inputs as needed
-
+
removeModal() # Close the modal after saving
})
-
+
###Genomic Prediction
#This tab involved 3 observeEvents
#1) to get the traits listed in the phenotype file
@@ -283,7 +283,7 @@ mod_GS_server <- function(input, output, session, parent_session){
updateVirtualSelect("pred_fixed_info2", choices = trait_var2, session = session)
updateVirtualSelect("pred_trait_info2", choices = trait_var2, session = session)
})
-
+
observeEvent(input$pred_fixed_info2, {
updateVirtualSelect("pred_fixed_cat2", choices = input$pred_fixed_info2, session = session)
})
@@ -592,22 +592,22 @@ mod_GS_server <- function(input, output, session, parent_session){
}
}
)
-
+
#Status
updateProgressBar(session = session, id = "pb_gp", value = 40, title = "Generating Matrices")
-
+
#Create relationship matrix depending on the input VCF files
if (is.null(advanced_options_pred$pred_est_file)) {
#Subset phenotype file by common IDs
pheno2 <- pheno2[common_ids, ]
-
+
#Matrix
Kin_mat <- A.mat(t(train_geno_adj_init), max.missing=NULL,impute.method="mean",return.imputed=FALSE)
-
+
} else{
#Subset phenotype file and training file by common IDs
pheno2 <- pheno2[common_ids, ]
-
+
#Match training and testing genotype file SNPs
common_markers <- intersect(rownames(train_geno_adj_init), rownames(est_geno_adj_init))
#first remove samples from training genotype matrix that are not in the phenotype file
@@ -615,10 +615,10 @@ mod_GS_server <- function(input, output, session, parent_session){
#Merge the training and prediction genotype matrices
est_geno_adj_init <- est_geno_adj_init[common_markers, ]
train_pred_geno <- cbind(train_geno_adj, est_geno_adj_init)
-
+
#Matrix
Kin_mat <- A.mat(t(train_pred_geno), max.missing=NULL,impute.method="mean",return.imputed=FALSE)
-
+
}
#Save to reactive values
@@ -663,13 +663,13 @@ mod_GS_server <- function(input, output, session, parent_session){
#Status
updateProgressBar(session = session, id = "pb_gp", value = 90, title = "Generating Results")
-
+
#initialize dataframe
results_GEBVs <- matrix(nrow = ncol(gmat), ncol = length(traits) + 1)
results_TRAITs <- matrix(nrow = ncol(gmat), ncol = length(traits) + 1)
colnames(results_TRAITs) <- c("Sample",paste0(traits)) # Set the column names to be the traits
colnames(results_GEBVs) <- c("Sample",paste0(traits)) # Set the column names to be the traits
-
+
#GBLUP for each trait
for (trait_idx in 1:length(traits)) {
traitpred <- kin.blup(data = pheno2,
@@ -679,24 +679,24 @@ mod_GS_server <- function(input, output, session, parent_session){
covariate = fixed_cov,
K=gmat,
n.core = cores)
-
+
results_GEBVs[, (trait_idx+1)] <- traitpred$g
results_TRAITs[, (trait_idx+1)] <- traitpred$pred
}
#Organize dataframes
results_GEBVs[,1] <- row.names(data.frame(traitpred$g))
results_TRAITs[,1] <- row.names(data.frame(traitpred$pred))
-
+
#Label the samples that already had phenotype information
results_GEBVs <- data.frame(results_GEBVs)
results_TRAITs <- data.frame(results_TRAITs)
exists_in_df <- results_GEBVs[[1]] %in% pheno2[[1]]
results_GEBVs <- cbind(results_GEBVs[1], "w/Pheno" = exists_in_df, results_GEBVs[-1])
results_TRAITs <- cbind(results_TRAITs[1], "w/Pheno" = exists_in_df, results_TRAITs[-1])
-
+
#Status
updateProgressBar(session = session, id = "pb_gp", value = 100, title = "Finished!")
-
+
##Make output tables depending on 1 or 2 VCF/pedigree files used.
#GEBVs
if (!is.null(advanced_options_pred$pred_est_file)) {
@@ -705,7 +705,7 @@ mod_GS_server <- function(input, output, session, parent_session){
} else{
pred_outputs2$all_GEBVs <- results_GEBVs
}
-
+
#BLUPs of genetic values
if (!is.null(advanced_options_pred$pred_est_file)) {
# Subset rows where 'w/Pheno' is FALSE and drop the 'w/Pheno' column
@@ -765,7 +765,7 @@ mod_GS_server <- function(input, output, session, parent_session){
ex <- system.file("iris_passport_file.csv", package = "BIGapp")
file.copy(ex, file)
})
-
+
#Download files for GP
output$download_pred_results_file <- downloadHandler(
filename = function() {
@@ -780,21 +780,21 @@ mod_GS_server <- function(input, output, session, parent_session){
ebv_file <- file.path(temp_dir, paste0("GS-EBV-predictions-", Sys.Date(), ".csv"))
write.csv(pred_outputs2$all_GEBVs, ebv_file, row.names = FALSE)
temp_files <- c(temp_files, ebv_file)
-
+
trait_file <- file.path(temp_dir, paste0("GS-Phenotype-predictions-", Sys.Date(), ".csv"))
write.csv(pred_outputs2$trait_output, trait_file, row.names = FALSE)
temp_files <- c(temp_files, trait_file)
-
+
# Zip files only if there's something to zip
if (length(temp_files) > 0) {
zip(file, files = temp_files, extras = "-j") # Using -j to junk paths
}
-
+
# Optionally clean up
file.remove(temp_files)
}
)
-
+
##Summary Info
pred_summary_info <- function() {
# Handle possible NULL values for inputs
@@ -802,7 +802,7 @@ mod_GS_server <- function(input, output, session, parent_session){
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",
@@ -836,7 +836,7 @@ mod_GS_server <- function(input, output, session, parent_session){
sep = ""
)
}
-
+
# Popup for analysis summary
observeEvent(input$pred_summary, {
showModal(modalDialog(
@@ -852,8 +852,8 @@ mod_GS_server <- function(input, output, session, parent_session){
)
))
})
-
-
+
+
# Download Summary Info
output$download_pred_info <- downloadHandler(
filename = function() {
diff --git a/R/mod_GSAcc.R b/R/mod_GSAcc.R
index 9df59b2..b80665d 100644
--- a/R/mod_GSAcc.R
+++ b/R/mod_GSAcc.R
@@ -30,13 +30,14 @@ mod_GSAcc_ui <- function(id){
),
column(width = 3,
box(title="Inputs", width = 12, collapsible = TRUE, collapsed = FALSE, status = "info", solidHeader = TRUE,
- fileInput(ns("pred_file"), "Choose VCF File", accept = c(".csv",".vcf",".gz")),
- fileInput(ns("trait_file"), "Choose Trait File", accept = ".csv"),
- numericInput(ns("pred_ploidy"), "Species Ploidy", min = 1, value = NULL),
- numericInput(ns("pred_cv"), "Iterations", min = 1, max=20, value = 5),
+ "* Required",
+ fileInput(ns("pred_file"), "Choose VCF File*", accept = c(".csv",".vcf",".gz")),
+ fileInput(ns("trait_file"), "Choose Trait File*", accept = ".csv"),
+ numericInput(ns("pred_ploidy"), "Species Ploidy*", min = 1, value = NULL),
+ numericInput(ns("pred_cv"), "Iterations*", min = 1, max=20, value = 5),
virtualSelectInput(
inputId = ns("pred_trait_info"),
- label = "Select Trait(s):",
+ label = "Select Trait(s)*:",
choices = NULL,
showValueAsTags = TRUE,
search = TRUE,
@@ -122,7 +123,7 @@ mod_GSAcc_ui <- function(id){
downloadButton(ns("download_pred_file"), "Save Files")),
circle = FALSE,
status = "danger",
- icon = icon("floppy-disk"), width = "300px",
+ icon = icon("floppy-disk"), width = "300px", label = "Save Image",
tooltip = tooltipOptions(title = "Click to see inputs!")
))
)
@@ -154,31 +155,31 @@ mod_GSAcc_server <- function(input, output, session, parent_session){
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "Predictive_Ability_tabset",
selected = "Predictive_Ability_par")
# expand specific box
updateBox(id = "Predictive_Ability_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goRes, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "Predictive_Ability_tabset",
selected = "Predictive_Ability_results")
# expand specific box
updateBox(id = "Predictive_Ability_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goCite, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "Predictive_Ability_tabset",
selected = "Predictive_Ability_cite")
@@ -834,14 +835,14 @@ 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",
@@ -874,7 +875,7 @@ mod_GSAcc_server <- function(input, output, session, parent_session){
sep = ""
)
}
-
+
# Popup for analysis summary
observeEvent(input$predAcc_summary, {
showModal(modalDialog(
@@ -890,8 +891,8 @@ mod_GSAcc_server <- function(input, output, session, parent_session){
)
))
})
-
-
+
+
# Download Summary Info
output$download_predAcc_info <- downloadHandler(
filename = function() {
diff --git a/R/mod_PCA.R b/R/mod_PCA.R
index 229e240..bc4869a 100644
--- a/R/mod_PCA.R
+++ b/R/mod_PCA.R
@@ -17,7 +17,7 @@ mod_PCA_ui <- function(id){
ns <- NS(id)
tagList(
fluidPage(
- # Add PCA content here
+ # Add PCA content here
fluidRow(
disconnectMessage(
text = "An unexpected error occurred, please reload the application and check the input file(s).",
@@ -30,7 +30,7 @@ mod_PCA_ui <- function(id){
),
useShinyjs(),
inlineCSS(list(.borderred = "border-color: red", .redback = "background: red")),
-
+
column(width = 3,
box(
title = "Inputs", width = 12, solidHeader = TRUE, status = "info",
@@ -42,23 +42,23 @@ mod_PCA_ui <- function(id){
br(),
actionButton(ns("pca_start"), "Run Analysis"),
div(style="display:inline-block; float:right",dropdownButton(
- HTML("Input files"),
- p(downloadButton(ns('download_vcf'),""), "VCF Example File"),
- p(downloadButton(ns('download_pheno'),""), "Trait Example File"), hr(),
- 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(),
- actionButton(ns("pca_summary"), "Summary"),
- circle = FALSE,
- status = "warning",
- icon = icon("info"), width = "300px",
- tooltip = tooltipOptions(title = "Click to see info!")
- ))#,
+ HTML("Input files"),
+ p(downloadButton(ns('download_vcf'),""), "VCF Example File"),
+ p(downloadButton(ns('download_pheno'),""), "Trait Example File"), hr(),
+ 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(),
+ actionButton(ns("pca_summary"), "Summary"),
+ circle = FALSE,
+ status = "warning",
+ icon = icon("info"), width = "300px",
+ tooltip = tooltipOptions(title = "Click to see info!")
+ ))#,
#style = "overflow-y: auto; height: 480px"
),
box(
title = "Plot Controls", status = "warning", solidHeader = TRUE, collapsible = TRUE,collapsed = FALSE, width = 12,
- selectInput(ns('group_info'), label = 'Color Variable', choices = NULL),
+ selectInput(ns('group_info'), label = 'Color Variable', choices = ""),
materialSwitch(ns('use_cat'), label = "Color Category", status = "success"),
conditionalPanel(condition = "input.use_cat",
ns = ns,
@@ -94,7 +94,7 @@ mod_PCA_ui <- function(id){
downloadButton(ns("download_pca"), "Save Image"),
circle = FALSE,
status = "danger",
- icon = icon("floppy-disk"), width = "300px",
+ icon = icon("floppy-disk"), width = "300px", label = "Save Image",
tooltip = tooltipOptions(title = "Click to see inputs!")
))
)
@@ -132,45 +132,45 @@ mod_PCA_ui <- function(id){
mod_PCA_server <- function(input, output, session, parent_session){
ns <- session$ns
- options(warn = -1) #Uncomment to suppress warnings
-
+ #options(warn = -1) #Uncomment to suppress warnings
+
# Help links
observeEvent(input$goPar, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "PCA_tabset",
selected = "PCA_par")
# expand specific box
updateBox(id = "PCA_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goRes, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "PCA_tabset",
selected = "PCA_results")
# expand specific box
updateBox(id = "PCA_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goCite, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "PCA_tabset",
selected = "PCA_cite")
# expand specific box
updateBox(id = "PCA_box", action = "toggle", session = parent_session)
})
-
+
#PCA reactive values
pca_data <- reactiveValues(
pc_df_pop = NULL,
@@ -329,7 +329,6 @@ mod_PCA_server <- function(input, output, session, parent_session){
#PCA
prin_comp <- prcomp(G.mat.updog, scale = TRUE)
eig <- get_eigenvalue(prin_comp)
- round(sum(eig$variance.percent[1:3]),1)
###Simple plots
# Extract the PC scores
@@ -379,6 +378,7 @@ mod_PCA_server <- function(input, output, session, parent_session){
pca_data$pc_df_pop <- pc_df_pop
pca_data$variance_explained <- variance_explained
pca_data$my_palette <- my_palette
+ pca_data$group_info <- input$group_info
#End of PCA section
})
@@ -390,10 +390,9 @@ mod_PCA_server <- function(input, output, session, parent_session){
need(!is.null(pca_data$pc_df_pop), "Input Genotype file, Species ploidy, and run the analysis to access results in this section.")
)
-
# Generate colors
if (!is.null(pca_data$my_palette)) {
- unique_countries <- unique(pca_data$pc_df_pop[[input$group_info]])
+ unique_countries <- unique(pca_data$pc_df_pop[[pca_data$group_info]])
palette <- brewer.pal(length(unique_countries), input$color_choice)
my_palette <- colorRampPalette(palette)(length(unique_countries))
} else {
@@ -413,21 +412,22 @@ mod_PCA_server <- function(input, output, session, parent_session){
#Set factor
if (!input$use_cat && is.null(my_palette)) {
print("No Color Info")
- }else{
- pca_data$pc_df_pop[[input$group_info]] <- as.factor(pca_data$pc_df_pop[[input$group_info]])
+ } else {
+ if(pca_data$group_info != "") pca_data$pc_df_pop[[pca_data$group_info]] <- as.factor(pca_data$pc_df_pop[[pca_data$group_info]])
}
# Similar plotting logic here
+ #input$cat_color <- as.character(unique(pca_data$pc_df_pop[[input$group_info]]))
cat_colors <- c(input$cat_color, "grey")
- plot <- {if(!is.null(input$group_info) & input$group_info != "")
+ plot <- {if(!is.null(pca_data$group_info) & pca_data$group_info != "")
ggplot(pca_data$pc_df_pop, aes(x = pca_data$pc_df_pop[[input$pc_X]],
y = pca_data$pc_df_pop[[input$pc_Y]],
- color = factor(pca_data$pc_df_pop[[input$group_info]]))) else
+ color = factor(pca_data$pc_df_pop[[pca_data$group_info]]))) else
ggplot(pca_data$pc_df_pop, aes(x = pca_data$pc_df_pop[[input$pc_X]],
y = pca_data$pc_df_pop[[input$pc_Y]]))} +
geom_point(size = 2, alpha = 0.8) +
- {if(input$use_cat) scale_color_manual(values = setNames(c(my_palette, "grey"), cat_colors), na.value = selected_grey) else
+ {if(input$use_cat & !is.null(my_palette)) scale_color_manual(values = setNames(c(my_palette, "grey"), cat_colors), na.value = selected_grey) else
if(!is.null(my_palette)) scale_color_manual(values = my_palette)} +
guides(color = guide_legend(override.aes = list(size = 5.5), nrow = 17)) +
theme_minimal() +
@@ -441,7 +441,7 @@ mod_PCA_server <- function(input, output, session, parent_session){
labs(
x = paste0(input$pc_X, "(", pca_data$variance_explained[as.numeric(substr(input$pc_X, 3, 3))], "%)"),
y = paste0(input$pc_Y, "(", pca_data$variance_explained[as.numeric(substr(input$pc_Y, 3, 3))], "%)"),
- color = input$group_info
+ color = pca_data$group_info
)
plot # Assign the plot to your reactiveValues
@@ -459,16 +459,22 @@ mod_PCA_server <- function(input, output, session, parent_session){
need(!is.null(pca_data$pc_df_pop), "Input Genotype file, Species ploidy, and run the analysis to access results in this section.")
)
+ tit = paste0('Total Explained Variance =', sum(pca_data$variance_explained[1:3]))
+
#Generate colors
- unique_countries <- unique(pca_data$pc_df_pop[[input$group_info]])
- palette <- brewer.pal(length(unique_countries),input$color_choice)
- my_palette <- colorRampPalette(palette)(length(unique_countries))
+ if(pca_data$group_info!= ""){
+ unique_countries <- unique(pca_data$pc_df_pop[[pca_data$group_info]])
+ palette <- brewer.pal(length(unique_countries),input$color_choice)
+ my_palette <- colorRampPalette(palette)(length(unique_countries))
- tit = paste0('Total Explained Variance =', sum(pca_data$variance_explained[1:3]))
+ fig <- plot_ly(pca_data$pc_df_pop, x = ~PC1, y = ~PC2, z = ~PC3, color = as.factor(pca_data$pc_df_pop[[pca_data$group_info]]),
+ colors = my_palette) %>%
+ add_markers(size = 12, text = paste0("Sample:",pca_data$pc_df_pop$Row.names))
- fig <- plot_ly(pca_data$pc_df_pop, x = ~PC1, y = ~PC2, z = ~PC3, color = as.factor(pca_data$pc_df_pop[[input$group_info]]),
- colors = my_palette) %>%
- add_markers(size = 12, text = paste0("Sample:",pca_data$pc_df_pop$Row.names))
+ } else {
+ fig <- plot_ly(pca_data$pc_df_pop, x = ~PC1, y = ~PC2, z = ~PC3) %>%
+ add_markers(size = 12, text = paste0("Sample:",pca_data$pc_df_pop$Row.names))
+ }
fig <- fig %>%
layout(
diff --git a/R/mod_dapc.R b/R/mod_dapc.R
index f221261..62690b4 100644
--- a/R/mod_dapc.R
+++ b/R/mod_dapc.R
@@ -87,7 +87,7 @@ mod_dapc_ui <- function(id){
downloadButton(ns("download_dapc_file"), "Save Files")),
circle = FALSE,
status = "danger",
- icon = icon("floppy-disk"), width = "300px",
+ icon = icon("floppy-disk"), width = "300px", label = "Save Image",
tooltip = tooltipOptions(title = "Click to see inputs!")
))
),
@@ -105,8 +105,7 @@ mod_dapc_ui <- function(id){
bs4Dash::box(title = "DAPC Plots", status = "info", solidHeader = FALSE, width = 12, height = 550, maximizable = T,
bs4Dash::tabsetPanel(
tabPanel("BIC Plot",withSpinner(plotOutput(ns("BIC_plot"), height = '460px'))),
- tabPanel("DAPC Plot", withSpinner(plotOutput(ns("DAPC_plot"), height = '460px'))),
- tabPanel("STRUCTURE Plot", "Not yet supported"))
+ tabPanel("DAPC Plot", withSpinner(plotOutput(ns("DAPC_plot"), height = '460px'))))
)
),
column(width = 1)
@@ -125,37 +124,37 @@ mod_dapc_ui <- function(id){
mod_dapc_server <- function(input, output, session, parent_session){
ns <- session$ns
-
+
# Help links
observeEvent(input$goPar, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "DAPC_tabset",
selected = "DAPC_par")
# expand specific box
updateBox(id = "DAPC_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goRes, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "DAPC_tabset",
selected = "DAPC_results")
# expand specific box
updateBox(id = "DAPC_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goCite, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "DAPC_tabset",
selected = "DAPC_cite")
@@ -193,7 +192,7 @@ mod_dapc_server <- function(input, output, session, parent_session){
)
}
req(input$dosage_file$datapath, input$dapc_ploidy)
-
+
#PB
updateProgressBar(session = session, id = "pb_dapc", value = 5, title = "Importing input files")
@@ -223,10 +222,10 @@ mod_dapc_server <- function(input, output, session, parent_session){
genotypeMatrix <- apply(genotypeMatrix, 2, convert_to_dosage)
rm(vcf) #Remove VCF
}
-
+
#PB
updateProgressBar(session = session, id = "pb_dapc", value = 30, title = "Calculating K")
-
+
#Perform analysis
get_k <- findK(genotypeMatrix, maxK, ploidy)
@@ -234,10 +233,10 @@ mod_dapc_server <- function(input, output, session, parent_session){
dapc_items$grp <- get_k$grp
dapc_items$bestK <- get_k$bestK
dapc_items$BIC <- get_k$BIC
-
+
#PB
updateProgressBar(session = session, id = "pb_dapc", value = 100, title = "Step 1: Finished!")
-
+
})
observeEvent(input$dapc_start, {
@@ -262,10 +261,10 @@ mod_dapc_server <- function(input, output, session, parent_session){
)
}
req(input$dosage_file$datapath, input$dapc_ploidy, input$dapc_k)
-
+
#Pb
updateProgressBar(session = session, id = "pb_dapc", value = 5, title = "Importing input files")
-
+
geno <- input$dosage_file$datapath
ploidy <- as.numeric(input$dapc_ploidy)
selected_K <- as.numeric(input$dapc_k)
@@ -278,10 +277,10 @@ mod_dapc_server <- function(input, output, session, parent_session){
# Apply the function to the first INFO string
info_ids <- extract_info_ids(info[1])
-
+
#Pb
updateProgressBar(session = session, id = "pb_dapc", value = 30, title = "Formatting files")
-
+
#Get the genotype values if the updog dosage calls are present
if ("UD" %in% info_ids) {
genotypeMatrix <- extract.gt(vcf, element = "UD")
@@ -293,20 +292,20 @@ mod_dapc_server <- function(input, output, session, parent_session){
genotypeMatrix <- apply(genotypeMatrix, 2, convert_to_dosage)
rm(vcf) #Remove VCF
}
-
+
#Pb
updateProgressBar(session = session, id = "pb_dapc", value = 60, title = "Performing DAPC")
-
+
#Perform analysis
clusters <- performDAPC(genotypeMatrix, selected_K, ploidy)
#Assign results to reactive value
dapc_items$assignments <- clusters$Q
dapc_items$dapc <- clusters$dapc
-
+
#Pb
updateProgressBar(session = session, id = "pb_dapc", value = 100, title = "Finished!")
-
+
})
###Outputs from DAPC
@@ -497,7 +496,7 @@ 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
diff --git a/R/mod_diversity.R b/R/mod_diversity.R
index 90295af..222e525 100644
--- a/R/mod_diversity.R
+++ b/R/mod_diversity.R
@@ -57,7 +57,7 @@ mod_diversity_ui <- function(id){
downloadButton(ns("download_div_file"), "Save Files")),
circle = FALSE,
status = "danger",
- icon = icon("floppy-disk"), width = "300px",
+ icon = icon("floppy-disk"), width = "300px", label = "Save Image",
tooltip = tooltipOptions(title = "Click to see inputs!")
))
)
@@ -96,44 +96,44 @@ mod_diversity_ui <- function(id){
mod_diversity_server <- function(input, output, session, parent_session){
ns <- session$ns
-
+
# Help links
observeEvent(input$goPar, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "Genomic_Diversity_tabset",
selected = "Genomic_Diversity_par")
# expand specific box
updateBox(id = "Genomic_Diversity_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goRes, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "Genomic_Diversity_tabset",
selected = "Genomic_Diversity_results")
# expand specific box
updateBox(id = "Genomic_Diversity_box", action = "toggle", session = parent_session)
})
-
+
observeEvent(input$goCite, {
# change to help tab
updatebs4TabItems(session = parent_session, inputId = "MainMenu",
selected = "help")
-
+
# select specific tab
updateTabsetPanel(session = parent_session, inputId = "Genomic_Diversity_tabset",
selected = "Genomic_Diversity_cite")
# expand specific box
updateBox(id = "Genomic_Diversity_box", action = "toggle", session = parent_session)
})
-
+
#######Genomic Diversity analysis
#Genomic Diversity output files
@@ -255,11 +255,11 @@ mod_diversity_server <- function(input, output, session, parent_session){
#Calculate PIC
calc_allele_frequencies <- function(d_diplo_t, ploidy) {
allele_frequencies <- apply(d_diplo_t, 1, function(x) {
- count_sum <- sum(!is.na(x))
- allele_sum <- sum(x, na.rm = TRUE)
+ count_sum <- sum(!is.na(x))
+ allele_sum <- sum(x, na.rm = TRUE)
if (count_sum != 0) {allele_sum / (ploidy * count_sum)} else {NA}
})
-
+
all_allele_frequencies <- data.frame(SNP = rownames(d_diplo_t), p1= allele_frequencies, p2= 1-allele_frequencies)
return(all_allele_frequencies)
}
@@ -271,19 +271,19 @@ mod_diversity_server <- function(input, output, session, parent_session){
pic <- 1 - sum(freq_squared) - 2*upper_tri_sum
return(pic)
}
-
+
print(Fre[1:5,])
-
+
PIC_results <- apply(Fre[, c("p1", "p2")], 1, calc_pic)
PIC_df <- data.frame(SNP_ID = Fre$SNP, PIC = PIC_results)
rownames(PIC_df) <- NULL
-
+
print(PIC_df[1:5,])
print(diversity_items$maf_df[1:5,])
-
+
diversity_items$snp_stats <- (merge(diversity_items$maf_df, PIC_df, by = "SNP_ID", all = TRUE))[,c("SNP_ID","MAF","PIC")]
colnames(diversity_items$snp_stats)[1] <- "SNP"
-
+
#Updating value boxes
output$mean_het_box <- renderValueBox({
valueBox(
@@ -410,7 +410,9 @@ mod_diversity_server <- function(input, output, session, parent_session){
validate(
need(!is.null(diversity_items$het_df), "Input VCF, define parameters and click `run analysis` to access results in this session.")
)
- diversity_items$het_df
+ tb <- diversity_items$het_df
+ tb$Ho <- round(tb$Ho,4)
+ tb
})
output$sample_table <- renderDT({sample_table()}, options = list(scrollX = TRUE,autoWidth = FALSE, pageLength = 5))
@@ -419,7 +421,10 @@ mod_diversity_server <- function(input, output, session, parent_session){
validate(
need(!is.null(diversity_items$snp_stats), "Input VCF, define parameters and click `run analysis` to access results in this session.")
)
- diversity_items$snp_stats
+ tb <- diversity_items$snp_stats
+ tb$PIC <- round(tb$PIC,4)
+ tb$MAF <- round(tb$MAF,4)
+ tb
})
output$snp_table <- renderDT({snp_table()}, options = list(scrollX = TRUE,autoWidth = FALSE, pageLength = 5))
@@ -510,13 +515,13 @@ 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",
@@ -541,7 +546,7 @@ mod_diversity_server <- function(input, output, session, parent_session){
sep = ""
)
}
-
+
# Popup for analysis summary
observeEvent(input$diversity_summary, {
showModal(modalDialog(
@@ -557,8 +562,8 @@ mod_diversity_server <- function(input, output, session, parent_session){
)
))
})
-
-
+
+
# Download Summary Info
output$download_diversity_info <- downloadHandler(
filename = function() {
diff --git a/R/mod_dosage2vcf.R b/R/mod_dosage2vcf.R
index 2c8c879..cbac21f 100644
--- a/R/mod_dosage2vcf.R
+++ b/R/mod_dosage2vcf.R
@@ -41,7 +41,6 @@ mod_dosage2vcf_ui <- function(id){
),
textInput(ns("d2v_output_name"), "Output File Name"),
numericInput(ns("dosage2vcf_ploidy"), "Species Ploidy", min = 1, value = NULL),
- #actionButton(ns("run_analysis"), "Run Analysis"),
useShinyjs(),
downloadButton(ns('download_d2vcf'), "Download VCF File", class = "butt"),
div(style="display:inline-block; float:right",dropdownButton(
@@ -59,7 +58,7 @@ mod_dosage2vcf_ui <- function(id){
))
)
),
- column(width = 4,
+ column(width = 4,
valueBoxOutput(ns("ReportSnps"), width=12),
box(title = "Status", width = 12, collapsible = TRUE, status = "info",
progressBar(id = ns("dosage2vcf_pb"), value = 0, status = "info", display_pct = TRUE, striped = TRUE, title = " ")
@@ -126,45 +125,6 @@ mod_dosage2vcf_server <- function(input, output, session, parent_session){
valueBox(snp_number(), "Number of Markers", icon = icon("dna"), color = "info")
})
- observeEvent(input$run_analysis, {
- # Missing input with red border and alerts
- toggleClass(id = "d2v_output_name", class = "borderred", condition = (is.na(input$d2v_output_name) | is.null(input$d2v_output_name) | input$d2v_output_name == ""))
- toggleClass(id = "dosage2vcf_ploidy", class = "borderred", condition = (is.na(input$dosage2vcf_ploidy) | is.null(input$dosage2vcf_ploidy) | input$dosage2vcf_ploidy == ""))
-
- if (is.null(input$report_file$datapath) | is.null(input$counts_file$datapath)) {
- shinyalert(
- title = "Missing input!",
- text = "Upload Dose Report and Counts Files",
- size = "s",
- closeOnEsc = TRUE,
- closeOnClickOutside = FALSE,
- html = TRUE,
- type = "error",
- showConfirmButton = TRUE,
- confirmButtonText = "OK",
- confirmButtonCol = "#004192",
- showCancelButton = FALSE,
- animation = TRUE
- )
- }
- req(input$report_file, input$counts_file, input$d2v_output_name, input$dosage2vcf_ploidy)
-
- updateProgressBar(session = session, id = "dosage2vcf_pb", value = 10, title = "Input files evaluated.")
-
- dosage_file_df <- read.csv(input$report_file$datapath)
- snp_number <- length(dosage_file_df$X.[-c(1:7)])
-
- #SNP counts value box
- output$ReportSnps <- renderValueBox({
- valueBox(snp_number, "Number of Markers", icon = icon("dna"), color = "info")
- })
-
- enable("download_d2vcf")
-
- updateProgressBar(session = session, id = "dosage2vcf_pb", value = 100, title = "Click in Download to continue.")
-
- })
-
output$download_dose <- downloadHandler(
filename = function() {
paste0("BIGapp_Dose_Report_Example_file.csv")
@@ -191,8 +151,24 @@ mod_dosage2vcf_server <- function(input, output, session, parent_session){
},
content = function(file) {
# Ensure the files are uploaded
+ # Missing input with red border and alerts
+ if (is.null(input$report_file$datapath) | is.null(input$counts_file$datapath) | input$d2v_output_name == "" | input$dosage2vcf_ploidy == "") {
+ shinyalert(
+ title = "Missing input!",
+ text = "Upload Dose Report and Counts Files",
+ size = "s",
+ closeOnEsc = TRUE,
+ closeOnClickOutside = FALSE,
+ html = TRUE,
+ type = "error",
+ showConfirmButton = TRUE,
+ confirmButtonText = "OK",
+ confirmButtonCol = "#004192",
+ showCancelButton = FALSE,
+ animation = TRUE
+ )
+ }
req(input$report_file, input$counts_file, input$d2v_output_name, input$dosage2vcf_ploidy)
-
# Get the uploaded file paths
dosage_file <- input$report_file$datapath
counts_file <- input$counts_file$datapath
@@ -251,14 +227,14 @@ 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",
@@ -282,7 +258,7 @@ mod_dosage2vcf_server <- function(input, output, session, parent_session){
sep = ""
)
}
-
+
# Popup for analysis summary
observeEvent(input$d2vcf_summary, {
showModal(modalDialog(
@@ -298,8 +274,8 @@ mod_dosage2vcf_server <- function(input, output, session, parent_session){
)
))
})
-
-
+
+
# Download Summary Info
output$download_d2vcf_info <- downloadHandler(
filename = function() {
diff --git a/R/mod_gwas.R b/R/mod_gwas.R
index 999a634..c712e74 100644
--- a/R/mod_gwas.R
+++ b/R/mod_gwas.R
@@ -29,21 +29,22 @@ mod_gwas_ui <- function(id){
),
column(width = 3,
box(title="Inputs", width = 12, collapsible = TRUE, collapsed = FALSE, status = "info", solidHeader = TRUE,
- fileInput(ns("gwas_file"), "Choose VCF File", accept = c(".csv",".vcf",".gz")),
- fileInput(ns("phenotype_file"), "Choose Trait File", accept = ".csv"),
- numericInput(ns("gwas_ploidy"), "Species Ploidy", min = 1, value = NULL),
- numericInput(ns("bp_window_before"), "Base pair window (Mb)", min = 0, value = 2),
- selectInput(ns('gwas_threshold'), label='Significance Threshold', choices = c("M.eff","Bonferroni","FDR","permute"), selected="M.eff"),
- selectInput(ns('trait_info'), label = 'Select Trait', choices = NULL),
+ "* Required",
+ fileInput(ns("gwas_file"), "Choose VCF File*", accept = c(".csv",".vcf",".gz")),
+ fileInput(ns("phenotype_file"), "Choose Trait File*", accept = ".csv"),
+ numericInput(ns("gwas_ploidy"), "Species Ploidy*", min = 1, value = NULL),
+ numericInput(ns("bp_window_before"), "Base pair window (Mb)*", min = 0, value = 2),
+ selectInput(ns('gwas_threshold'), label='Significance Threshold*', choices = c("M.eff","Bonferroni","FDR","permute"), selected="M.eff"),
+ selectInput(ns('trait_info'), label = 'Select Trait*', choices = NULL),
virtualSelectInput(
inputId = ns("fixed_info"),
- label = "Select Fixed Effects (optional):",
+ label = "Select Fixed Effects:",
choices = NULL,
showValueAsTags = TRUE,
search = TRUE,
multiple = TRUE
),
- sliderInput(ns("cores"), "Number of CPU Cores", min = 1, max = (availableCores() - 1), value = 1, step = 1),
+ sliderInput(ns("cores"), "Number of CPU Cores*", min = 1, max = (availableCores() - 1), value = 1, step = 1),
actionButton(ns("gwas_start"), "Run Analysis"),
div(style="display:inline-block; float:right",dropdownButton(
HTML("Input files"),
@@ -128,7 +129,7 @@ mod_gwas_ui <- function(id){
downloadButton(ns("download_gwas_file"), "Save Files")),
circle = FALSE,
status = "danger",
- icon = icon("floppy-disk"), width = "300px",
+ icon = icon("floppy-disk"), width = "300px", label = "Save Image",
tooltip = tooltipOptions(title = "Click to see inputs!")
))
)
@@ -150,7 +151,7 @@ mod_gwas_ui <- function(id){
mod_gwas_server <- function(input, output, session, parent_session){
ns <- session$ns
-
+
# Help links
observeEvent(input$goGWASpar, {
# change to help tab
@@ -493,7 +494,7 @@ mod_gwas_server <- function(input, output, session, parent_session){
model <- c("additive","1-dom","2-dom","general","diplo-general","diplo-additive")
updateSelectInput(session, "model_select", choices = c("all", model))
}else{
- model <- c("additive", "1-dom")
+ model <- c("additive", "1-dom", "general")
updateSelectInput(session, "model_select", choices = c("all", model))
}
@@ -508,7 +509,9 @@ mod_gwas_server <- function(input, output, session, parent_session){
manhattan_plot_list <- list()
#plot for six models per trait
- manhattan_plot_list[["all"]] <- manhattan.plot(data2,traits=colnames(data@pheno[i]), models = model)+geom_point(size=3)+theme(text = element_text(size = 25),strip.text = element_text(face = "bold"))
+ manhattan_plot_list[["all"]] <- manhattan.plot(data2,traits=colnames(data@pheno[i]), models = model)+
+ geom_point(size=3)+
+ theme(text = element_text(size = 25),strip.text = element_text(face = "bold"), axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
#Status
updateProgressBar(session = session, id = "pb_gwas", value = 80, title = "GWAS Complete: Now Plotting Results")
@@ -542,7 +545,7 @@ mod_gwas_server <- function(input, output, session, parent_session){
#Status
updateProgressBar(session = session, id = "pb_gwas", value = 100, status = "success", title = "Finished")
})
-
+
#Checking if any QTLs were detected and returning a user notice if not
observe({
req(gwas_vars$gwas_df)
@@ -562,7 +565,7 @@ mod_gwas_server <- function(input, output, session, parent_session){
animation = TRUE
)
}
-
+
#Gracefully abort
return()
})
@@ -615,7 +618,7 @@ mod_gwas_server <- function(input, output, session, parent_session){
observe({
req(gwas_vars$gwas_df_filt, nrow(gwas_vars$gwas_df_filt) > 0)
-
+
df <- gwas_vars$gwas_df_filt %>% filter(Model %in% input$sele_models)
updatePickerInput(session = session, inputId = "sele_qtl", choices = unique(paste0(df$Marker, "_", df$Model)),
selected = unique(paste0(df$Marker, "_", df$Model)))
@@ -741,21 +744,21 @@ mod_gwas_server <- function(input, output, session, parent_session){
# Temporary files list
temp_dir <- tempdir()
temp_files <- c()
-
+
if (!is.null(gwas_vars$gwas_df)) {
# Create a temporary file for assignments
gwas_file <- file.path(temp_dir, paste0("QTL-Significant_Markers-statistics-", Sys.Date(), ".csv"))
write.csv(gwas_vars$gwas_df, gwas_file, row.names = FALSE)
temp_files <- c(temp_files, gwas_file)
}
-
+
if (!is.null(gwas_vars$gwas_df_filt)) {
# Create a temporary file for assignments
gwas_file <- file.path(temp_dir, paste0("QTL-LD-filtered-statistics-", Sys.Date(), ".csv"))
write.csv(gwas_vars$gwas_df_filt, gwas_file, row.names = FALSE)
temp_files <- c(temp_files, gwas_file)
}
-
+
if (!is.null(gwas_vars$fit_qtl)) {
# Create a temporary file for assignments
gwas_file <- file.path(temp_dir, paste0("Multiple-QTL-model-statistics-", Sys.Date(), ".csv"))
@@ -813,7 +816,7 @@ mod_gwas_server <- function(input, output, session, parent_session){
req(gwas_vars$LD_plot)
#Plot
print(gwas_vars$LD_plot)
-
+
} else if (input$gwas_figures == "Manhattan Plot") {
req(gwas_vars$manhattan_plots, input$model_select)
#Plot
diff --git a/inst/CITATION b/inst/CITATION
new file mode 100644
index 0000000..4fd7290
--- /dev/null
+++ b/inst/CITATION
@@ -0,0 +1,33 @@
+bibentry(bibtype = "Article",
+ title = "BIGapp: A User-Friendly Genomic Tool Kit Identified Quantitative Trait Loci for Creeping Rootedness in Alfalfa (Medicago sativa L.)",
+ year = "TBD",
+ journal = "TBD",
+ publisher = "TBD",
+ volume = "TBD",
+ number = "TBD",
+ pages = "TBD",
+ issn = "TBD",
+ doi = "TBD",
+ author = c(person(given = "Alex",
+ family = "Sandercock",
+ email = "ams866@cornell.edu"),
+ person(given = "Michael",
+ family = "Peel"),
+ person(given = "Cristiane",
+ family = "Taniguti"),
+ person(given = "Josue",
+ family = "Chinchilla-Vargas"),
+ person(given = "Shufen",
+ family = "Chen"),
+ person(given = "Manoj",
+ family = "Sapkota"),
+ person(given = "Meng",
+ family = "Lin"),
+ person(given = "Dongyan",
+ family = "Zhao"),
+ person(given = "Craig",
+ family = "Beil"),
+ person(given = "Moira",
+ family = "Sheehan")
+ )
+ )