Skip to content

Commit

Permalink
- fix merge confilicts
Browse files Browse the repository at this point in the history
Merge branch 'main' into dev

# Conflicts:
#	.github/workflows/docker-publish.yml
#	Dockerfile
#	components/mainpanel.R
#	components/server.R
#	functions/plotFunctions.R
#	install_packages.R
#	req.txt
#	tests/testthat/test_loadData_bruker.R
#	tests/testthat/test_loadData_mzML.R
  • Loading branch information
thomas-enzlein committed Jul 1, 2024
2 parents 8fa3ee7 + 4c26569 commit 6a5b8e4
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN R -e "packages <- readLines('/req.txt'); install.packages(packages)"
# Install the MALDIcellassay from GitHub
RUN R -e "pak::pkg_install('CeMOS-Mannheim/MALDIcellassay')"


## copy app folder into container
COPY ./ ./app

Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Thomas Enzlein

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
90 changes: 89 additions & 1 deletion components/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,42 @@ server <- function(input, output, session) {

## main ####
appData <<- emptyAppDataObject()
<<<<<<< HEAD
=======
vol <- getVolumes()

# check if "dir" is set in defaults
if (!is.null(defaults$dir)) {
appData$selected_dir <- defaults$dir
message("Dir set from loaded default value.\n")
appData$info_state <- "dir_set"
}

### choose dir ####
shinyDirChoose(input,
"dir",
roots = vol,
allowDirCreate = FALSE,
defaultRoot = names(vol)[1])

observeEvent(input$dir, {
# check if folder was selected
# prepare info massage
appData$selected_dir <- parseDirPath(vol, input$dir)
if (length(appData$selected_dir) > 0) {
appData$info_state <- "dir_set"
}
})

observeEvent(input$preproc_settings, {
appData$preprocessing$smooth <-
handlePreprocSettings(input$preproc_settings,
"smooth")

appData$preprocessing$rmBl <-
handlePreprocSettings(input$preproc_settings,
"rmBl")
>>>>>>> main

appData <- selectDir(appData, input)

Expand Down Expand Up @@ -188,6 +224,10 @@ server <- function(input, output, session) {
ggplotly(p)
} else {
dummyPlot()
<<<<<<< HEAD
=======

>>>>>>> main
}
})

Expand Down Expand Up @@ -253,10 +293,19 @@ server <- function(input, output, session) {
p <- loadingsPlot(appData$pca,
pc = input$pcaX,
simple = input$simpleLoadings)
<<<<<<< HEAD
=======

return(p)
>>>>>>> main

return(p)
} else {
dummyPlot()
<<<<<<< HEAD
=======

>>>>>>> main
}
})

Expand Down Expand Up @@ -285,6 +334,7 @@ server <- function(input, output, session) {
}
})

