Skip to content

Commit

Permalink
Merge pull request #80 from Breeding-Insight/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Cristianetaniguti authored Dec 19, 2024
2 parents 9b3adad + 37e67d6 commit 8d571e9
Show file tree
Hide file tree
Showing 15 changed files with 251 additions and 74 deletions.
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: BIGapp
Title: Breeding Insight Genomics Shiny Application
Version: 0.6.2
Version: 1.0.0
Authors@R:
c(
person(c("Alexander", "M."), "Sandercock",
Expand All @@ -20,10 +20,9 @@ Authors@R:
role = "aut"),
person("Breeding Insight Team",
role = "aut"))
Description: This R shiny app provides a web-based user friendly way for our internal and
external collaborators to analyze genomic data without needing to use command-line tools.
Description: This R shiny app provides a web-based user friendly way for researchers to analyze genomic data without needing to use command-line tools.
Initial supported analyses will include the mature genomics/bioinformatics pipelines developed
within Breeding Insight, with additional analyses continuing to be added.
within Breeding Insight, with additional analyses continuing to be added. Both diploid and polyploid species are supported.
License: Apache License (== 2.0)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand All @@ -32,6 +31,7 @@ biocViews:
Imports:
vcfR (>= 1.15.0),
adegenet,
curl,
DT,
dplyr,
bs4Dash,
Expand All @@ -51,6 +51,7 @@ Imports:
GWASpoly,
AGHmatrix,
factoextra,
httr,
future,
shinycssloaders,
RColorBrewer,
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ importFrom(bs4Dash,updatebs4TabItems)
importFrom(bs4Dash,valueBox)
importFrom(bs4Dash,valueBoxOutput)
importFrom(config,get)
importFrom(curl,curl_fetch_memory)
importFrom(curl,new_handle)
importFrom(factoextra,get_eigenvalue)
importFrom(future,availableCores)
importFrom(golem,activate_js)
Expand All @@ -72,6 +74,9 @@ importFrom(graphics,strheight)
importFrom(graphics,strwidth)
importFrom(graphics,text)
importFrom(graphics,title)
importFrom(httr,GET)
importFrom(httr,content)
importFrom(httr,status_code)
importFrom(matrixcalc,is.positive.definite)
importFrom(plotly,add_markers)
importFrom(plotly,ggplotly)
Expand Down
84 changes: 84 additions & 0 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#' @param input,output,session Internal parameters for {shiny}.
#' DO NOT REMOVE.
#' @import shiny
#' @importFrom httr GET content status_code
#' @importFrom curl new_handle curl_fetch_memory
#' @noRd
app_server <- function(input, output, session) {
# Your application server logic
Expand Down Expand Up @@ -68,6 +70,88 @@ app_server <- function(input, output, session) {
)
))
})

#Check for updates from GitHub for BIGapp
get_latest_github_commit <- function(repo, owner) {
url <- paste0("https://api.github.com/repos/", owner, "/", repo, "/commits/main")
response <- GET(url)
content <- content(response, "parsed")

if (status_code(response) == 200) {
return(content$sha)
} else {
return(NULL)
}
}

is_internet_connected <- function() {
handle <- new_handle()
success <- tryCatch({
curl_fetch_memory("https://www.google.com", handle = handle)
TRUE
}, error = function(e) {
FALSE
})
return(success)
}

observeEvent(input$updates_info_button, {
# Check internet connectivity
if (!is_internet_connected()) {
# Display internet connectivity issues message
showModal(modalDialog(
title = "No Internet Connection",
easyClose = TRUE,
footer = tagList(
modalButton("Close")
),
"Please check your internet connection and try again."
))
return()
}

package_name <- "BIGapp"
repo_name <- "BIGapp" # GitHub repo name
repo_owner <- "Breeding-Insight" # User or organization name

# Get the installed version
installed_version <- as.character(packageVersion(package_name))

# Get the latest version from GitHub (can be tag version or latest commit)
latest_commit <- get_latest_github_commit(repo_name, repo_owner)

# Compare versions and prepare message
if (latest_commit > installed_version) {
update_status <- "A new version is available. Please update your package."
# Prepare styled HTML text for the modal
message_html <- paste(
"Installed version:", installed_version, "<br>",
#"Latest version commit SHA:", latest_commit, "<br>",
"<span>A new version is available on GitHub!</span><br>",
"<span style='color: red;'>Please update your package.</span>"
)
} else {
update_status <- "Your package is up-to-date!"
# Prepare non-styled text for no update needed
message_html <- paste(
"Installed version:", installed_version, "<br>",
#"Latest version commit SHA:", latest_commit, "<br>",
update_status
)
}

# Display message in a Shiny modal
showModal(modalDialog(
title = "BIGapp Updates",
size = "m",
easyClose = TRUE,
footer = tagList(
modalButton("Close")
),
# Use HTML to format the message and include styling
HTML(message_html)
))
})

