bittremieux / falcon

Large-scale tandem mass spectrum clustering using fast nearest neighbor searching.
BSD 3-Clause "New" or "Revised" License
24 stars 7 forks source link
clustering mass-spectrometry nearest-neighbor-search

falcon

falcon

For more information:

The falcon spectrum clustering tool uses advanced algorithmic techniques for highly efficient processing of millions of MS/MS spectra. First, high-resolution spectra are binned and converted to low-dimensional vectors using feature hashing. Next, the spectrum vectors are used to construct nearest neighbor indexes for fast similarity searching. The nearest neighbor indexes are used to efficiently compute a sparse pairwise distance matrix without having to exhaustively compare all spectra to each other. Finally, density-based clustering is performed to group similar spectra into clusters.

The software is available as open-source under the BSD license.

If you use falcon in your work, please cite the following publication:

Installation

falcon requires Python 3.8+ and is available on the Linux and OSX platforms.

You can easily install falcon with pip:

pip install falcon-ms spectrum-utils==0.3.5

Running falcon

falcon can be run from the command line, with settings specified as command-line arguments or set in an INI config file. falcon takes peak files (in the mzML, mzXML, or MGF format) as input and exports the clustering result as a comma-separated file with each MS/MS spectrum and its cluster label on a single line. Representative spectra for each cluster can optionally be exported to an MGF file.

Example falcon run with some relevant command-line arguments:

falcon peak/*.mzml falcon --export_representatives --precursor_tol 20 ppm --fragment_tol 0.05 --eps 0.10

This will cluster all MS/MS spectra in mzML files in the peak directory with the specified settings and write (i) the cluster assignments to the falcon.csv file, and (ii) the cluster representatives to the falcon.mgf file.

Important settings

Here we provide information on the most important settings that influence the falcon clustering performance. All settings have sensible default values which should give good results for a wide variety of datasets.

For detailed information on all available settings, run falcon -h or falcon --help.

Spectrum comparison

Clustering

Spectrum preprocessing

There are several options to configure spectrum preprocessing prior to the clustering. The default settings are intended for clustering bottom-up proteomics data. When analyzing metabolomics or top-down data, these settings likely need to be adjusted accordingly.

Nearest neighbor indexing (see below)

The settings for nearest neighbor indexing can be modified to tune clustering time versus accuracy. Changing these settings is only recommended for advanced users.

How does it work?

falcon spectrum clustering

  1. High-resolution MS/MS spectra are converted to low-dimensional vectors using feature hashing. First, spectra are converted to sparse vectors using small mass bins to tightly capture their fragment masses. Next, the sparse, high-dimensional, vectors are hashed to lower-dimensional vectors by using a hash function (the non-cryptographic MurmurHash3 algorithm) to map the mass bins separately to a small number of hash bins. This feature hashing conserves the cosine similarity between hashed vectors and can be used to approximate the similarity between the original spectra.
  2. Vectors are split into buckets based on the precursor m/z of the corresponding spectra to construct nearest neighbor indexes for highly efficient spectrum comparison. The spectrum vectors in each bucket are partitioned into data subspaces to create a Voronoi diagram, and all vectors are assigned to their nearest representative vector in an inverted index.
  3. A sparse pairwise distance matrix is computed by retrieving similarities to neighboring spectra using the nearest neighbor indexes. The accuracy and speed of similarity searching is governed by the number of neighboring cells to explore during searching: exploring more cells during searching decreases the chance of missing a nearest neighbor in the high-dimensional space, at the expense of a longer searching time.
  4. Density-based clustering using the pairwise distance matrix is performed to find spectrum clusters. The DBSCAN algorithm is used to find spectra that are close to each other and that form a dense data subspace, and group them into clusters.

Contact

For more information you can visit the official code website or send an email to wbittremieux@health.ucsd.edu.