Skip to content
New issue

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

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

Already on GitHub? # to your account

selectPeaks: operations are possible only for numeric, logical or complex types #278

Open
Don86 opened this issue Dec 6, 2020 · 3 comments

Comments

@Don86
Copy link

Don86 commented Dec 6, 2020

Running the workflow and the example dataset from here: https://bioconductor.org/packages/release/bioc/vignettes/RMassBank/inst/doc/RMassBank.html completes, but unable to run selectPeaks() afterward. Full code:

# load packages
library("pacman")
pacman::p_load("RMassBank", "RMassBankData")

# load various files and prepare workflow object
file.copy(system.file("list/NarcoticsDataset.csv", package="RMassBankData"), 
          "./Compoundlist.csv")
loadList("./Compoundlist.csv")
RmbSettingsTemplate("mysettings.ini")
loadRmbSettings("mysettings.ini")

fn_ls <- list.files(system.file("spectra", package="RMassBankData"),
                    ".mzML", 
                    full.names = TRUE)
w <- newMsmsWorkspace()
w@files <- fn_ls[1:2]

# run workflow
w <- msmsWorkflow(w, mode="pH", 
                  steps=c(1:4), 
                  archivename = "pH_narcotics")
w <- msmsWorkflow(w, mode="pH", 
                  steps=c(5:8), 
                  archivename ="pH_narcotics")

# select peaks
filtered <- selectPeaks(w, good=TRUE, bad=FALSE, cleaned=TRUE)

Error message:

Error in eval(f, o, enclos) & !is.na(eval(f, o, enclos)) : operations are possible only for numeric, logical or complex types

sessionInfo:

R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

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

other attached packages:
[1] RMassBankData_1.28.0
[2] RMassBank_3.0.0     
[3] pacman_0.5.1        
[4] Rcpp_1.0.5          

loaded via a namespace (and not attached):
 [1] lattice_0.20-41      
 [2] png_0.1-7            
 [3] gtools_3.8.2         
 [4] assertthat_0.2.1     
 [5] digest_0.6.27        
 [6] foreach_1.5.1        
 [7] R6_2.5.0             
 [8] plyr_1.8.6           
 [9] mzID_1.28.0          
[10] stats4_4.0.3         
[11] httr_1.4.2           
[12] ggplot2_3.3.2        
[13] pillar_1.4.7         
[14] gplots_3.1.1         
[15] itertools_0.1-3      
[16] zlibbioc_1.36.0      
[17] rlang_0.4.9          
[18] rstudioapi_0.13      
[19] S4Vectors_0.28.0     
[20] preprocessCore_1.52.0
[21] mzR_2.24.1           
[22] BiocParallel_1.24.1  
[23] ProtGenerics_1.22.0  
[24] munsell_0.5.0        
[25] fingerprint_3.5.7    
[26] compiler_4.0.3       
[27] xfun_0.19            
[28] pkgconfig_2.0.3      
[29] BiocGenerics_0.36.0  
[30] pcaMethods_1.82.0    
[31] tidyselect_1.1.0     
[32] tibble_3.0.4         
[33] IRanges_2.24.0       
[34] codetools_0.2-18     
[35] XML_3.99-0.5         
[36] crayon_1.3.4         
[37] dplyr_1.0.2          
[38] MASS_7.3-53          
[39] bitops_1.0-6         
[40] grid_4.0.3           
[41] gtable_0.3.0         
[42] lifecycle_0.2.0      
[43] affy_1.68.0          
[44] magrittr_2.0.1       
[45] rcdk_3.5.0           
[46] scales_1.1.1         
[47] ncdf4_1.17           
[48] KernSmooth_2.23-18   
[49] impute_1.64.0        
[50] affyio_1.60.0        
[51] doParallel_1.0.16    
[52] limma_3.46.0         
[53] ellipsis_0.3.1       
[54] generics_0.1.0       
[55] vctrs_0.3.5          
[56] rjson_0.2.20         
[57] iterators_1.0.13     
[58] tools_4.0.3          
[59] Biobase_2.50.0       
[60] MSnbase_2.16.0       
[61] glue_1.4.2           
[62] purrr_0.3.4          
[63] rcdklibs_2.3         
[64] parallel_4.0.3       
[65] yaml_2.2.1           
[66] colorspace_2.0-0     
[67] BiocManager_1.30.10  
[68] vsn_3.58.0           
[69] caTools_1.18.0       
[70] MALDIquant_1.19.3    
[71] rJava_0.9-13         
[72] knitr_1.30     
@sneumann
Copy link
Member

sneumann commented Dec 7, 2020

Hi, I can confirm the issue on linux, which is quite a relief as this is now reproducible and not operating system specific. Yours, Steffen

R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

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

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

other attached packages:
[1] RMassBankData_1.26.0 RMassBank_2.99.4     Rcpp_1.0.4.6        
[4] pacman_0.5.1        

loaded via a namespace (and not attached):
 [1] gtools_3.8.2          tidyselect_1.0.0      purrr_0.3.4          
 [4] rJava_0.9-13          lattice_0.20-41       colorspace_1.4-1     
 [7] vctrs_0.3.2           stats4_4.0.3          yaml_2.2.1           
