rformassspectrometry / Spectra

Low level infrastructure to handle MS spectra
https://rformassspectrometry.github.io/Spectra/
34 stars 24 forks source link

Processing in combineSpectra #140

Closed michaelwitting closed 3 years ago

michaelwitting commented 3 years ago

Hi,

We would like to combine a intensity filter followed by combining spectra. My student @liesasalzer has seen that filtering is not applied when calling combineSpectra. Is there a specific reason for this? We are working around by using applyProcessing, but I was just wondering...

Best,

Michael

jorainer commented 3 years ago

That sounds like a bug. Could you please provide a minimal working example so that I can check and fix?

michaelwitting commented 3 years ago

Here an example

library(Spectra)
library(MsCoreUtils)

spd <- DataFrame(msLevel = c(2L, 2L, 2L), rtime = c(1, 2, 3))
spd$mz <- list(c(12, 14, 45, 56), c(14.1, 34, 56.1), c(12.1, 14.15, 34.1))
spd$intensity <- list(c(10, 20, 30, 40), c(11, 21, 31), c(12, 22, 32))
sps <- Spectra(spd)
res <- combineSpectra(sps)

filter_fun <- function(x){
  x > max(x, na.rm = TRUE) / 100
}

sps_filter <- filterIntensity(sps, intensity = filter_fun)

res <- combineSpectra(sps_filter)

The second combineSpectra throws Fehler in .concatenate_spectra(res) : Can not concatenate 'Spectra' objects with non-empty processing queue

jorainer commented 3 years ago

Thanks @michaelwitting . This bug should be fixed with PR #141

jorainer commented 3 years ago

Fixed in version 0.99.8 (current master branch) - should be available through Bioconductor in the next couple of days.