Clustering Mass Spectra from Low Resolution LC-MS/MS Data Using CluMSID

Tobias Depke

October 24, 2023

Introduction

As described in the GC-EI-MS tutorial, CluMSID can also be used to analyse low resolution data – although using low resolution data comes at a cost.

In this example, we will use a similar sample (1uL Pseudomonas aeruginosa PA14 cell extract) as in the General Tutorial, measured with similar chromatography but on a different mass spectrometer, a Bruker amaZon ion trap instrument operated in ESI-(+) mode with auto-MS/MS. In addition to introducing a workflow for low resolution LC-MS/MS data, this example also demonstrates that CluMSID can work with data from different types of mass spectrometers.

Data import

We load the file from the CluMSIDdata package:

library(CluMSID)
library(CluMSIDdata)

lowresfile <- system.file("extdata", 
                        "PA14_amazon_lowres.mzXML",
                        package = "CluMSIDdata")

Data preprocessing

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

ms2list <- extractMS2spectra(lowresfile)
length(ms2list)
#> [1] 1989

Like in the GC-EI-MS example, we have to adjust mz_tolerance to a much higher value compared to high resolution data, while the retention time tolerance can remain unchanged.

featlist <- mergeMS2spectra(ms2list, mz_tolerance = 0.02)
length(featlist)
#> [1] 525

We see that we have similar numbers of spectra as in the General Tutorial, because we tried to keep all parameters except for the mass spectrometer type comparable.

Generation of distance matrix

As we do not have low resolution spectral libraries at hand, we skip the integration of previous knowledge on feature identities in this example 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.

When we now make an MDS plot, we learn that the similarity data is very different from the comparable high resolution data:

MDSplot(distmat)

Figure 1: Multidimensional scaling plot as a visualisation of MS2 spectra similarities of the low resolution LC-MS/MS example data set. Black dots signify spectra from unknown metabolites.

To get a better overview of the data and the general similarity behaviour, we create a heat map of the distance matrix:

HCplot(distmat, type = "heatmap", 
                cexRow = 0.1, cexCol = 0.1,
                margins = c(6,6))

Figure 2: Symmetric heat map of the distance matrix displaying MS2 spectra similarities of the low resolution LC-MS/MS example data set. along with dendrograms resulting from hierarchical clustering based on the distance matrix. The colour encoding is shown in the top-left insert.

We clearly see that the heat map is generally a lot “warmer” than in the General Tutorial (an intuition that is supported by the histogram in the top-left corner), i.e. we have a higher general degree of similarity between spectra. That is not surprising as the m/z information has much fewer levels than in high resolution data and fragments of different sum formula are more likely to have indistinguishable mass-to-charge ratios.

We also see that some more or less compact clusters can be identified. This is easier to inspect in the dendrogram visualisation:

HCplot(distmat, h = 0.8, cex = 0.3)

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

In conclusion, CluMSID is capable of processing low resolution LC-MS/MS data and if high resolution data is not available, it can be very useful to provide an overview of spectral similarities in low resolution data, thereby helping metabolite annotation if some individual metabolites can be identified by comparison to authentic standards. However, concerning feature annotation, high resolution methods should always be favoured for the many benefits they provide.

Session Info

