tidyomics / tidyomics

Easily install and load packages from the tidyomcis ecosystem
https://tidyomics.github.io/tidyomicsBlog/
MIT License
35 stars 0 forks source link

build a tidy raw mass spectrometry data infrastructure (Spectra objects) #21

Open mikelove opened 4 days ago

lgatto commented 3 days ago

I documented a possible interface between Spectra objects and tables here.

> sciex_file <- dir(system.file("sciex", package = "msdata"), full.names = TRUE)
> sciex <- Spectra(sciex_file, backend = MsBackendMzR())
> sciex ## object of class Spectra
MSn data (Spectra) with 1862 spectra in a MsBackendMzR backend:
       msLevel     rtime scanIndex
     <integer> <numeric> <integer>
1            1     0.280         1
2            1     0.559         2
3            1     0.838         3
4            1     1.117         4
5            1     1.396         5
...        ...       ...       ...
1858         1   258.636       927
1859         1   258.915       928
1860         1   259.194       929
1861         1   259.473       930
1862         1   259.752       931
 ... 33 more variables/columns.

file(s):
20171016_POOL_POS_1_105-134.mzML
20171016_POOL_POS_3_105-134.mzML
> asDataFrame(sciex, i = 1:3, spectraVariables(sciex)[1:3])
DataFrame with 3707 rows and 5 columns
            mz intensity   msLevel     rtime acquisitionNum
     <numeric> <numeric> <integer> <numeric>      <integer>
1      105.043         0         1      0.28              1
2      105.045       412         1      0.28              1
3      105.046         0         1      0.28              1
4      107.055         0         1      0.28              1
5      107.057       412         1      0.28              1
...        ...       ...       ...       ...            ...
3703   133.984         0         1     0.838              3
3704   133.985       132         1     0.838              3
3705   133.987         0         1     0.838              3
3706   133.989       132         1     0.838              3
3707   133.990         0         1     0.838              3
lgatto commented 3 days ago

Also note that the functions that operate on Spectra objects can be piped:

x |>
 filterMsLevel(2L) |>
 filterRt(500, 750) |>
 ....