Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates BIGapp’s dosage2vcf Shiny module to align with BIGr v0.7.0 madc2vcf functionality, removing dosage/counts report conversion paths and adding new MADC conversion options (target/off-target/microhaplotypes), advanced filtering, and an in-app log display/download.
Changes:
- Simplifies input formats to MADC and Dosage Matrix, and expands marker types to include microhaplotypes.
- Adds “Advanced Options” modal for off-target SNP extraction and adds a Status & Log panel with log download.
- Updates help material and bumps package version.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
R/mod_GS.R |
Removes extraneous blank lines (no behavioral change). |
R/mod_dosage2vcf.R |
Refactors UI/server to use updated madc2vcf_* functions, adds advanced options + log capture/download, updates example downloads and species resources. |
inst/help_files/DArT_Report2VCF_par.Rmd |
Updates documentation to reflect new MADC workflows, requirements, and advanced options. |
DESCRIPTION |
Version bump to 1.8.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| error = function(e) { | ||
| log_lines <<- c(log_lines, paste0("Error: ", conditionMessage(e), "\n")) | ||
| shinyalert( | ||
| title = "Missing input!", | ||
| text = "Upload MADC and/or define a output file name", | ||
| title = "Error", | ||
| text = conditionMessage(e), | ||
| size = "s", | ||
| closeOnEsc = TRUE, | ||
| closeOnClickOutside = FALSE, | ||
| html = TRUE, | ||
| type = "error", | ||
| showConfirmButton = TRUE, | ||
| confirmButtonText = "OK", | ||
| confirmButtonCol = "#004192", | ||
| showCancelButton = FALSE, | ||
| animation = TRUE | ||
| confirmButtonCol = "#004192" | ||
| ) | ||
| } |
There was a problem hiding this comment.
The conversion is wrapped in tryCatch(), but the error handler only shows an alert and does not stop the reactive (or return a failure value). That means downstream code can still mark the job complete and expose a download path even when madc2vcf_* failed. Consider returning NULL (or re-throwing) from the error handler and updating the progress bar to an error state.
| updateProgressBar(session = session, id = "dosage2vcf_pb", value = 100, title = "Complete!") | ||
| return(output_name) | ||
|
|
There was a problem hiding this comment.
After tryCatch(), the code always updates the progress bar to 100% "Complete!" and returns output_name even if conversion failed. This can lead to attempts to bgzip/download a VCF that was never created. Gate the completion/return on success (e.g., check file.exists(output_name) and return NULL on failure).
| updateProgressBar(session = session, id = "dosage2vcf_pb", value = 100, title = "Complete!") | |
| return(output_name) | |
| if (file.exists(output_name)) { | |
| updateProgressBar(session = session, id = "dosage2vcf_pb", value = 100, title = "Complete!") | |
| return(output_name) | |
| } | |
| updateProgressBar(session = session, id = "dosage2vcf_pb", value = 0, title = "Conversion failed") | |
| return(NULL) | |
| if (is.null(input$madc_file$datapath) | input$d2v_output_name == "") { | ||
| shinyalert( | ||
| title = "Missing input!", | ||
| text = "Upload Dose Report and Counts Files", | ||
| text = "Upload MADC and/or define a output file name", | ||
| size = "s", |
There was a problem hiding this comment.
This branch shows a "Missing input" alert when output name is empty, but it doesn't stop execution (the only req() here is for madc_file). As a result, the analysis can proceed with an empty output name and produce a download filename like ".vcf.gz". Add a req(nzchar(input$d2v_output_name)) (or return(NULL)) after the alert to enforce the requirement.
| } else if(input$snp_type == "target"){ | ||
| madc2vcf_targets(read_madc, output_name, get_REF_ALT = as.logical(input$ref_alt), botloci_file = botloci, | ||
| markers_info = markers_info, collapse_matches_counts = input$collapse_matches_counts) | ||
| } else if(input$snp_type == "multiallelic"){ |
There was a problem hiding this comment.
In the target branch, input$ref_alt is only defined when species == 'other' (UI hides it otherwise), so as.logical(input$ref_alt) becomes logical(0) for built-in species. Also, input$collapse_matches_counts from radioButtons will arrive as a string ("TRUE"/"FALSE") and is passed through uncast. Provide defaults/coercion (e.g., use TRUE/FALSE when ref_alt is NULL and wrap collapse_matches_counts with isTRUE(as.logical(...))).
| "pecan" = paste0(github_path, "pecan/Pecan_unique_alignment_top48_MAS_14K_3K_f180bp.botloci"), | ||
| "potato" = paste0(github_path, "potato/potato_20K_SNPset_f180bp_forDArT_3K_f180bp.botloci"), | ||
| "strawberry" = paste0(github_path, "strawberry/strawberry_20K_SNPset_f180bp_forDArT_3K_f180bp.botloci"), | ||
| "sweetpotato" = paste0(github_path, "sweetpotato/sweetpotato_20K_SNPset_f180bp_forDArT_3K_f180bp.botloci"), | ||
| "other" = input$botloci_file$datapath) |
There was a problem hiding this comment.
When species == 'other', botloci is taken from input$botloci_file$datapath, but there is no server-side validation that botloci_file was actually uploaded before running. If the user clicks Convert without uploading it, botloci becomes NULL and the BIGr conversion will likely error. Add a req(input$botloci_file) (or equivalent) when input$species == 'other'.
| content = function(file) { | ||
| ex <- system.file("iris_DArT_MADC.csv", package = "BIGapp") | ||
| file.copy(ex, file) | ||
| github_path <- "https://raw.githubusercontent.com/Breeding-Insight/BIGapp-PanelHub/refs/heads/long_seq/" |
There was a problem hiding this comment.
This downloads an example file from a moving GitHub branch reference (refs/heads/long_seq). That URL can change or disappear, breaking the app at runtime, and it also makes the feature dependent on network availability. Prefer bundling the example file in the package (inst/extdata) or pinning to a release tag/commit hash.
| github_path <- "https://raw.githubusercontent.com/Breeding-Insight/BIGapp-PanelHub/refs/heads/long_seq/" | |
| github_path <- "https://raw.githubusercontent.com/Breeding-Insight/BIGapp-PanelHub/<pinned-commit-hash>/" |
| # Select species botloci | ||
| github_path <- "https://raw.githubusercontent.com/Breeding-Insight/BIGapp-PanelHub/refs/heads/long_seq/" | ||
|
|
||
| botloci <- switch(input$species, | ||
| "alfalfa" = paste0(github_path, "alfalfa/20201030-BI-Alfalfa_SNPs_DArTag-probe-design_f180bp.botloci"), | ||
| "blueberry" = paste0(github_path, "blueberry/20200819-BI-Blueberry_10K_SNPs_forDArT_3K_ref_alt.botloci"), |
There was a problem hiding this comment.
All reference resources (botloci, allele DB, markers_info) are fetched from a GitHub branch URL (refs/heads/long_seq). Using a non-pinned branch introduces a reliability risk for production use. Consider pinning to a tagged release/commit, or shipping these resources with the app and/or caching locally after first download.
| ), | ||
| fileInput(ns("hapDB_file"), "Upload haplotype database file (fasta) (optional)"), | ||
| 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), br(), |
There was a problem hiding this comment.
sliderInput max is set to (availableCores() - 1). On single-core environments this evaluates to 0, which can make max < min and break the UI. Consider using max(1, availableCores() - 1) (or similar) to guarantee a valid range.
| sliderInput(ns("cores"), "Number of CPU Cores", min = 1, max = (availableCores() - 1), value = 1, step = 1), br(), | |
| sliderInput(ns("cores"), "Number of CPU Cores", min = 1, max = max(1, availableCores() - 1), value = 1, step = 1), br(), |
| shinyalert( | ||
| title = "Missing input!", | ||
| text = "Upload Dose Report and Counts Files", | ||
| text = "Upload MADC and/or define a output file name", |
There was a problem hiding this comment.
Grammar nit in the alert text: "define a output file name" should be "define an output file name".
| text = "Upload MADC and/or define a output file name", | |
| text = "Upload MADC and/or define an output file name", |
This adapts the
dosage2vcfmodule with the new updates onmadc2vcffunctions in BIGr version 0.7.0Details: