Warning in In chromPeakSpectra: Lazy evaluation queue is not empty, results in NULL object
0
1
Entering edit mode
e.terlova ▴ 20
@eterlova-22651
Last seen 2.6 years ago
Belgium

Hello all,

I am trying to extract MS2 level spectra from my dataset after xcms pre-processing using a Spectra package. I am following this tutorial : https://jorainer.github.io/MetaboAnnotationTutorials/articles/annotation-use-cases.html

however calling the chromPeakSpectra function results in a warning and a NULL object:


> xdata_ms2 <- chromPeakSpectra(xdata_filled, return.type="Spectra", peaks = pks_match_ms1$peak_id)
Warning message:
In chromPeakSpectra(xdata_filled, return.type = "Spectra", peaks = pks_match_ms1$peak_id) :
  Lazy evaluation queue is not empty. Will ignore any processing steps as 'return.type = "Spectra"' and 'return.type = "List"' currently don't support a non-empty processing queue.
> xdata_ms2
NULL

> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /home/FCAM/eterlova/miniconda3/envs/Rmetab/lib/libopenblasp-r0.3.17.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] data.table_1.14.2           MetaboAnnotation_0.99.7    
 [3] MsBackendMassbank_1.2.0     RSQLite_2.2.10             
 [5] pander_0.6.4                Spectra_1.5.12             
 [7] xcms_3.16.1                 MSnbase_2.20.4             
 [9] ProtGenerics_1.26.0         mzR_2.28.0                 
[11] Rcpp_1.0.8                  BiocParallel_1.28.3        
[13] SummarizedExperiment_1.24.0 Biobase_2.54.0             
[15] GenomicRanges_1.46.1        GenomeInfoDb_1.30.1        
[17] IRanges_2.28.0              S4Vectors_0.32.3           
[19] BiocGenerics_0.40.0         MatrixGenerics_1.6.0       
[21] matrixStats_0.61.0         

loaded via a namespace (and not attached):
 [1] bitops_1.0-7           fs_1.5.2               bit64_4.0.5           
 [4] doParallel_1.0.17      RColorBrewer_1.1-2     tools_4.1.0           
 [7] utf8_1.2.2             R6_2.5.1               affyio_1.64.0         
[10] DBI_1.1.2              colorspace_2.0-3       tidyselect_1.1.2      
[13] bit_4.0.4              compiler_4.1.0         MassSpecWavelet_1.60.0
[16] preprocessCore_1.56.0  cli_3.2.0              DelayedArray_0.20.0   
[19] scales_1.1.1           DEoptimR_1.0-10        robustbase_0.93-9     
[22] affy_1.72.0            digest_0.6.29          XVector_0.34.0        
[25] pkgconfig_2.0.3        MetaboCoreUtils_1.3.7  fastmap_1.1.0         
[28] limma_3.50.1           rlang_1.0.2            impute_1.68.0         
[31] generics_0.1.2         mzID_1.32.0            dplyr_1.0.8           
[34] RCurl_1.98-1.6         magrittr_2.0.2         GenomeInfoDbData_1.2.7
[37] MALDIquant_1.21        Matrix_1.4-0           munsell_0.5.0         
[40] fansi_1.0.2            MsCoreUtils_1.7.4      lifecycle_1.0.1       
[43] vsn_3.62.0             MASS_7.3-55            zlibbioc_1.40.0       
[46] plyr_1.8.6             grid_4.1.0             blob_1.2.2            
[49] parallel_4.1.0         crayon_1.5.0           lattice_0.20-45       
[52] MsFeatures_1.2.0       pillar_1.7.0           codetools_0.2-18      
[55] XML_3.99-0.9           glue_1.6.2             pcaMethods_1.86.0     
[58] BiocManager_1.30.16    vctrs_0.3.8            foreach_1.5.2         
[61] gtable_0.3.0           RANN_2.6.1             purrr_0.3.4           
[64] clue_0.3-60            assertthat_0.2.1       cachem_1.0.6          
[67] ggplot2_3.3.5          ncdf4_1.19             tibble_3.1.6          
[70] iterators_1.0.14       memoise_2.0.1          cluster_2.1.2         
[73] ellipsis_0.3.2

