diff --git a/R/SOI_functions.R b/R/SOI_functions.R index 4a428ac..efaecdf 100644 --- a/R/SOI_functions.R +++ b/R/SOI_functions.R @@ -707,7 +707,12 @@ setMethod("filterSOI", signature = c("RHermesExp", "numeric", "ANY", "ANY", "ANY ##Filter by maximum intensity intense_enough <- which(soilist$MaxInt > minint) soilist <- soilist[intense_enough, ] - + if(nrow(soilist) == 0){ + warning("No SOIs remaining after filtering by intensity. ", + "Aborting filter") + return(struct) + } + ##Filter by isotopic fidelity if (isofidelity) { # Isotopic elution similarity @@ -717,6 +722,12 @@ setMethod("filterSOI", signature = c("RHermesExp", "numeric", "ANY", "ANY", "ANY soilist <- soilist[good, ] with_isos <- intense_enough[good] + if(nrow(soilist) == 0){ + warning("No SOIs remaining after filtering by isotopic elution", + " similarity. Aborting filter") + return(struct) + } + # Isotopic pattern similarity message("Calculating isotopic fidelity metrics:") isodata <- lapply(with_isos, plotFidelity, struct = struct, @@ -726,6 +737,12 @@ setMethod("filterSOI", signature = c("RHermesExp", "numeric", "ANY", "ANY", "ANY soilist$isofidelity <- cos soilist <- soilist[cos > minscore, ] + if(nrow(soilist) == 0){ + warning("No SOIs remaining after filtering by isotopic ", + "fidelity. Aborting filter") + return(struct) + } + rtmargin <- 20 # Removing confirmed isotopic signals soilist <- soilist[order(-soilist$MaxInt), ] diff --git a/inst/app/SOI_UI.R b/inst/app/SOI_UI.R index 212b2cf..9d73c14 100644 --- a/inst/app/SOI_UI.R +++ b/inst/app/SOI_UI.R @@ -236,8 +236,8 @@ SOIServer <- function(id, struct){ style = "margin-top: 5px" )) ), - numericInput(ns("numericval"), label = "Minimum SOI intensity", value = 0, - min = 0, max = 1e5, step = 1000), + numericInput(ns("minfilter"), label = "Minimum SOI intensity", value = 0, + min = 0, max = 5e5, step = 1000), fluidRow( actionButton(inputId = ns("soiClean"), label = "Start SOI Cleaning", style = "text-align: center; background-color: #4d4263; color: #F0F0F0"), @@ -247,11 +247,7 @@ SOIServer <- function(id, struct){ }, ignoreNULL = TRUE,ignoreInit = TRUE, priority = 100) - observeEvent(input$minfilter,{ - updateNumericInput(session, "numericval", value = input$minfilter) - }) - - observeEvent(input$soiClean,{ + observeEvent(input$soiClean, { struct$dataset <- filterSOI(struct$dataset, as.numeric(input$soiChoices), as.numeric(input$minfilter),