rformassspectrometry / Spectra

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

Problems with ‘"Spectra"’ signature #201

Closed Dev-RDV closed 3 years ago

Dev-RDV commented 3 years ago

Hi,

I am following the tutorial proposed in http://eurobioc2019.bioconductor.org/slides/Flashlight3/Spectra.html#1

However, I am not able to execute the removePeaks and clean functions. I loaded only the Spectra package to avoid any interference.

In the step:

  ms2_hist%>%
   pickPeaks ()%>%
   removePeaks (threshold = 500)

the error is: Error in removePeaks (., Threshold = 500): could not find function "removePeaks"

I tried to call removePeaks by MSnbase and then the error changed:

ms2_hist %>%
    pickPeaks() %>%
    MSnbase::removePeaks(threshold = 500)

Error in (function (classes, fdef, mtable): unable to find an inherited method for function ‘removePeaks’ for signature ‘" Spectra "’

Here is my entire code with session information:

library(Spectra)
library(BiocParallel)
library(tidyverse)
register(SerialParam())

sps <- Spectra("11_1.mzML", backend = MsBackendMzR())

mz_hist <- 102.97047 #adapted for my case
ms2_hist <- sps %>%
  filterMsLevel(2) %>%
  filterPrecursorMz(mz = mz_hist + ppm(c(-mz_hist, mz_hist), 20))
ms2_hist
mz(ms2_hist)
plotSpectra(ms2_hist)
#until this plot line everything is perfect.

ms2_hist_Peaks <- ms2_hist %>%
  pickPeaks() %>%
  removePeaks(threshold = 500) %>%
  clean(all = TRUE)
ms2_hist_Peaks

Error in clean(., all = TRUE) : could not find function "clean"

sessionInfo()

R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] forcats_0.5.1       stringr_1.4.0       dplyr_1.0.5         purrr_0.3.4         readr_1.4.0         tidyr_1.1.3         tibble_3.1.1       
 [8] ggplot2_3.3.3       tidyverse_1.3.1     Spectra_1.1.20      ProtGenerics_1.23.9 BiocParallel_1.24.1 S4Vectors_0.28.1    BiocGenerics_0.36.1

loaded via a namespace (and not attached):
 [1] Biobase_2.50.0        httr_1.4.2            vsn_3.58.0            foreach_1.5.1         jsonlite_1.7.2        modelr_0.1.8         
 [7] assertthat_0.2.1      BiocManager_1.30.12   affy_1.68.0           cellranger_1.1.0      impute_1.64.0         pillar_1.6.0         
[13] backports_1.2.1       lattice_0.20-41       limma_3.46.0          glue_1.4.2            digest_0.6.27         rvest_1.0.0          
[19] colorspace_2.0-0      preprocessCore_1.52.1 plyr_1.8.6            MALDIquant_1.19.3     XML_3.99-0.6          pkgconfig_2.0.3      
[25] broom_0.7.6           haven_2.4.1           zlibbioc_1.36.0       scales_1.1.1          affyio_1.60.0         generics_0.1.0       
[31] IRanges_2.24.1        ellipsis_0.3.2        withr_2.4.2           cli_2.5.0             magrittr_2.0.1        crayon_1.4.1         
[37] readxl_1.3.1          fs_1.5.0              ncdf4_1.17            fansi_0.4.2           doParallel_1.0.16     MASS_7.3-53.1        
[43] xml2_1.3.2            mzR_2.24.1            tools_4.0.5           hms_1.0.0             lifecycle_1.0.0       MSnbase_2.17.8       
[49] munsell_0.5.0         reprex_2.0.0          cluster_2.1.2         pcaMethods_1.82.0     compiler_4.0.5        mzID_1.28.0          
[55] rlang_0.4.11          grid_4.0.5            iterators_1.0.13      rstudioapi_0.13       MsCoreUtils_1.3.3     gtable_0.3.0         
[61] codetools_0.2-18      DBI_1.1.1             R6_2.5.0              lubridate_1.7.10      utf8_1.2.1            clue_0.3-59          
[67] stringi_1.5.3         Rcpp_1.0.6            vctrs_0.3.8           dbplyr_2.1.1          tidyselect_1.1.1     
jorainer commented 3 years ago

Oh, sorry for that - we changed quite some code since. Maybe better to use a more updated tutorial such as this here: SpectraTutorials.

And for the removePeaks - we changed/renamed that function now into filterIntensity. To have the original usage you can use filterIntensity(sps, intensity = 500), but you can now define also a lower and upper limit for the intensity or alternatively define a function to support a spectra data dependent filter. Maybe check also the Spectra vignette and ?Spectra help page for more information.

Dev-RDV commented 3 years ago

Dear @jorainer, Thanks for the guidance. Now everything worked perfectly. Sincerely,