rformassspectrometry / Spectra

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

Bug in Spectra vignette #129

Closed plantton closed 3 years ago

plantton commented 3 years ago

I find there's a bug in the latest version of Spectra:

> library(msdata)
> library(Spectra)

> fl <- proteomics(full.names = TRUE)[5]
> sps_tmt <- Spectra(fl, backend = MsBackendHdf5Peaks(), hdf5path = tempdir())
> sps_tmt
MSn data (Spectra) with 0 spectra in a MsBackendHdf5Peaks backend:

The code block is copied from the vignette directly.

If I use mzR backend to initialize the Spectra instance, it will return an error. I think I didn't have it yesterday, since I just updated Spectra pkg this morning.

> sps_tmt <- Spectra(fl, source = MsBackendMzR(), backend = MsBackendHdf5Peaks(), hdf5path = tempdir())
Error in .Call("_H5Fopen", x, 0L, fapl@ID, PACKAGE = "rhdf5") : 
  Incorrect number of arguments (3), expecting 2 for '_H5Fopen'
In addition: Warning message:
In normalizePath(file.path(hdf5path, basename(files))) :
  path[1]="/tmp/RtmpMMSgju/TMT_Erwinia_1uLSike_Top10HCD_isol2_45stepped_60min_01.mzML.h5": No such file or directory
Error in validObject(object) : 
  invalid class “MsBackendHdf5Peaks” object: File /tmp/RtmpMMSgju/TMT_Erwinia_1uLSike_Top10HCD_isol2_45stepped_60min_01.mzML.h5 is not a Hdf5 file

However, when use MsBackendDataFrame backend, the Spectra instance can be created successfully.

> sps_tmt <- Spectra(fl, source = MsBackendMzR(), backend = MsBackendDataFrame())
> sps_tmt
MSn data (Spectra) with 509 spectra in a MsBackendMzR backend:
      msLevel     rtime scanIndex
    <integer> <numeric> <integer>
1           1   1108.30         1
2           2   1108.90         2
3           2   1109.59         3
4           2   1109.95         4
5           2   1110.30         5
...       ...       ...       ...
505         2   1321.60       505
506         2   1321.89       506
507         2   1322.18       507
508         2   1322.47       508
509         1   1322.95       509
 ... 33 more variables/columns.

file(s):
TMT_Erwinia_1uLSike_Top10HCD_isol2_45stepped_60min_01.mzML.gz
jorainer commented 3 years ago

Thanks for reporting! This seems to be related to a change in the rhdf5 package... I'll have a look into that.

jorainer commented 3 years ago

What version of rhdf5 do you have? I have 2.33.7 and just get a warning message (that I will also fix later).

> sps_tmt <- Spectra(fl, source = MsBackendMzR(), backend = MsBackendHdf5Peaks(), hdf5path = tempdir())
Warning message:
In normalizePath(file.path(hdf5path, basename(files))) :
  path[1]="/tmp/Rtmp05ZH4h/TMT_Erwinia_1uLSike_Top10HCD_isol2_45stepped_60min_01.mzML.h5": No such file or directory

My full session info:

> sessionInfo()
R version 4.0.2 Patched (2020-09-02 r79126)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-openmp/libopenblasp-r0.3.8.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=C             
 [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] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
[1] Spectra_0.99.3      ProtGenerics_1.21.0 BiocParallel_1.23.2
[4] S4Vectors_0.27.12   BiocGenerics_0.35.4 msdata_0.29.0      
[7] BiocManager_1.30.10

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5         codetools_0.2-16   IRanges_2.23.10    rhdf5filters_1.1.2
 [5] MASS_7.3-53        MsCoreUtils_1.1.5  ncdf4_1.17         mzR_2.23.0        
 [9] Rhdf5lib_1.11.3    tools_4.0.2        Biobase_2.49.1     compiler_4.0.2    
[13] rhdf5_2.33.7      
plantton commented 3 years ago

Indeed! I have to update my rhdf5 pkg. Thank you @jorainer !

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

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

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

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

other attached packages:
 [1] rhdf5_2.32.2        Spectra_0.99.2      BiocParallel_1.22.0 mzID_1.26.0         MSnbase_2.14.2      ProtGenerics_1.20.0
 [7] S4Vectors_0.26.1    mzR_2.22.0          Rcpp_1.0.5          Biobase_2.48.0      BiocGenerics_0.34.0

loaded via a namespace (and not attached):
 [1] msdata_0.28.0         compiler_4.0.2        pillar_1.4.6          BiocManager_1.30.10   plyr_1.8.6            iterators_1.0.12     
 [7] zlibbioc_1.34.0       tools_4.0.2           digest_0.6.25         ncdf4_1.17            MALDIquant_1.19.3     lifecycle_0.2.0      
[13] tibble_3.0.3          preprocessCore_1.50.0 gtable_0.3.0          lattice_0.20-41       pkgconfig_2.0.3       rlang_0.4.7          
[19] foreach_1.5.0         rstudioapi_0.11       dplyr_1.0.2           MsCoreUtils_1.1.4     IRanges_2.22.2        generics_0.0.2       
[25] vctrs_0.3.4           grid_4.0.2            tidyselect_1.1.0      glue_1.4.2            impute_1.62.0         R6_2.4.1             
[31] XML_3.99-0.5          limma_3.44.3          Rhdf5lib_1.10.1       ggplot2_3.3.2         purrr_0.3.4           magrittr_1.5         
[37] scales_1.1.1          pcaMethods_1.80.0     codetools_0.2-16      ellipsis_0.3.1        MASS_7.3-51.6         colorspace_1.4-1     
[43] affy_1.66.0           doParallel_1.0.15     munsell_0.5.0         vsn_3.56.0            crayon_1.3.4          affyio_1.58.0