Skip to content

Commit

Permalink
- info_state manager uses switch
Browse files Browse the repository at this point in the history
- clean up
- set smoothHalfWindowSize to a more reasonable value
  • Loading branch information
thomas-enzlein committed May 29, 2024
1 parent a3250d4 commit 99a0609
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 152 deletions.
3 changes: 0 additions & 3 deletions functions/doFitCurve.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


doFitCurve <- function(appData, spec, input) {

#res <- NULL
Expand All @@ -24,6 +22,5 @@ doFitCurve <- function(appData, spec, input) {
cat("fitCurve returned null.\n")
}


return(res)
}
82 changes: 42 additions & 40 deletions functions/infoStateMassageHandler.R
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
infoStateMassageHandler <- function(info_state, output) {
if (info_state == "inital") {
output$info1 <- renderText("Please select\na folder.")
output$info2 <- renderText("")
output$info3 <- renderText("")
}
if (info_state == "dir_set") {
output$info1 <- renderText("Selected:")
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Press load button.")
}
if (info_state == "loaded") {
output$info1 <- renderText("Loaded:")
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Press process button.")
}
if (info_state == "processed") {
output$info1 <- renderText(("Dataset:"))
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Changed settings apply after re-processing.")
}
if (info_state == "fitErrorRecal") {
output$info1 <- renderText(("Dataset:"))
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Could not be processed. Wrong lock-mass?")
}
if (info_state == "fitErrorNorm") {
output$info1 <- renderText(("Dataset:"))
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Could not be processed. Wrong normalization-mass?")
}
if (info_state == "RefMzError") {
output$info1 <- renderText(("Dataset:"))
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Could not be processed. Increase tolerance?")
}
if (info_state == "fitErrorOther") {
output$info1 <- renderText(("Dataset:"))
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Could not be processed. Unkown error.\n")
}
switch(info_state,
"inital" = {
output$info1 <- renderText("Please select\na folder.")
output$info2 <- renderText("")
output$info3 <- renderText("")
},
"dir_set" = {
output$info1 <- renderText("Selected:")
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Press load button.")
},
"loaded" = {
output$info1 <- renderText("Loaded:")
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Press process button.")
},
"processed" = {
output$info1 <- renderText(("Dataset:"))
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Changed settings apply after re-processing.")
},
"fitErrorRecal" = {
output$info1 <- renderText(("Dataset:"))
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Could not be processed. Wrong lock-mass?")
},
"fitErrorNorm" = {
output$info1 <- renderText(("Dataset:"))
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Could not be processed. Wrong normalization-mass?")
},
"RefMzError" = {
output$info1 <- renderText(("Dataset:"))
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Could not be processed. Increase tolerance?")
},
"fitErrorOther" = {
output$info1 <- renderText(("Dataset:"))
output$info2 <- renderText(appData$selected_dir)
output$info3 <- renderText("Could not be processed. Unkown error.\n")
}
)

return(output)
}
1 change: 0 additions & 1 deletion functions/loadAllFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ loadAllFunctions <- function() {
source("functions/createDataTable.R")
source("functions/storeResults.R")
source("functions/emptyAppDataObject.R")
source("functions/prepareVi.R")
source("functions/detectOutliers.R")

}
Expand Down
21 changes: 0 additions & 21 deletions functions/load_spectra.R

This file was deleted.

29 changes: 0 additions & 29 deletions functions/mapSpots.R

This file was deleted.

38 changes: 0 additions & 38 deletions functions/plotFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,44 +101,6 @@ loadingsPlot <- function(pca, pc, simple = TRUE, n = 10) {
return(p)
}

glmRegPlot <- function(model, penalty) {
p <- getModelFit(model, penalty) %>%
predict(model$prepData) %>%
mutate(truth = pull(model$prepData, conc)) %>%
ggplot(aes(x = .pred, y = truth)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm") +
ggpubr::stat_regline_equation(aes(label = paste0("R2adj.=", ..adj.rr..))) +
coord_obs_pred() +
labs(x = "Log-predicted conc.",
y = "Log-true conc.")

return(p)
}

viPlot <- function(vi) {
NumNonZeoroCoef <- vi %>%
filter(Importance > 0) %>%
pull(Importance) %>%
length()

p <- vi %>%
arrange(desc(Importance)) %>%
slice_head(n = 20) %>%
mutate(Variable = round(readr::parse_number(Variable), 3)) %>%
mutate(imp = ifelse(Sign == "POS", Importance, -Importance)) %>%
mutate(Variable = fct_reorder(as.factor(Variable), imp)) %>%
ggplot(aes(x = Variable, y = imp, fill = Sign)) +
geom_col() +
geom_text(aes(x = 1, y = 0, label = paste0("#-features =", NumNonZeoroCoef))) +
coord_flip() +
theme(legend.position = "none") +
labs(x = "m/z",
y = "Variable importance")

return(p)
}

plateMapPlot <- function(appData,
stat = c("Concentration",
"Total Peak Intensity",
Expand Down
18 changes: 0 additions & 18 deletions functions/prepareVi.R

This file was deleted.

2 changes: 1 addition & 1 deletion functions/preprocessFunction.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ preprocess <- function(spectra,
smooth,
rmBaseline,
sqrtTransform = FALSE,
smoothHalfWindowSize = 3,
smoothHalfWindowSize = 20,
smoothMethod = "SavitzkyGolay",
rmBlMethod = "TopHat",
SNR,
Expand Down
1 change: 0 additions & 1 deletion req.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ tibble
tidyr
ggplot2
purrr
readr
stringr
forcats
shinyFiles
Expand Down

0 comments on commit 99a0609

Please sign in to comment.