Skip to content

madc2vcf updates#154

Open
Cristianetaniguti wants to merge 1 commit intoGS-Amatfrom
BIGr_v0.6.7
Open

madc2vcf updates#154
Cristianetaniguti wants to merge 1 commit intoGS-Amatfrom
BIGr_v0.6.7

Conversation

@Cristianetaniguti
Copy link
Copy Markdown
Collaborator

This adapts the dosage2vcf module with the new updates on madc2vcf functions in BIGr version 0.7.0

Details:

  • removes the possibility to convert from dosage and counts files
  • add options to convert to microhaplotype VCF (via polyRAD)
  • add options to collapse read counts for target SNPs
  • add advanced options for target + off-target SNPs:
    • filter tag by alignment scores
    • filter multiallelic SNPs
      • adjust depth and maf thresholds
    • add Other alleles
      • adjust maximum number of SNPs and presence of indels filters
  • Add box to display and download the log of the madc2vcf functions
  • Updates the help material

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread R/mod_dosage2vcf.R
Comment on lines +455 to 466
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"
)
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread R/mod_dosage2vcf.R
Comment on lines +470 to 472
updateProgressBar(session = session, id = "dosage2vcf_pb", value = 100, title = "Complete!")
return(output_name)

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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)

Copilot uses AI. Check for mistakes.
Comment thread R/mod_dosage2vcf.R
Comment on lines +365 to 369
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",
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread R/mod_dosage2vcf.R
Comment on lines +423 to +426
} 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"){
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(...))).

Copilot uses AI. Check for mistakes.
Comment thread R/mod_dosage2vcf.R
Comment on lines +330 to +334
"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)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'.

Copilot uses AI. Check for mistakes.
Comment thread R/mod_dosage2vcf.R
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/"
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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>/"

Copilot uses AI. Check for mistakes.
Comment thread R/mod_dosage2vcf.R
Comment on lines +322 to +327
# 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"),
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread R/mod_dosage2vcf.R
),
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(),
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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(),

Copilot uses AI. Check for mistakes.
Comment thread R/mod_dosage2vcf.R
shinyalert(
title = "Missing input!",
text = "Upload Dose Report and Counts Files",
text = "Upload MADC and/or define a output file name",
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar nit in the alert text: "define a output file name" should be "define an output file name".

Suggested change
text = "Upload MADC and/or define a output file name",
text = "Upload MADC and/or define an output file name",

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants