Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New .peaksapply fails with MsBackendMassbankSql #187

Closed
meowcat opened this issue Mar 23, 2021 · 4 comments
Closed

New .peaksapply fails with MsBackendMassbankSql #187

meowcat opened this issue Mar 23, 2021 · 4 comments

Comments

@meowcat
Copy link

meowcat commented Mar 23, 2021

Hi,

filing this here, perhaps it's a MsBackendMassbankSql issue. Using addProcessing with the "new" .peaksapply, fails for me on a MsBackendMassbankSql backend at time of applying a lazy queue.

Error in (function (x, ...) : argument "x" is missing, with no default

It works if I convert the data to MsBackendDataFrame first. Everything worked with the old .peaksapply where arguments ms2Leveland centroided were expected.

I can't get far in debugging because the error handler obscures to me where the issue actually is coming from.

Below is a reprex with the minimassbank.sqlite:

library(tidyverse)
library(Spectra)
library(MsBackendMassbank)
library(RSQLite)
library(DBI)

con <- dbConnect(
  RSQLite::SQLite(),
  system.file("sql/minimassbank.sqlite", package="MsBackendMassbank")
)
 
be <- backendInitialize(MsBackendMassbankSql(), dbcon = con)
sp <- Spectra(be)

sp_selection <- sp[2:5]
sp_converted <- setBackend(sp_selection, MsBackendDataFrame())

print(peaksData(sp_selection)[[1]])
print(peaksData(sp_converted)[[1]])


ms2_normalize_spectrum <- function(x, ...) {
  scale <- 333
  x[,2] <- x[,2] / max(x[,2]) * scale
  x  
}

sp_converted_norm <- sp_converted %>% addProcessing(ms2_normalize_spectrum)
print(peaksData(sp_converted_norm)[[1]])
sp_selection_norm <- sp_selection %>% addProcessing(ms2_normalize_spectrum)
# Here we fail, when the processing function would be applied to get the actual peaks.
print(peaksData(sp_selection_norm)[[1]])

# It's not the pipe's fault:
test2 <- addProcessing(sp_selection, ms2_normalize_spectrum)
print(peaksData(test2))
@jorainer
Copy link
Member

Can you please provide the output of your sessionInfo?

@jorainer
Copy link
Member

Oh man. I fixed it now. Thanks so much @meowcat for reporting and the reproducible example!

The problem was that the list returned by peaksData,MsBackendMassbankSql is named. And the name is then used as the variable name. Anyway, I dropped now the names and it works. I will merge then change into the master branch once the unit tests run through.

jorainer added a commit that referenced this issue Mar 23, 2021
fix: drop names on peaks list (fixes issue #187)
@jorainer
Copy link
Member

Can you please verify that it's working now @meowcat and eventually close the issue?

@meowcat
Copy link
Author

meowcat commented Mar 24, 2021

Works, thanks!

@meowcat meowcat closed this as completed Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants