sneumann / xcms

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

findChromPeaks() and refineChromPeaks() is sending error #641

Open Hani16 opened 1 year ago

Hani16 commented 1 year ago

I am using R-version 4.2.2 and trying to run xcms for GC-data. The first part of the data processing - to extract information of the chromatography peaks is giving error. Here is the code I am trying to run:

##XCMS data extraction steps
#Load required packages
library(xcms)
library(doParallel)
library(BiocParallel)
library(RColorBrewer)

#Read raw data into XCMSMSn file

raw_data <- readMSData(files = ms_files,
                       mode = "onDisk")

#Step 1, peak detection
#Define CentWave parameterds
cwp <- CentWaveParam(
  ppm= 5, 
  peakwidth= c(2,10), 
  snthr= 5, 
  mzdiff= -0.001, 
  noise= 5000, 
  prefilter= c(3,100),
  mzCenterFun= "wMean",
  integrate= 1,
  fitgauss= FALSE)

#Detect peaks using cwp
step_01_set <- findChromPeaks(raw_data, 
                              BPPARAM=SnowParam(workers = c1),
                              param = cwp)

#Step 1a, merge split peaks
#Merge split peaks using parameters in mpp
step_01a_set <- refineChromPeaks(step_01_set, param= MergeNeighboringPeaksParam(
  expandRt = 10,
  expandMz = 0,
  ppm = 3,
  minProp = 0.9))

And here is the error I am getting:

Attaching package: ‘BiocGenerics’

The following objects are masked from ‘package:stats’:

    IQR, mad, sd, var, xtabs

The following objects are masked from ‘package:base’:

    anyDuplicated, append, as.data.frame, basename, cbind, colnames, dirname, do.call,
    duplicated, eval, evalq, Filter, Find, get, grep, grepl, intersect, is.unsorted, lapply,
    Map, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
    rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply, union, unique, unsplit,
    which.max, which.min

Welcome to Bioconductor

    Vignettes contain introductory material; view with 'browseVignettes()'. To cite
    Bioconductor, see 'citation("Biobase")', and for packages 'citation("pkgname")'.

Attaching package: ‘S4Vectors’

The following objects are masked from ‘package:base’:

    expand.grid, I, unname

Attaching package: ‘ProtGenerics’

The following object is masked from ‘package:stats’:

    smooth

This is MSnbase version 2.22.0 
  Visit https://lgatto.github.io/MSnbase/ to get started.

Attaching package: ‘MSnbase’

The following object is masked from ‘package:base’:

    trimws

This is xcms version 3.18.0 

Attaching package: ‘xcms’

The following object is masked from ‘package:stats’:

    sigma

Detecting mass traces at 5 ppm ... OK
Detecting chromatographic peaks in 119750 regions of interest ... OK: 26719 found.
Detecting mass traces at 5 ppm ... OK
Detecting chromatographic peaks in 121014 regions of interest ... OK: 26228 found.
Detecting mass traces at 5 ppm ... OK
Detecting chromatographic peaks in 126044 regions of interest ... OK: 28539 found.

Evaluating 2969 peaks in file 20221018_Yakov_Validation_31.mzXML for merging ... 
Evaluating 2815 peaks in file 20221018_Yakov_Validation_22.mzXML for merging ... 
Evaluating 2844 peaks in file 20221018_Yakov_Validation_16.mzXML for merging ... 
Evaluating 2812 peaks in file 20221018_Yakov_Validation_10.mzXML for merging ... 
Evaluating 1373 peaks in file 20221018_Yakov_Validation_01.mzXML for merging ... 
Evaluating 3051 peaks in file 20221018_Yakov_Validation_34.mzXML for merging ... 
Evaluating 2262 peaks in file 20221018_Yakov_Validation_40.mzXML for merging ... 
Stop worker failed with the error: wrong args for environment subassignment
Error: BiocParallel errors
  1 remote errors, element index: 1
  39 unevaluated and other errors
  first remote error:
Error: BiocParallel errors
  1 remote errors, element index: 1
  0 unevaluated and other errors
  first remote error:
Error in socketConnection(port = port, server = TRUE, blocking = TRUE, : cannot open the connection
jorainer commented 1 year ago

Can you please add the output of your sessionInfo()?

From the error message it seems that this is related to the parallel processing setup you used (seems that the connection to one of the worker processes is closed). Can you try to run the same code but using BPPARAM = SerialParam()?

Hani16 commented 1 year ago

Hi @jorainer ,

Thank you for responding!

Here is the output for sessionInfo()

sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

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

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

other attached packages:
 [1] RColorBrewer_1.1-3  doParallel_1.0.17  
 [3] iterators_1.0.14    foreach_1.5.2      
 [5] xcms_3.8.2          MSnbase_2.12.0     
 [7] ProtGenerics_1.18.0 S4Vectors_0.24.4   
 [9] mzR_2.20.0          Rcpp_1.0.7         
[11] BiocParallel_1.20.1 Biobase_2.46.0     
[13] BiocGenerics_0.32.0

loaded via a namespace (and not attached):
 [1] vsn_3.54.0             splines_3.6.3         
 [3] assertthat_0.2.1       BiocManager_1.30.19   
 [5] affy_1.64.0            yaml_2.3.6            
 [7] robustbase_0.95-0      impute_1.60.0         
 [9] pillar_1.8.1           lattice_0.20-45       
[11] glue_1.6.2             limma_3.42.2          
[13] digest_0.6.30          colorspace_2.0-3      
[15] Matrix_1.5-3           htmltools_0.5.3       
[17] preprocessCore_1.48.0  plyr_1.8.8            
[19] MALDIquant_1.19.3      XML_3.99-0.3          
[21] pkgconfig_2.0.3        GetoptLong_1.0.5      
[23] zlibbioc_1.32.0        scales_1.2.1          
[25] RANN_2.6.1             affyio_1.56.0         
[27] tibble_3.1.8           generics_0.1.3        
[29] IRanges_2.20.2         ggplot2_3.4.0         
[31] MassSpecWavelet_1.52.0 cli_3.4.1             
[33] survival_3.4-0         magrittr_2.0.3        
[35] crayon_1.5.2           evaluate_0.18         
[37] ncdf4_1.19             fansi_1.0.3           
[39] MASS_7.3-58.1          tools_3.6.3           
[41] GlobalOptions_0.1.2    lifecycle_1.0.3       
[43] ComplexHeatmap_2.2.0   munsell_0.5.0         
[45] cluster_2.1.4          pcaMethods_1.78.0     
[47] compiler_3.6.3         mzID_1.24.0           
[49] rlang_1.0.6            grid_3.6.3            
[51] rstudioapi_0.14        rjson_0.2.20          
[53] circlize_0.4.15        rmarkdown_2.18        
[55] gtable_0.3.1           codetools_0.2-18      
[57] multtest_2.42.0        DBI_1.1.3             
[59] R6_2.5.1               knitr_1.41            
[61] dplyr_1.0.10           fastmap_1.1.0         
[63] utf8_1.2.2             clue_0.3-62           
[65] shape_1.4.6            vctrs_0.5.1           
[67] png_0.1-7              DEoptimR_1.0-11       
[69] tidyselect_1.2.0       xfun_0.35

I used BPPARAM = SerialParam() while processing for findChromPeaks() I receive the following error Error in x$.self$finalize() : attempt to apply non-function but it detects the peaks. For refining the peaks it gives error Error in refineChromPeaks(step_01_set, param = MergeNeighboringPeaksParam(expandRt = 10, : could not find function "refineChromPeaks"

jorainer commented 1 year ago

Your version of xcms does not yet provide the refineChromPeaks function, this was introduced with version 3.9.1 while you have 3.8.2. I would suggest to update to a new version of R and new Bioconductor version (that will come with a new version of xcms). Ideally, make a fresh installation of R, install the Bioconductor installer with install.packages("BiocManager") and then xcms (or any other packages that you need) using BiocManager::install("xcms").