#Download Session Info
output$download_session_info <- downloadHandler(
Expand Down
20 changes: 13 additions & 7 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ app_ui <- function(request) {
href = "#",
"Session Info",
onclick = "Shiny.setInputValue('session_info_button', Math.random())"
),
tags$a(
class = "dropdown-item",
href = "#",
"Check for Updates",
onclick = "Shiny.setInputValue('updates_info_button', Math.random())"
)
)
)
Expand Down Expand Up @@ -62,19 +68,19 @@ app_ui <- function(request) {
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")),
span("Predictive Ability"),
tabName = "prediction_accuracy",
icon = icon("right-left")),
menuItem(
span("Genomic Prediction", bs4Badge("beta", position = "right", color = "success")),
span("Genomic Prediction"),
tabName = "prediction",
icon = icon("angles-right")),
tags$li(class = "header", style = "color: grey; margin-top: 18px; margin-bottom: 10px; padding-left: 15px;", "Information"),
menuItem("Source Code", icon = icon("circle-info"), href = "https://www.github.com/Breeding-Insight/Genomics_Shiny_App"),
menuItem(
span("Job Queue", bs4Badge("demo", position = "right", color = "warning")),
tabName = "slurm",
icon = icon("clock")),
#menuItem(
# span("Job Queue", bs4Badge("demo", position = "right", color = "warning")),
# tabName = "slurm",
# icon = icon("clock")),
menuItem("Help", tabName = "help", icon = icon("circle-question"))
)
),
Expand All @@ -98,7 +104,7 @@ app_ui <- function(request) {
),
left = div(
style = "display: flex; align-items: center; height: 100%;", # Center the version text vertically
"v0.6.2")
"v1.0.0")
),
dashboardBody(
disconnectMessage(), #Adds generic error message for any error if not already accounted for
Expand Down
16 changes: 8 additions & 8 deletions R/mod_DosageCall.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ mod_DosageCall_ui <- function(id){
fluidRow(
box(
title = "Inputs", status = "info", solidHeader = TRUE, collapsible = FALSE, collapsed = FALSE,
fileInput(ns("madc_file"), "Choose MADC or VCF File", accept = c(".csv",".vcf",".gz")),
fileInput(ns("madc_passport"), "Choose Passport File (optional)", accept = c(".csv")),
"* Required",
fileInput(ns("madc_file"), "Choose MADC or VCF File*", accept = c(".csv",".vcf",".gz")),
fileInput(ns("madc_passport"), "Choose Trait File", accept = c(".csv")),
conditionalPanel(
condition = "output.passportTablePopulated",
ns = ns,
Expand Down Expand Up @@ -96,12 +97,11 @@ mod_DosageCall_ui <- function(id){
tooltip = tooltipOptions(title = "Click to see info!")
))
),
valueBoxOutput(ns("MADCsnps"))
),

fluidRow(
box(title = "Status", width = 3, collapsible = TRUE, status = "info",
column(width=4,
valueBoxOutput(ns("MADCsnps"), width=12),
box(title = "Status", width = 12, collapsible = TRUE, status = "info",
progressBar(id = ns("pb_madc"), value = 0, status = "info", display_pct = TRUE, striped = TRUE, title = " ")
)
)
)
)
Expand Down Expand Up @@ -161,7 +161,7 @@ mod_DosageCall_server <- function(input, output, session, parent_session){
# Update dropdown menu choices based on uploaded passport file
passport_table <- reactive({
validate(
need(!is.null(input$madc_passport), "Upload passport file to access results in this section."),
need(!is.null(input$madc_passport), "Upload Trait File to access results in this section."),
)
info_df <- read.csv(input$madc_passport$datapath, header = TRUE, check.names = FALSE)
info_df[,1] <- as.character(info_df[,1]) #Makes sure that the sample names are characters instead of numeric
Expand Down
83 changes: 81 additions & 2 deletions R/mod_GS.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod_GS_ui <- function(id){
column(width = 3,
box(title="Inputs", width = 12, collapsible = TRUE, collapsed = FALSE, status = "info", solidHeader = TRUE,
fileInput(ns("pred_known_file"), "Choose Training VCF File", accept = c(".csv",".vcf",".gz")),
fileInput(ns("pred_trait_file"), "Choose Passport File", accept = ".csv"),
fileInput(ns("pred_trait_file"), "Choose Trait File", accept = ".csv"),
fileInput(ns("pred_est_file"), "Choose Prediction VCF File", accept = c(".csv",".vcf",".gz")),
numericInput(ns("pred_est_ploidy"), "Species Ploidy", min = 1, value = NULL),
virtualSelectInput(
Expand Down Expand Up @@ -52,7 +52,14 @@ mod_GS_ui <- function(id){
status = "warning",
icon = icon("info"), width = "300px",
tooltip = tooltipOptions(title = "Click to see info!")
))
)),
tags$hr(style="border-color: #d3d3d3; margin-top: 20px; margin-bottom: 20px;"), # Lighter grey line
div(style="text-align: left; margin-top: 10px;",
actionButton(ns("advanced_options_pred"),
label = HTML(paste(icon("cog", style = "color: #007bff;"), "Advanced Options (beta)")),
style = "background-color: transparent; border: none; color: #007bff; font-size: smaller; text-decoration: underline; padding: 0;"
)
)

)
),
Expand Down Expand Up @@ -105,6 +112,78 @@ mod_GS_ui <- function(id){
mod_GS_server <- function(input, output, session, parent_session){

ns <- session$ns

#Default model choices
advanced_options_pred <- reactiveValues(
pred_model = "GBLUP",
pred_matrix = "Gmatrix",
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)) {
paste("Previously uploaded file:", advanced_options_pred$ped_file$name)
} else {
"" # Return an empty string if no file has been uploaded
}
})

#UI popup window for input
observeEvent(input$advanced_options_pred, {
showModal(modalDialog(
title = "Advanced Options (beta)",
selectInput(
inputId = ns('pred_model'),
label = 'Model Choice',
choices = c("GBLUP"),
selected = advanced_options_pred$pred_model # Initialize with stored value
),
conditionalPanel(
condition = "input.pred_model == 'GBLUP'", ns = ns,
div(
selectInput(
inputId = ns('pred_matrix'),
label = 'GBLUP Matrix Choice',
choices = c("Gmatrix", "Amatrix", "Hmatrix"),
selected = advanced_options_pred$pred_matrix # Initialize with stored value
)
)
),
conditionalPanel(
condition = "input.pred_matrix != 'Gmatrix'", ns = ns,
div(
fileInput(ns("ped_file"), "Choose Pedigree File", accept = ".csv"),
conditionalPanel(
condition = "output.uploaded_file_name !== ''", # Show only if there's content
textOutput(ns("uploaded_file_name")) # Display the uploaded file name
)
)
),
footer = tagList(
modalButton("Close"),
actionButton(ns("save_advanced_options"), "Save")
)
))
})



#Close popup window when user "saves options"
observeEvent(input$save_advanced_options, {
advanced_options$pred_model <- input$pred_model
advanced_options$pred_matrix <- input$pred_matrix
advanced_options$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
Expand Down
4 changes: 2 additions & 2 deletions R/mod_GSAcc.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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 Passport File", accept = ".csv"),
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(
Expand Down Expand Up @@ -164,7 +164,7 @@ mod_GSAcc_server <- function(input, output, session, parent_session){
selectInput(
inputId = ns('pred_model'),
label = 'Model Choice',
choices = c("rrBLUP", "GBLUP"),
choices = c("GBLUP"),
selected = advanced_options$pred_model # Initialize with stored value
),
conditionalPanel(
Expand Down
10 changes: 5 additions & 5 deletions R/mod_Home.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ mod_Home_ui <- function(id){
box(
title = "Breeding Insight Genomics App", status = "info", solidHeader = FALSE, width = 12, collapsible = FALSE,
HTML(
"<strong>The app is under development</strong>
<p>Breeding Insight provides bioinformatic processing support for our external collaborators. This R shiny app provides a web-based user friendly way for users to analyze genomic data without needing to use command-line tools.</p>
"<p>The BIGapp is a user-friendly tool for processing low to mid-density genotyping data for diploid and polyploid species. This R shiny app provides a web-based user friendly way for users to analyze genomic data without needing to use command-line tools.
Additional analysis will be added, with the initial focus on a core set of features for supporting breeding decisions.</p>
<p><b>Supported Analyses</b></p>
Initial supported analyses includes the mature genomics/bioinformatics pipelines developed within Breeding Insight:
<ul>
<li>Genotype processing</li>
<li>Summary metrics</li>
<li>Genotype Processing</li>
<li>Summary Metrics</li>
<li>Population Structure</li>
<li>GWAS</li>
<li>GS</li>
<li>Genomic Selection</li>
</ul>"
),
style = "overflow-y: auto; height: 500px"
Expand Down
Loading

0 comments on commit 8d571e9

Please sign in to comment.