Clustering Spectra from High Resolution DI-MS/MS Data Using CluMSID

Tobias Depke

April 25, 2023


Although originally developed for liquid chromatography-tandem mass spectrometry (LC-MS/MS) data, CluMSID can also be used with direct infusion-tandem mass spectrometry (DI-MS/MS) data.

Generally, the missing retention time dimension makes feature annotation in metabolomics harder but if only direct infusion data is at hand, CluMSID can help to get an overview of the chemodiversity of a sample measured by DI-MS/MS.

In this example, we will use a similar sample (1uL Pseudomonas aeruginosa PA14 cell extract) as in the General Tutorial, measured on the same machine, a Bruker maxisHD qTOF operated in ESI-(+) mode with auto-MS/MS but without chromatographic separation.

Data import

We load the file from the CluMSIDdata package:


DIfile <- system.file("extdata", 
                        package = "CluMSIDdata")

Data preprocessing

The extraction of spectra works the same way as with LC-MS/MS data:

ms2list <- extractMS2spectra(DIfile)
#> [1] 373

Merging of redundant spectra is less straightforward when retention time is not available. Depending on the MS/MS method it can be next to impossible to decide whether two spectra with the same precursor m/z and similar fragmentation patterns derive from the same analyte or from two different but structurally similar ones.

In this example, we would like to merge spectra with identical precursor ions only if they were recorded one right after another. We can do so by setting rt_tolerance to 1 second:

featlist <- mergeMS2spectra(ms2list, rt_tolerance = 1)
#> [1] 349

We see that we have hardly reduced the number of spectra in the list. If we would decide to merge all spectra with identical precursor m/z from the entire run, we could do so by setting rt_tolerance to the duration of the run, in this case approx. 250 seconds:

testlist <- mergeMS2spectra(ms2list, rt_tolerance = 250)
#> [1] 75

The resulting number of spectra is drastically lower but the danger of merging spectra that do not actually derive from the same analyte is also very big.

Generation of distance matrix

In this very explorative example, we skip the integration of previous knowledge on feature identities and generate a distance matrix right away:

distmat <- distanceMatrix(featlist)

Data exploration

Starting from this distance matrix, we can use all the data exploration functions that CluMSID offers. In this example workflow, we look at a cluster dendrogram:

HCplot(distmat, cex = 0.5)

Figure 1: Circularised dendrogram as a result of agglomerative hierarchical clustering with average linkage as agglomeration criterion based on MS2 spectra similarities of the DI-MS/MS example data set. Each leaf represents one feature and colours encode cluster affiliation of the features. Leaf labels display feature IDs, along with feature annotations, if existent. Distance from the central point is indicative of the height of the dendrogram.

It is directly obvious that we have some spectra that are nearly identical and thus most likely derive from the same analyte, e.g. the many spectra with a precursor m/z of 270.19. But we still see nice clustering of similar spectra with different precursor m/z, e.g. the huge gray cluster that contains a lot of different alkylquinolone type metabolites (see General Tutorial).

In conclusion, CluMSID is very useful to provide an overview of spectral similarities within DI-MS/MS runs but wherever annotation is in the focus, one should not do without the additional layer of information created by chromatographic separation.

Session Info

#> R version 4.3.0 RC (2023-04-13 r84269)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 22.04.2 LTS
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.17-bioc/R/lib/ 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB              LC_COLLATE=C              
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> time zone: America/New_York
#> tzcode source: system (glibc)
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> other attached packages:
#> [1] CluMSIDdata_1.15.0 CluMSID_1.16.0    
#> loaded via a namespace (and not attached):
#>  [1] tidyselect_1.2.0      viridisLite_0.4.1     dplyr_1.1.2          
#>  [4] bitops_1.0-7          lazyeval_0.2.2        fastmap_1.1.1        
#>  [7] reshape_0.8.9         GGally_2.1.2          XML_3.99-0.14        
#> [10] digest_0.6.31         lifecycle_1.0.3       cluster_2.1.4        
#> [13] ProtGenerics_1.32.0   magrittr_2.0.3        dbscan_1.1-11        
#> [16] compiler_4.3.0        rlang_1.1.0           sass_0.4.5           
#> [19] tools_4.3.0           utf8_1.2.3            yaml_2.3.7           
#> [22] data.table_1.14.8     sna_2.7-1             knitr_1.42           
#> [25] htmlwidgets_1.6.2     plyr_1.8.8            RColorBrewer_1.1-3   
#> [28] BiocParallel_1.34.0   KernSmooth_2.23-20    purrr_1.0.1          
#> [31] BiocGenerics_0.46.0   grid_4.3.0            stats4_4.3.0         
#> [34] preprocessCore_1.62.0 fansi_1.0.4           caTools_1.18.2       
#> [37] colorspace_2.1-0      ggplot2_3.4.2         scales_1.2.1         
#> [40] gtools_3.9.4          iterators_1.0.14      MASS_7.3-59          
#> [43] cli_3.6.1             mzR_2.34.0            rmarkdown_2.21       
#> [46] generics_0.1.3        httr_1.4.5            ncdf4_1.21           
#> [49] ape_5.7-1             cachem_1.0.7          affy_1.78.0          
#> [52] zlibbioc_1.46.0       network_1.18.1        parallel_4.3.0       
#> [55] impute_1.74.0         BiocManager_1.30.20   vsn_3.68.0           
#> [58] vctrs_0.6.2           jsonlite_1.8.4        IRanges_2.34.0       
#> [61] S4Vectors_0.38.0      MALDIquant_1.22.1     clue_0.3-64          
#> [64] foreach_1.5.2         limma_3.56.0          plotly_4.10.1        
#> [67] tidyr_1.3.0           jquerylib_0.1.4       affyio_1.70.0        
#> [70] glue_1.6.2            MSnbase_2.26.0        statnet.common_4.8.0 
#> [73] codetools_0.2-19      gtable_0.3.3          mzID_1.38.0          
#> [76] munsell_0.5.0         tibble_3.2.1          pillar_1.9.0         
#> [79] pcaMethods_1.92.0     htmltools_0.5.5       gplots_3.1.3         
#> [82] R6_2.5.1              doParallel_1.0.17     evaluate_0.20        
#> [85] lattice_0.21-8        Biobase_2.60.0        highr_0.10           
#> [88] bslib_0.4.2           Rcpp_1.0.10           coda_0.19-4          
#> [91] nlme_3.1-162          xfun_0.39             MsCoreUtils_1.12.0   
#> [94] pkgconfig_2.0.3