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

#### Tobias Depke

#### April 15, 2025

## 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.5.0 RC (2025-04-04 r88126 ucrt)
    #> Platform: x86_64-w64-mingw32/x64
    #> Running under: Windows Server 2022 x64 (build 20348)
    #>
    #> Matrix products: default
    #>   LAPACK version 3.12.1
    #>
    #> locale:
    #> [1] LC_COLLATE=C
    #> [2] LC_CTYPE=English_United States.utf8
    #> [3] LC_MONETARY=English_United States.utf8
    #> [4] LC_NUMERIC=C
    #> [5] LC_TIME=English_United States.utf8
    #>
    #> time zone: America/New_York
    #> tzcode source: internal
    #>
    #> attached base packages:
    #> [1] stats     graphics  grDevices utils     datasets  methods   base
    #>
    #> other attached packages:
    #>  [1] magrittr_2.0.3      metaMSdata_1.43.0   metaMS_1.44.0
    #>  [4] CAMERA_1.64.0       xcms_4.6.0          BiocParallel_1.42.0
    #>  [7] Biobase_2.68.0      BiocGenerics_0.54.0 generics_0.1.3
    #> [10] CluMSIDdata_1.23.0  CluMSID_1.24.0
    #>
    #> loaded via a namespace (and not attached):
    #>   [1] RColorBrewer_1.1-3          rstudioapi_0.17.1
    #>   [3] jsonlite_2.0.0              MultiAssayExperiment_1.34.0
    #>   [5] farver_2.1.2                MALDIquant_1.22.3
    #>   [7] rmarkdown_2.29              fs_1.6.6
    #>   [9] vctrs_0.6.5                 base64enc_0.1-3
    #>  [11] htmltools_0.5.8.1           S4Arrays_1.8.0
    #>  [13] BiocBaseUtils_1.10.0        progress_1.2.3
    #>  [15] SparseArray_1.8.0           Formula_1.2-5
    #>  [17] mzID_1.46.0                 sass_0.4.10
    #>  [19] KernSmooth_2.23-26          bslib_0.9.0
    #>  [21] htmlwidgets_1.6.4           plyr_1.8.9
    #>  [23] impute_1.82.0               plotly_4.10.4
    #>  [25] cachem_1.1.0                igraph_2.1.4
    #>  [27] lifecycle_1.0.4             iterators_1.0.14
    #>  [29] pkgconfig_2.0.3             Matrix_1.7-3
    #>  [31] R6_2.6.1                    fastmap_1.2.0
    #>  [33] GenomeInfoDbData_1.2.14     MatrixGenerics_1.20.0
    #>  [35] clue_0.3-66                 digest_0.6.37
    #>  [37] pcaMethods_2.0.0            colorspace_2.1-1
    #>  [39] GGally_2.2.1                S4Vectors_0.46.0
    #>  [41] Hmisc_5.2-3                 GenomicRanges_1.60.0
    #>  [43] labeling_0.4.3              Spectra_1.18.0
    #>  [45] httr_1.4.7                  abind_1.4-8
    #>  [47] compiler_4.5.0              bit64_4.6.0-1
    #>  [49] withr_3.0.2                 doParallel_1.0.17
    #>  [51] backports_1.5.0             htmlTable_2.4.3
    #>  [53] DBI_1.2.3                   ggstats_0.9.0
    #>  [55] gplots_3.2.0                MASS_7.3-65
    #>  [57] MsExperiment_1.10.0         DelayedArray_0.34.0
    #>  [59] gtools_3.9.5                caTools_1.18.3
    #>  [61] mzR_2.42.0                  tools_4.5.0
    #>  [63] foreign_0.8-90              PSMatch_1.12.0
    #>  [65] ape_5.8-1                   nnet_7.3-20
    #>  [67] glue_1.8.0                  dbscan_1.2.2
    #>  [69] nlme_3.1-168                QFeatures_1.18.0
    #>  [71] grid_4.5.0                  checkmate_2.3.2
    #>  [73] cluster_2.1.8.1             reshape2_1.4.4
    #>  [75] snow_0.4-4                  gtable_0.3.6
    #>  [77] tzdb_0.5.0                  preprocessCore_1.70.0
    #>  [79] tidyr_1.3.1                 sna_2.8
    #>  [81] data.table_1.17.0           hms_1.1.3
    #>  [83] MetaboCoreUtils_1.16.0      XVector_0.48.0
    #>  [85] foreach_1.5.2               pillar_1.10.2
    #>  [87] stringr_1.5.1               vroom_1.6.5
    #>  [89] limma_3.64.0                robustbase_0.99-4-1
    #>  [91] dplyr_1.1.4                 lattice_0.22-7
    #>  [93] bit_4.6.0                   tidyselect_1.2.1
    #>  [95] RBGL_1.84.0                 knitr_1.50
    #>  [97] gridExtra_2.3               IRanges_2.42.0
    #>  [99] ProtGenerics_1.40.0         SummarizedExperiment_1.38.0
    #> [101] stats4_4.5.0                xfun_0.52
    #> [103] statmod_1.5.0               MSnbase_2.34.0
    #> [105] matrixStats_1.5.0           DEoptimR_1.1-3-1
    #> [107] stringi_1.8.7               UCSC.utils_1.4.0
    #> [109] statnet.common_4.11.0       lazyeval_0.2.2
    #> [111] yaml_2.3.10                 evaluate_1.0.3
    #> [113] codetools_0.2-20            archive_1.1.12
    #> [115] MsCoreUtils_1.20.0          tibble_3.2.1
    #> [117] BiocManager_1.30.25         graph_1.86.0
    #> [119] cli_3.6.4                   affyio_1.78.0
    #> [121] rpart_4.1.24                munsell_0.5.1
    #> [123] jquerylib_0.1.4             network_1.19.0
    #> [125] Rcpp_1.0.14                 GenomeInfoDb_1.44.0
    #> [127] MassSpecWavelet_1.74.0      coda_0.19-4.1
    #> [129] XML_3.99-0.18               parallel_4.5.0
    #> [131] readr_2.1.5                 ggplot2_3.5.2
    #> [133] prettyunits_1.2.0           AnnotationFilter_1.32.0
    #> [135] bitops_1.0-9                viridisLite_0.4.2
    #> [137] MsFeatures_1.16.0           scales_1.3.0
    #> [139] affy_1.86.0                 ncdf4_1.24
    #> [141] purrr_1.0.4                 crayon_1.5.3
    #> [143] rlang_1.1.6                 vsn_3.76.0