sessionInfo()
#> R version 4.3.1 (2023-06-16)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 22.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.18-bioc/R/lib/libRblas.so 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
#> 
#> 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            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: America/New_York
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats4    stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#>  [1] magrittr_2.0.3      metaMSdata_1.37.0   metaMS_1.38.0      
#>  [4] CAMERA_1.58.0       xcms_4.0.0          MSnbase_2.28.0     
#>  [7] ProtGenerics_1.34.0 S4Vectors_0.40.0    mzR_2.36.0         
#> [10] Rcpp_1.0.11         BiocParallel_1.36.0 Biobase_2.62.0     
#> [13] BiocGenerics_0.48.0 CluMSIDdata_1.17.0  CluMSID_1.18.0     
#> 
#> loaded via a namespace (and not attached):
#>   [1] RColorBrewer_1.1-3          rstudioapi_0.15.0          
#>   [3] jsonlite_1.8.7              MultiAssayExperiment_1.28.0
#>   [5] farver_2.1.1                MALDIquant_1.22.1          
#>   [7] rmarkdown_2.25              fs_1.6.3                   
#>   [9] zlibbioc_1.48.0             vctrs_0.6.4                
#>  [11] multtest_2.58.0             RCurl_1.98-1.12            
#>  [13] base64enc_0.1-3             htmltools_0.5.6.1          
#>  [15] S4Arrays_1.2.0              progress_1.2.2             
#>  [17] Formula_1.2-5               SparseArray_1.2.0          
#>  [19] mzID_1.40.0                 sass_0.4.7                 
#>  [21] KernSmooth_2.23-22          bslib_0.5.1                
#>  [23] htmlwidgets_1.6.2           plyr_1.8.9                 
#>  [25] impute_1.76.0               plotly_4.10.3              
#>  [27] cachem_1.0.8                igraph_1.5.1               
#>  [29] lifecycle_1.0.3             iterators_1.0.14           
#>  [31] pkgconfig_2.0.3             Matrix_1.6-1.1             
#>  [33] R6_2.5.1                    fastmap_1.1.1              
#>  [35] GenomeInfoDbData_1.2.11     MatrixGenerics_1.14.0      
#>  [37] clue_0.3-65                 digest_0.6.33              
#>  [39] pcaMethods_1.94.0           colorspace_2.1-0           
#>  [41] GGally_2.1.2                reshape_0.8.9              
#>  [43] Hmisc_5.1-1                 GenomicRanges_1.54.0       
#>  [45] labeling_0.4.3              Spectra_1.12.0             
#>  [47] fansi_1.0.5                 httr_1.4.7                 
#>  [49] abind_1.4-5                 compiler_4.3.1             
#>  [51] bit64_4.0.5                 withr_2.5.1                
#>  [53] doParallel_1.0.17           backports_1.4.1            
#>  [55] htmlTable_2.4.1             gplots_3.1.3               
#>  [57] MASS_7.3-60                 MsExperiment_1.4.0         
#>  [59] DelayedArray_0.28.0         gtools_3.9.4               
#>  [61] caTools_1.18.2              tools_4.3.1                
#>  [63] foreign_0.8-85              ape_5.7-1                  
#>  [65] nnet_7.3-19                 glue_1.6.2                 
#>  [67] dbscan_1.1-11               nlme_3.1-163               
#>  [69] QFeatures_1.12.0            grid_4.3.1                 
#>  [71] checkmate_2.2.0             cluster_2.1.4              
#>  [73] generics_0.1.3              gtable_0.3.4               
#>  [75] tzdb_0.4.0                  preprocessCore_1.64.0      
#>  [77] tidyr_1.3.0                 sna_2.7-1                  
#>  [79] data.table_1.14.8           hms_1.1.3                  
#>  [81] MetaboCoreUtils_1.10.0      utf8_1.2.4                 
#>  [83] XVector_0.42.0              stringr_1.5.0              
#>  [85] RANN_2.6.1                  foreach_1.5.2              
#>  [87] pillar_1.9.0                vroom_1.6.4                
#>  [89] limma_3.58.0                robustbase_0.99-0          
#>  [91] splines_4.3.1               dplyr_1.1.3                
#>  [93] lattice_0.22-5              bit_4.0.5                  
#>  [95] survival_3.5-7              tidyselect_1.2.0           
#>  [97] RBGL_1.78.0                 knitr_1.44                 
#>  [99] gridExtra_2.3               IRanges_2.36.0             
#> [101] SummarizedExperiment_1.32.0 xfun_0.40                  
#> [103] statmod_1.5.0               matrixStats_1.0.0          
#> [105] DEoptimR_1.1-3              stringi_1.7.12             
#> [107] statnet.common_4.9.0        lazyeval_0.2.2             
#> [109] yaml_2.3.7                  evaluate_0.22              
#> [111] codetools_0.2-19            archive_1.1.6              
#> [113] MsCoreUtils_1.14.0          tibble_3.2.1               
#> [115] BiocManager_1.30.22         graph_1.80.0               
#> [117] cli_3.6.1                   affyio_1.72.0              
#> [119] rpart_4.1.21                munsell_0.5.0              
#> [121] jquerylib_0.1.4             network_1.18.1             
#> [123] GenomeInfoDb_1.38.0         MassSpecWavelet_1.68.0     
#> [125] coda_0.19-4                 XML_3.99-0.14              
#> [127] parallel_4.3.1              readr_2.1.4                
#> [129] ggplot2_3.4.4               prettyunits_1.2.0          
#> [131] AnnotationFilter_1.26.0     bitops_1.0-7               
#> [133] viridisLite_0.4.2           MsFeatures_1.10.0          
#> [135] scales_1.2.1                affy_1.80.0                
#> [137] ncdf4_1.21                  purrr_1.0.2                
#> [139] crayon_1.5.2                rlang_1.1.1                
#> [141] vsn_3.70.0