Implement support for custom SNP sets#10
Conversation
| shinyFileChoose(input, "sample_GetFile", roots=volumes, session=session) | ||
| samplefile = reactive({parseFilePaths(volumes, input$sample_GetFile)}) | ||
| roots = c(home="~", wd=".") | ||
| shinyFileChoose(input, "sample_GetFile", roots=roots, session=session, defaultRoot="home") | ||
| samplefile = reactive({parseFilePaths(roots, input$sample_GetFile)}) |
There was a problem hiding this comment.
changing to have file picker default to home directory instead of volumes dir
… if needed for conditioning)
| output$assay_choice = renderUI({ | ||
| selectInput("assay_choice", tags$span("Select Assay", tags$span(icon( | ||
| name = "question-circle", | ||
| ) | ||
| ) |> | ||
| add_prompt(message = "Select assay used to develop genotypes", position = "right") | ||
| ), c("Kintelligence", "Custom")) | ||
| }) | ||
| output$assay_GetFile = renderUI({ | ||
| fluidRow(column(10,shinyFilesButton("assay_GetFile", "Select a custom SNP positions file" , | ||
| title = "Select a custom SNP positions file", multiple = FALSE, | ||
| buttonType = "default", class = NULL), | ||
| tags$span( | ||
| icon( | ||
| name = "question-circle", | ||
| ) | ||
| ) |> | ||
| add_prompt(message = "File containing chromosomal locations for custom SNP panels.\nThis is not required if using the Kintelligence assay.\nColumns required: rsID, chromosome (e.g. 1, 2, 3,), and position (GRCh37).", position = "right") | ||
| )) | ||
| }) | ||
| output$assay_text = renderUI({ | ||
| textOutput("assay_file") | ||
| }) |
There was a problem hiding this comment.
drop-down menu for "kintelligence" or "custom". If select custom, file selector appears to select file with SNP positions information.
| withProgress(message = "Loading References", value = 0, { | ||
| if (file.exists(glue("{refs()}/EFM_references.rda"))) { | ||
| load(glue("{refs()}/EFM_references.rda")) |
There was a problem hiding this comment.
searches first for .rda file
| showModal(modalDialog( | ||
| title = "Input Error", | ||
| "Please provide reference genotypes before proceeding.", | ||
| easyClose = TRUE, | ||
| footer = modalButton("Dismiss") | ||
| )) | ||
| } | ||
| } else if (!isTruthy(input$cond) & !isTruthy(input$uncond)) { | ||
| showModal(modalDialog( | ||
| title = "Input Error", | ||
| "Please select either an Unconditioned or Conditioned analysis (or both!) before proceeding.", | ||
| easyClose = TRUE, | ||
| footer = modalButton("Dismiss") | ||
| )) | ||
| } else { |
There was a problem hiding this comment.
improved error handling using pop-up windows.
| withProgress(message = "Loading Allele Frequency Data", value = 0, { | ||
| freq_both = ifelse(!isTruthy(freq()$datapath), input$uploadfreq, freq()$datapath) | ||
| freq_major = ifelse(!isTruthy(freq_major()$datapath), input$uploadfreq_major, freq_major()$datapath) | ||
| freq_minor = ifelse(!isTruthy(freq_minor()$datapath), input$uploadfreq_minor, freq_minor()$datapath) | ||
| popFreq = load_freq(input$twofreqs, freq_both, freq_major, freq_minor) |
There was a problem hiding this comment.
now loads the frequency data before looping through each sample in manifest (therefore only loads freq data once).
| lcol = grep("rsid|marker|locus|snp", colname, ignore.case=TRUE, value=TRUE) | ||
| chrcol = grep("chr", colname, ignore.case=TRUE, value=TRUE) | ||
| poscol = grep("pos", colname, ignore.case=TRUE, value=TRUE) |
There was a problem hiding this comment.
more flexibility with column names
| format_ref = function(refData, refid, refs) { | ||
| if (is.numeric(refid)) { | ||
| ref_int = names(refData)[refid] | ||
| } else { | ||
| ref_int = refid | ||
| } | ||
| ref_profile = euroformix::tableReader(glue("{refs}/EFM_references.csv")) %>% | ||
| filter(.data$Sample.Name == ref_int) | ||
| #' @importFrom data.table fread | ||
| format_ref = function(refid, refs) { | ||
| ref_profile = data.frame(fread(glue("{refs}/EFM_references.csv"))) %>% | ||
| filter(.data$Sample.Name == refid) |
There was a problem hiding this comment.
Removed legacy code that is no longer used; converted to fread() function for fast reading of file.
| read_in_freq = function(freq){ | ||
| #efmaf=fread(freq, header=T, sep=",") | ||
| tab=data.frame(freq) |
There was a problem hiding this comment.
Rewrite of EFM freqImport() function to improve speed
| if (!file.exists(glue("{write_path}/rda_files/{sample}.rda")) | !(keep_bins)) { | ||
| evidData = create_evid(sample, replicate, snps_input) | ||
| dir.create(file.path(write_path, "rda_files"), showWarnings = FALSE, recursive=TRUE) | ||
| save(evidData, file=glue("{write_path}/rda_files/{sample}.rda")) | ||
| } else { | ||
| load(glue("{write_path}/rda_files/{sample}.rda")) | ||
| } |
There was a problem hiding this comment.
Save SNP binned data as .rda file
| #' @export | ||
| #' | ||
| run_mixder_ancestry = function(sample_manifest=NULL, sample=NULL, replicate=NULL, sample_reports = getwd(), output = "output", refpath=NULL, refs=NULL, mixdeconv=TRUE, uncond=TRUE, cond=FALSE, sets=10, dynamicAT=0.015, staticAT=10, minimum_snps=6000, A1_threshold=0.99, A2_threshold=0.6, minor_contrib_threshold=FALSE, keep_bins=TRUE, snps, pcagroups) { | ||
| run_mixder_ancestry = function(sample_manifest=NULL, sample=NULL, replicate="", sample_reports = getwd(), output = "output", refpath=NULL, refs=NULL, mixdeconv=TRUE, uncond=TRUE, cond=FALSE, sets=10, dynamicAT=0.015, staticAT=10, minimum_snps=6000, A1_threshold=0.99, A2_threshold=0.6, minor_contrib_threshold=FALSE, keep_bins=TRUE, snps="ancestry", pcagroups="superpopulations") { |
There was a problem hiding this comment.
Added default values
| if (dynamicAT != 0) { | ||
| message("creating AT table<br/>") | ||
| attable = process_kinreport(id, replicate_id, kinpath, dynamicAT, staticAT) | ||
| } else { | ||
| attable = staticAT | ||
| } |
There was a problem hiding this comment.
If only static AT is applied, then just the single AT value can be used (a table does not need to be created).
| if (!isTruthy(samplefile()$datapath)) { | ||
| showModal(modalDialog( | ||
| title = "Input Error", | ||
| "Please provide a sample manifest before proceeding.", | ||
| easyClose = TRUE, | ||
| footer = modalButton("Dismiss") | ||
| )) | ||
| } else if (!isTruthy(kin_inpath())) { |
There was a problem hiding this comment.
updated error handling for missing files in Shiny app- pop-up window will appear stating the problem instead of random closing of the app
This MR will implement support for custom, larger SNP sets, including changes to increase the speed of uploading data (and formatting appropriately for EFM).