[10] fingerprint_3.5.7     vsn_3.56.0            XML_3.99-0.3         
[13] rlang_0.4.7           pillar_1.4.4          glue_1.4.0           
[16] MSnbase_2.15.7        mzR_2.23.1            BiocParallel_1.22.0  
[19] affy_1.66.0           BiocGenerics_0.34.0   affyio_1.58.0        
[22] foreach_1.5.0         lifecycle_0.2.0       plyr_1.8.6           
[25] mzID_1.26.0           ProtGenerics_1.20.0   zlibbioc_1.34.0      
[28] munsell_0.5.0         pcaMethods_1.80.0     gtable_0.3.0         
[31] rcdklibs_2.3          caTools_1.18.0        codetools_0.2-16     
[34] Biobase_2.48.0        IRanges_2.22.1        doParallel_1.0.15    
[37] parallel_4.0.3        itertools_0.1-3       preprocessCore_1.50.0
[40] KernSmooth_2.23-17    scales_1.1.0          BiocManager_1.30.10  
[43] gdata_2.18.0          limma_3.44.1          rcdk_3.5.0           
[46] S4Vectors_0.26.0      gplots_3.0.3          impute_1.62.0        
[49] rjson_0.2.20          ggplot2_3.3.0         png_0.1-7            
[52] digest_0.6.25         dplyr_0.8.5           ncdf4_1.17           
[55] grid_4.0.3            bitops_1.0-6          magrittr_1.5         
[58] tibble_3.0.1          crayon_1.3.4          pkgconfig_2.0.3      
[61] MASS_7.3-53           ellipsis_0.3.0        assertthat_0.2.1     
[64] httr_1.4.1            iterators_1.0.12      R6_2.4.1             
[67] MALDIquant_1.19.3     compiler_4.0.3  

@sneumann sneumann changed the title RMassBank example workflow problems on a Mac selectPeaks: operations are possible only for numeric, logical or complex types Dec 7, 2020
@sneumann
Copy link
Member

sneumann commented Dec 7, 2020

The traceback() is

> filtered <- selectPeaks(w, good=TRUE, bad=FALSE, cleaned=TRUE)
Error in eval(f, o, enclos) & !is.na(eval(f, o, enclos)) : 
  operations are possible only for numeric, logical or complex types
In addition: Warning message:
In is.na(eval(f, o, enclos)) :
  is.na() applied to non-(list or vector) of type 'environment'
> traceback()
8: `[.data.frame`(o, eval(f, o, enclos) & !is.na(eval(f, o, enclos)), 
       , drop = FALSE)
7: o[eval(f, o, enclos) & !is.na(eval(f, o, enclos)), , drop = FALSE]
6: .local(o, ...)
5: selectPeaks(o@aggregated, ..., enclos)
4: selectPeaks(o@aggregated, ..., enclos)
3: .local(o, ...)
2: selectPeaks(w, good = TRUE, bad = FALSE, cleaned = TRUE)
1: selectPeaks(w, good = TRUE, bad = FALSE, cleaned = TRUE)

and seems to come from

o <- o[eval(f, o, enclos) & !is.na(eval(f,o,enclos)),,drop=FALSE]

o looks OK:

Browse[3]> o[1:3,1:3]
                                              mzFound intensity good
1_3_Chlorophenyl_piperazin_2818_pos.mzML.7   70.06518  29053.22 TRUE
1_3_Chlorophenyl_piperazin_2818_pos.mzML.18 110.99966  12117.51 TRUE
1_3_Chlorophenyl_piperazin_2818_pos.mzML.19 117.05731  19145.07 TRUE

filter is an environment with

Browse[3]> ls(filter)
[1] "fn_ls"         "RMassBank.env" "w"            
Browse[3]> filter$fn_ls
 [1] "/usr/local/lib/R/site-library/RMassBankData/spectra/1_3_Chlorophenyl_piperazin_2818_pos.mzML"                       
 [2] "/usr/local/lib/R/site-library/RMassBankData/spectra/1_3_Trifluoromethylphenyl_piperazin_2819_pos.mzML"              
...

Browse[3]> ls(filter$RMassBank.env)
[1] "export.invalid"             "export.molfiles"           
[3] "ReadAnnotation"             "strictMsMsSpectraSelection"
...

Browse[3]> filter$w
Object of class "msmsWorkspace"
 with files: 
  - 1_3_Chlorophenyl_piperazin_2818_pos.mzML 
  - 1_3_Trifluoromethylphenyl_piperazin_2819_pos.mzML 
 - 2818 	 foundOK: TRUE 
 - 2819 	 foundOK: TRUE 
...

enclos contains the msmsWorkspace:

Browse[3]> enclos$o
Object of class "msmsWorkspace"
 with files: 
  - 1_3_Chlorophenyl_piperazin_2818_pos.mzML 
  - 1_3_Trifluoromethylphenyl_piperazin_2819_pos.mzML 
 - 2818 	 foundOK: TRUE 
 - 2819 	 foundOK: TRUE 
Peaks found:
 - 2818 	 peaks: 114 57 67 74 108 145 164 116 115 137 167 211 327 181 
 - 2819 	 peaks: 94 64 64 100 157 248 286 116 96 149 199 306 450 228 
...

@meowcat , I am a bit lost about the intended code logic here (I need to learn about substitute() and friends ...) but hope to have provided some hints about the issue.
Yours, Steffen

@tsufz
Copy link
Member

tsufz commented Dec 7, 2020

Hi all,
Error in eval(f, o, enclos) & !is.na(eval(f, o, enclos)) : operations are possible only for numeric, logical or complex types

IMHO, this links to a data conversion problem. The message says operations are possible only for numeric, logical or complex types. Thus, could it be that some of the data is provided as charater or factor or what else, but not as numeric, logical or complex?

I had often the observation that R gets more strict with wrong data types due to better error handling or conditional tests.

Best,
Tobias

@tsufz tsufz added this to the Bugs and warnings milestone Feb 7, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants