Package: rmzTabM
Authors: Steffen Neumann
Modified: 2023-01-25 07:39:20
Compiled: Wed Jan 25 07:48:16 2023

library(BiocStyle)
library(rmzTabM)
library(metabolighteR)
#> Loading required package: magrittr
library(kableExtra)

Converting an mzTab-M file to MetaboLights MAF

The Metabolites Asignement File (MAF) is used by the EMBL-EBI MetaboLights repository to capture the metabolite abundances in the individual samples, the spectral characteristics of the features and, if present, the metabolite identifications.

The convertMzTab2MAF() function will read the mzTab-M via readMzTab() and extract the smlTable and the smfTable. Abundances are extracted from the smlTable, while m/z and retention time come from the feature table.

The MAF is created as a data.frame and written as TSV using write.MAF() from the metabolighteR package by Tom Wilson. The data.frame is also returned as (invisible) return value of convertMzTab2MAF().


# An example file:
mzTabfile <- system.file("testdata", 
                         "MTBLS263.mztab", 
                         package="rmzTabM",
                         mustWork=TRUE)

# Another example file shipped is:
mztabfile <- system.file("testdata", 
                         c("lcmsms_dda_hydrophilic_height_mzTab.mztab"), 
                         package="rmzTabM",
                         mustWork=TRUE)

MAFfile <- file.path(tempdir(check=TRUE), "m_MTBLS0815_v2_maf.tsv")                      

maf <- convertMzTab2MAF(mzTabfile=mztabfile,
                        MAFfile=MAFfile)

kable(head(maf[!(grepl ("MSP: Unknown", maf$database_identifier) | is.na(maf$database_identifier)), ])) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", font_size = 7)) %>% 
  scroll_box(width = "800px", height = "200px")
database_identifier chemical_formula smiles inchi metabolite_identification mass_to_charge fragmentation charge modifications retention_time taxid species database database_version reliability uri search_engine search_engine_score smallmolecule_abundance_sub smallmolecule_abundance_stdev_sub smallmolecule_abundance_std_error_sub 0717_kinetex_wine_50_4min_pos_IDA_A1 0717_kinetex_wine_50_4min_pos_IDA_B1 0717_kinetex_wine_50_4min_pos_IDA_C1 0717_kinetex_wine_50_4min_pos_IDA_D1 0717_kinetex_wine_50_4min_pos_IDA_E1 0717_kinetex_wine_50_4min_pos_IDA_F1
193 MSP: URACIL C4H4N2O2 OC1=NC(O)=NC=C1 NA w/o MS2:URACIL 113.0359 NA NA NA 32.05267 NA NA 1 Unknown 63 NA NA NA NA NA NA 9664 7888 5912 13912 8022 4678
220 MSP: C5H9NO2; PlaSMA ID-48 C5H9NO2 NA NA C5H9NO2; PlaSMA ID-48 116.0708 NA NA NA 28.98533 NA NA 1 Unknown 88.8 NA NA NA NA NA NA 11891 6080 13243 14411 10669 28595
325 MSP: Pyroglutamic acid (not validated, isomer of 89); PlaSMA ID-88 C5H7NO3 O=C(O)C1NC(=O)CC1 NA Pyroglutamic acid (not validated, isomer of 89); PlaSMA ID-88 130.0494 NA NA NA 38.17650 NA NA 1 Unknown 86.8 NA NA NA NA NA NA 25494 19988 32873 28238 26622 35567
354 MSP: Leucine; PlaSMA ID-100 C6H13NO2 O=C(O)C(N)CC(C)C NA w/o MS2:Leucine; PlaSMA ID-100 132.1008 NA NA NA 147.66800 NA NA 1 Unknown 99.6 NA NA NA NA NA NA 1092 607 2840 465 1234 1083
402 MSP: Hypoxanthine C5H4N4O OC1=NC=NC=2NC=NC12 NA w/o MS2:Hypoxanthine 137.0468 NA NA NA 31.73683 NA NA 1 Unknown 68.1 NA NA NA NA NA NA 7305 3924 10788 13304 9321 8399
471 MSP: 4-Methyl-5-thiazoleethanol; LC-ESI-QTOF; MS2; CE C6H9NOS CC1=C(CCO)SC=N1 NA w/o MS2:4-Methyl-5-thiazoleethanol; LC-ESI-QTOF; MS2; CE 144.0475 NA NA NA 47.81267 NA NA 1 Unknown 67 NA NA NA NA NA NA 23383 17362 24074 32806 17364 34208

Session information

sessionInfo()
#> R version 4.2.2 (2022-10-31)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 22.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so
#> 
#> locale:
#>  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
#>  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
#>  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
#> [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] kableExtra_1.3.4    metabolighteR_0.1.4 magrittr_2.0.3     
#> [4] rmzTabM_1.0.5.9007  BiocStyle_2.26.0   
#> 
#> loaded via a namespace (and not attached):
#>  [1] tidyselect_1.2.0    xfun_0.36           bslib_0.4.2        
#>  [4] purrr_1.0.1         colorspace_2.1-0    vctrs_0.5.2        
#>  [7] generics_0.1.3      htmltools_0.5.4     viridisLite_0.4.1  
#> [10] yaml_2.3.7          utf8_1.2.2          rlang_1.0.6        
#> [13] pkgdown_2.0.7       jquerylib_0.1.4     pillar_1.8.1       
#> [16] glue_1.6.2          withr_2.5.0         lifecycle_1.0.3    
#> [19] stringr_1.5.0       munsell_0.5.0       ragg_1.2.5         
#> [22] rvest_1.0.3         caTools_1.18.2      memoise_2.0.1      
#> [25] evaluate_0.20       knitr_1.41          fastmap_1.1.0      
#> [28] fansi_1.0.4         highr_0.10          scales_1.2.1       
#> [31] BiocManager_1.30.19 cachem_1.0.6        desc_1.4.2         
#> [34] webshot_0.5.4       jsonlite_1.8.4      systemfonts_1.0.4  
#> [37] fs_1.6.0            textshaping_0.3.6   digest_0.6.31      
#> [40] stringi_1.7.12      dplyr_1.0.10        rprojroot_2.0.3    
#> [43] cli_3.6.0           tools_4.2.2         bitops_1.0-7       
#> [46] sass_0.4.5          tibble_3.1.8        tidyr_1.3.0        
#> [49] pkgconfig_2.0.3     xml2_1.3.3          rmarkdown_2.20     
#> [52] svglite_2.1.1       httr_1.4.4          rstudioapi_0.14    
#> [55] R6_2.5.1            compiler_4.2.2

References