I looked at the description of this function, and indeed

> length(xdata_filled@spectraProcessingQueue)
[1] 2

But calling reset function results in an error (which makes sense since I failed to create a Spectra object):

> reset(xdata_ms2)
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘reset’ for signature ‘"NULL"’
> reset(xdata_filled)
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘reset’ for signature ‘"XCMSnExp"’

Could somebody help me understand what is wrong here and how to fix it?

Best, Lisa

xcms Spectra • 1.3k views
ADD COMMENT
1
Entering edit mode

Thanks for the detailed description of your problem! That makes it much easier to tackle it. Could you please provide the content of your processing queue (i.e. xdata_filled@spectraProcessingQueue)?

The reason why it is not working is that the processing queues of the MSnbase/xcms objects are not (yet) compatible with those of Spectra objects. Thus, the lazy processings that were added to your xcms result object can not be transferred to the Spectra object. Therefore we need somehow to either apply the processing queue to your xcms result object (would in fact not be that easy) or drop it (if possible).

ADD REPLY
1
Entering edit mode

Thank you for your continuing help!

Here is my processing queue:

> xdata_filled@spectraProcessingQueue
[[1]]
Object of class "ProcessingStep"
 Function: smooth
 Arguments:
  o method = SavitzkyGolay
  o halfWindowSize = 4
  o msLevel. = 12

[[2]]
Object of class "ProcessingStep"
 Function: pickPeaks
 Arguments:
  o method = MAD
  o halfWindowSize = 3
  o SNR = 0
  o ignoreCentroided = TRUE
  o refineMz = descendPeak
  o msLevel. = 12
ADD REPLY
1
Entering edit mode

Oh, I see - so this is not something we can simply drop. Have you actually considered to run the centroiding independently of the data analysis? That's at least how we process our files, i.e. the instrument records in profile mode, but then I have a script to perform the centroiding on all mzML files and export the centroided data again as mzML files. Thus, for all my analyses I just use the centroided files - that will also increase the performance considerably, because there is no need anymore to perform the centroiding on-the-fly (like in your case).

You could have a look here for some example code. Basically, it would be very simple: after you read your data with readMSData, apply your centroiding and then export the centroided data to mzML files (<new folder> below would be a character with the path to the directory where to store the mzML files):

new_files <- paste0(<new folder>, "/", basename(fileNames(data)))
writeMSData(data_cent, file = new_files, copy = TRUE)

You could then re-import these files with readMSData and perform the analysis on those (so yes, sorry, you'll have to re-run the whole xcms-based preprocessing again). That way your processing queue will be empty and you'll be able to export MS2 spectra as a Spectra object.

Out of curiosity, I assume you specified msLevel = c(1, 2) above and not msLevel = 12 for the smooth and pickPeaks?

ADD REPLY
0
Entering edit mode

Thank you for your advice! it did not even occur to me to export the files after centroiding. And no problem about re-running my XCMS analysis -- I've done it a few times already for even more stupid mistakes:)

And thank you for catching msLevel = 12 for the smooth and pickPeaks. Looks like I did not specified msLevel at all:

# smoothing data
rawdata_sg <- raw_data %>% smooth(method = "SavitzkyGolay", halfWindowSize = 4L)

# centroiding data
rawdata_cent <- rawdata_sg %>% pickPeaks(refineMz = "descendPeak")

Will fix this in my re-run.

ADD REPLY
1
Entering edit mode

no worries, if you did not specify it in smooth or pickPeaks it will use all MS levels in the data set. I guess it was correctly set to MS levels 1 and 2, but the print somehow failed to separate the two in the on-screen printout.

ADD REPLY

Login before adding your answer.

Traffic: 702 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6