Skip to content

Commit

Permalink
filterSOI bugfixing
Browse files Browse the repository at this point in the history
Fix problem with GUI variable names #11

Add checks to filterSOI to raise a warning if no SOIs remain after each filtering step
  • Loading branch information
RogerGinBer committed Jan 5, 2022
1 parent 10189ac commit d372d48
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
19 changes: 18 additions & 1 deletion R/SOI_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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), ]
Expand Down
10 changes: 3 additions & 7 deletions inst/app/SOI_UI.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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),
Expand Down

0 comments on commit d372d48

Please sign in to comment.