Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Extracted Ion Chromatogram from MS2 data #205

Closed
michaelwitting opened this issue Aug 15, 2017 · 9 comments
Closed

Extracted Ion Chromatogram from MS2 data #205

michaelwitting opened this issue Aug 15, 2017 · 9 comments

Comments

@michaelwitting
Copy link
Collaborator

Hi,

I encountered another issue working with the SWATH data: Creating an EIC for the MS2 data.
Following error pops up when trying to create a chromatogram:

Warning message:
In .extractMultipleChromatograms(object, rt = rt, mz = mz, aggregationFun = aggregationFun, :
No MS 1 data present.

Data is the same as in my last issue posted. I wanted execute the following Code line:

bpis <- chromatogram(xrms_ms2_swath[[10]], mz = c(184.0, 184.1), aggregationFun = "max")

Thank you very much!

Best regards,

Michael

@jorainer
Copy link
Collaborator

Yup, sorry. I'll fix that. There will be soon a parameter msLevel that allows to specify from which MS level you want to extract the chromatogram.

@jorainer
Copy link
Collaborator

OK, my pull request has been merged into MSnbase (lgatto/MSnbase#247). If you install the latest MSnbase you can use chromatogram(object, msLevel = 2) to extract a chromatogram of MS level 2.

@michaelwitting
Copy link
Collaborator Author

bpis <- chromatogram(ms2data[[2]], msLevel = 2)

throws following error:

Error in .local(object, ...) : unused argument (msLevel = 2)

Same for bpis <- MSnbase::chromatogram(ms2data[[2]], msLevel = 2)

used versions are

xcms_2.99.7
MSnbase_2.3.10 (freshly installed from GitHub today)
mzR_2.10.0

@jorainer
Copy link
Collaborator

This is very strange. I've just installed MSnbase from github (devtools::install_github("lgatto/MSnbase", version is still 2.3.10) and that version does support the msLevel argument in chromatogram. Can you try to re-install the package please? Note that you will have to restart R or detach and reload the package if you want to use a newly installed/updated package.

@michaelwitting
Copy link
Collaborator Author

Just removed and re-installed MSnbase... Still the same error. Same after restarting R...

@jorainer
Copy link
Collaborator

That's strange. This is what I did:

> remove.packages("MSnbase")
Removing package from/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/library’
(aslibis unspecified)
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
> library(MSnbase)
Error in library(MSnbase) : there is no package calledMSnbase> devtools::install_github("lgatto/MSnbase")
Downloading GitHub repo lgatto/MSnbase@master
from URL https://api.github.com/repos/lgatto/MSnbase/zipball/master
Installing MSnbase
'/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/bin/R' --no-site-file  \
  --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/_2/xgzjxb8j6jg467lqv1j19cpr0000gn/T/RtmpaZPoZc/devtools11d9d5c59f4dc/lgatto-MSnbase-ffaa210'  \
  --library='/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/library'  \
  --install-tests 

* installing *source* packageMSnbase...
** libs
*** arch - x86_64
clang++  -I/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/include -I/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/include/x86_64 -DNDEBUG  -I"/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/library/Rcpp/include" -D__ACCELERATE__   -fPIC  -g -O2  -c RcppExports.cpp -o RcppExports.o
clang -I/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/include -I/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/include/x86_64 -DNDEBUG  -I"/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/library/Rcpp/include" -D__ACCELERATE__   -fPIC  -g -O2  -c Spectrum1_class.c -o Spectrum1_class.o
clang -I/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/include -I/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/include/x86_64 -DNDEBUG  -I"/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/library/Rcpp/include" -D__ACCELERATE__   -fPIC  -g -O2  -c Spectrum2_class.c -o Spectrum2_class.o
clang++  -I/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/include -I/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/include/x86_64 -DNDEBUG  -I"/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/library/Rcpp/include" -D__ACCELERATE__   -fPIC  -g -O2  -c imp_neighbour_avg.cpp -o imp_neighbour_avg.o
clang -I/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/include -I/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/include/x86_64 -DNDEBUG  -I"/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/library/Rcpp/include" -D__ACCELERATE__   -fPIC  -g -O2  -c utils.c -o utils.o
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/lib/x86_64 -L/usr/local/lib -o MSnbase.so RcppExports.o Spectrum1_class.o Spectrum2_class.o imp_neighbour_avg.o utils.o -L/Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/lib/x86_64 -lR -Wl,-framework -Wl,CoreFoundation
installing to /Users/jo/R/2017-07/R-3.4.1-BioC3.6-devel/lib/R/library/MSnbase/libs/x86_64
** R
** data
*** moving datasets to lazyload DB
Creating a new generic function forsmoothin packageMSnbaseCreating a new generic function fortrimwsin packageMSnbasein method forcoercewith signature"IBSpectra","MSnSet": no definition for classIBSpectra** inst
** tests
** preparing package for lazy loading
Creating a new generic function forsmoothin packageMSnbaseCreating a new generic function fortrimwsin packageMSnbasein method forcoercewith signature"IBSpectra","MSnSet": no definition for classIBSpectra** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (MSnbase)
> library(MSnbase)
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package:BiocGenericsThe following objects are masked frompackage:parallel:

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked frompackage:stats:

    IQR, mad, sd, var, xtabs

The following objects are masked frompackage:base:

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

Loading required package: Biobase
Welcome to Bioconductor

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

Loading required package: mzR
Loading required package: Rcpp
Loading required package: BiocParallel
fLoading required package: ProtGenerics

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


Attaching package:MSnbaseThe following object is masked frompackage:stats:

    smooth

The following object is masked frompackage:base:

    trimws

> cdfs <- dir(system.file("cdf/KO/", package = "faahKO"), full.names = TRUE)
> tmp <- readMSData(cdfs, mode = "onDisk")
Polarity can not be extracted from netCDF files, please set manually the polarity with the 'polarity' method.
> chromatogram(tmp, msLevel = 2)
Chromatograms with 0 rows and 6 columns
phenoData with 1 variables
Warning message:
In .extractMultipleChromatograms(object, rt = rt, mz = mz, aggregationFun = aggregationFun,  :
  No MS 2 data present.
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin16.7.0/x86_64 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib

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

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

other attached packages:
[1] MSnbase_2.3.10      ProtGenerics_1.9.0  BiocParallel_1.11.6
[4] mzR_2.11.7          Rcpp_0.12.12        Biobase_2.37.2     
[7] BiocGenerics_0.23.0

loaded via a namespace (and not attached):
 [1] BiocInstaller_1.27.3  compiler_3.4.1        git2r_0.19.0         
 [4] plyr_1.8.4            iterators_1.0.8       zlibbioc_1.23.0      
 [7] tools_3.4.1           MALDIquant_1.16.2     digest_0.6.12        
[10] memoise_1.1.0         tibble_1.3.4          preprocessCore_1.39.0
[13] gtable_0.2.0          lattice_0.20-35       rlang_0.1.2          
[16] foreach_1.4.3         curl_2.8.1            withr_2.0.0          
[19] httr_1.3.1            knitr_1.17            IRanges_2.11.12      
[22] S4Vectors_0.15.5      devtools_1.13.3       stats4_3.4.1         
[25] grid_3.4.1            impute_1.51.0         R6_2.2.2             
[28] XML_3.98-1.9          limma_3.33.7          ggplot2_2.2.1        
[31] scales_0.4.1          pcaMethods_1.69.0     codetools_0.2-15     
[34] mzID_1.15.0           colorspace_1.3-2      affy_1.55.0          
[37] doParallel_1.0.10     lazyeval_0.2.0        munsell_0.4.3        
[40] vsn_3.45.2            affyio_1.47.0        

of course I can't extract MS level > 1 from the CDF files, but the msLevel parameter is supported. What is the class of your ms2data[[2]]?

@michaelwitting
Copy link
Collaborator Author

Well it looks like that is the problem:

> ms2data[[2]]
MSn experiment data ("XCMSnExp")
Object size in memory: 0.14 Mb
- - - Spectra data - - -
 MS level(s): 2 
 Number of spectra: 551 
 MSn retention times: 0:18 - 10:1 minutes
- - - Processing information - - -
Data loaded [Tue Aug 22 13:17:40 2017] 
Filter: select MS level(s) 2 [Tue Aug 22 13:17:46 2017] 
Filter: select MS level(s) 2 [Tue Aug 22 13:18:32 2017] 
 MSnbase version: 2.3.10 
- - - Meta data  - - -
phenoData
  rowNames: Bruker.mzML
  varLabels: sampleNames
  varMetadata: labelDescription
Loaded from:
  Bruker.mzML 
protocolData: none
featureData
  featureNames: F1.S00091 F1.S00120 ... F1.S16041 (551 total)
  fvarLabels: fileIdx spIdx ... spectrum (26 total)
  fvarMetadata: labelDescription
experimentData: use 'experimentData(object)'
- - - xcms preprocessing - - -
Chromatographic peak detection:
 method: centWave 
 19 peaks identified in 1 samples.
 On average 19 chromatographic peaks per sample.

on xrms_ms2_swath it is working.

> xrms_ms2_swath[[2]]
MSn experiment data ("OnDiskMSnExp")
Object size in memory: 0.14 Mb
- - - Spectra data - - -
 MS level(s): 2 
 Number of spectra: 551 
 MSn retention times: 0:18 - 10:1 minutes
- - - Processing information - - -
Data loaded [Tue Aug 22 13:17:40 2017] 
Filter: select MS level(s) 2 [Tue Aug 22 13:17:46 2017] 
 MSnbase version: 2.3.10 
- - - Meta data  - - -
phenoData
  rowNames: Bruker.mzML
  varLabels: sampleNames
  varMetadata: labelDescription
Loaded from:
  Bruker.mzML 
protocolData: none
featureData
  featureNames: F1.S00091 F1.S00120 ... F1.S16041 (551 total)
  fvarLabels: fileIdx spIdx ... spectrum (26 total)
  fvarMetadata: labelDescription
experimentData: use 'experimentData(object)'

if I use ms1data for extracting a chromatogram it is working although it is XCMSnExp

Hope that makes things clear???

jorainer added a commit that referenced this issue Aug 22, 2017
- Add argument msLevel to chromatogram,XCMSnExp.
@jorainer
Copy link
Collaborator

Thanks for the info! So sorry, it's my fault. I completely forgot that I have a chromatogram,XCMSnExp method in xcms. That one didn't have (yet) the msLevel argument. Now, with the most recent version in the xcms3 branch there is the parameter.

devtools::install_github("sneumann/xcms", ref = "xcms3")

@michaelwitting
Copy link
Collaborator Author

Now it's working. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants