sneumann / xcms

This is the git repository matching the Bioconductor package xcms: LC/MS and GC/MS Data Analysis
Other
183 stars 80 forks source link

An attempt to include xcms in shiny server #642

Closed linlennypinawa closed 1 year ago

linlennypinawa commented 1 year ago

Has anyone tried to develop a shiny app with xcms package?

I tried and received error messages.

The reason I had such idea is that I want to create an user interface to try out different variables for peak finding. I tried to set ppm for testing.

Here is my code:

library(shiny)
library(xcms)

ui <- fluidPage(
  numericInput('ppm', "Accuracy (1 - 10)", min = 1, max = 10, value = 5)
)

server <- function(input, output){
  ppm_val <- reactive({input$ppm})
  df <- xcmsSet("/directory to get the files", method="centWave", fitgauss=FALSE, mzCenterFun="wMean",
          ppm=ppm_val, peakwidth=c(12, 55), prefilter=c(3,100), mzdiff=-0.01, snthresh=10, integrate=1, noise=0)

  })

}

shinyApp(ui, server)

The error message is: Error in xcmsSet("/directory to get the files"", : Chromatographic peak detection failed for all files! The first error was: Error in as.vector(x, "character"): cannot coerce type 'closure' to vector of type 'character'.

I am looking for advice.

stanstrup commented 1 year ago

Yes. This (rather complex app) is using XCMS: https://gitlab.com/R_packages/mscurate/-/tree/master/shiny_mscurate But it is not meant as a GUI for normal analysis.

Some things:

What you want to do have little to do with XCMS as such...

linlennypinawa commented 1 year ago

Yes. This (rather complex app) is using XCMS: https://gitlab.com/R_packages/mscurate/-/tree/master/shiny_mscurate But it is not meant as a GUI for normal analysis.

Some things:

  • XCMS needs a vector of file paths as input. Not a folder.
  • You are using old functions. Please read up on the new XCMS workflow that uses different functions.
  • reactives are referred to like functions when you want the value back. so you need ppm=ppm_val(). That seems to be the error you are getting (it is trying to make ppm_val into a character vector, but it is a function which R refers to as a closure).
  • The part that runs xcms you probably want to run inside an eventReactive that is triggered by a button. Right now it will only ever trigger when you start the app
  • A quick googling finds: https://github.com/tkimhofer/msbrowser

What you want to do have little to do with XCMS as such...

Fantastic!