<<<<<<< HEAD
### clustering tab #####
observeEvent(input$doClust, {
if (appData$show_plot) {
Expand All @@ -298,15 +348,38 @@ server <- function(input, output, session) {
if (appData$show_plot & !is.null(appData$clust)) {
show_spinner()
p <- plotClusters(appData$clust, k = input$num_cluster)
=======
#### HClust tab #####
observeEvent(input$doHC, {
if (appData$show_plot) {
show_spinner()

appData$hc <- clusterCurves(appData$res, nClusters = 15)
>>>>>>> main
hide_spinner()
return(p)
}
})
<<<<<<< HEAD
=======
output$hclustPlot <- renderPlotly({
if (appData$show_plot & !is.null(appData$hc)) {
plotClusters(appData$hc, k = input$num_cluster)

}
})
>>>>>>> main

output$clustCurvesPlot <- renderPlotly({
if (appData$show_plot & !is.null(appData$clust)) {
show_spinner()
<<<<<<< HEAD
p <- plotTraj(appData$clust, k = input$num_cluster)
=======

p <- plotTraj(appData$hc, k = input$num_cluster)

>>>>>>> main
hide_spinner()
return(p)
}
Expand All @@ -315,7 +388,12 @@ server <- function(input, output, session) {
output$optNumClust <- renderPlotly({
if (appData$show_plot & !is.null(appData$clust)) {
show_spinner()
<<<<<<< HEAD
p <- plotClusterMetrics(appData$clust)
=======
p <- plotClusterMetrics(appData$hc)

>>>>>>> main
hide_spinner()
return(p)
}
Expand All @@ -324,7 +402,14 @@ server <- function(input, output, session) {
observeEvent(input$clust2peaksTable, {
if (appData$show_plot & !is.null(appData$clust)) {

<<<<<<< HEAD
clusters <- extractLaClusters(appData$clust, k = input$num_cluster)
=======
observeEvent(input$hc2peaksTable, {
if (appData$show_plot & !is.null(appData$hc)) {

clusters <- extractLaClusters(appData$hc, k = input$num_cluster)
>>>>>>> main
appData$stats <- appData$stats_original %>%
left_join(clusters, by = join_by(mzIdx))
message("Updated peak table with clustering data.\n")
Expand All @@ -350,12 +435,15 @@ server <- function(input, output, session) {

exportTestValues(numSpec = length(appData$spec_all),
isSpectrumList = MALDIquant::isMassSpectrumList(appData$spec_all),
<<<<<<< HEAD
infoState = appData$info_state,
pca = appData$pca,
clust = appData$clust)
=======
infoState = appData$info_state)
>>>>>>> main

session$onSessionEnded(function() {
stopApp()
})

}
1 change: 1 addition & 0 deletions functions/plotFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ loadingsPlot <- function(pca, pc, simple = TRUE, n = 10) {
theme(legend.position = "none")
}
p <- ggplotly(p)

return(p)
}

Expand Down
1 change: 1 addition & 0 deletions install_packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ options(dplyr.summarise.inform = FALSE)
# special case for packages not on CRAN
if (!require("MALDIcellassay", character.only = TRUE)) {
pak::pkg_install("CeMOS-Mannheim/MALDIcellassay")

library(MALDIcellassay, character.only = TRUE)
}
20 changes: 20 additions & 0 deletions req.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,39 @@ dplyr
tibble
tidyr
ggplot2
<<<<<<< HEAD
forcats
=======
purrr
readr
stringr
forcats
shinyFiles
>>>>>>> main
MALDIquant
MALDIquantForeign
DT
plotly
shiny
<<<<<<< HEAD
shinyFiles
shinycssloaders
shinyhelper
shinybusy
shinytest2
common
knitr
=======
shinycssloaders
shinyhelper
shinybusy
shinythemes
shinyWidgets
shinytest2
common
knitr
devtools
>>>>>>> main
sparsepca
platetools
fs
Expand Down
29 changes: 29 additions & 0 deletions tests/testthat/test_loadData_bruker.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ test_that("data can be loaded and processed from Bruker Flex",
format(Sys.time(), "%H:%M:%OS")
}
setwd(dirname(common::file.find(pattern = "req.txt")))
<<<<<<< HEAD

# download test data and unzip
curl::curl_download("https://figshare.com/ndownloader/files/46156791", "testdata_bruker.zip")
=======
cat("Working directory is ", getwd(), "\n")

# download test data and unzip
cat(timeNow(), "downloading Bruker Flex test data...\n")
curl::curl_download("https://figshare.com/ndownloader/files/46156791", "testdata_bruker.zip")
cat(timeNow(), "unzip Bruker test data...\n")
>>>>>>> main
unzip("testdata_bruker.zip")

# overwrite settings
Expand All @@ -20,19 +29,39 @@ test_that("data can be loaded and processed from Bruker Flex",

library(shinytest2)
options(shiny.testmode = TRUE)
<<<<<<< HEAD

=======
cat(timeNow(), "Starting app...\n")
>>>>>>> main
app <- AppDriver$new(app_dir = getwd(),
name = "M2ara_bruker load test",
seed = 42,
timeout = 4.5*1e5)

<<<<<<< HEAD
app$click("load")
Sys.sleep(120)
app$click("process")
exp <-app$get_values(export = TRUE)

expect_equal(exp$export$isSpectrumList, TRUE)
expect_equal(exp$export$numSpec, 88)
=======
cat(timeNow(), "loading spectra...\n")
app$click("load")
Sys.sleep(120)
cat(timeNow(), "processing...\n")
app$click("process")
cat(timeNow(), "done!\n")
exp <-app$get_values(export = TRUE)

cat(timeNow(), "running tests...\n")
expect_equal(exp$export$isSpectrumList, TRUE)
expect_equal(exp$export$numSpec, 88)

cat(timeNow(), "Sucess! Cleaning up...\n")
>>>>>>> main
fs::dir_delete("Curve")
fs::file_delete("settings.csv")
fs::file_delete("testdata_bruker.zip")
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test_loadData_mzML.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ test_that("data can be loaded and processed from mzML",

library(shinytest2)
options(shiny.testmode = TRUE)

cat(timeNow(), "Starting app...\n")
app <- AppDriver$new(app_dir = getwd(),
name = "M2ara_mzML load test",
seed = 42,
Expand Down

0 comments on commit 6a5b8e4

Please sign in to comment.