MS2KOSMOS user guide

AI Molecule Explorer (AIMe) is a multi-agent neuro-symbolic AI framework for predicting, interpreting, exploring, and mapping small-molecule MS data. AIMe enables query-driven molecular contextualization across the Known Organic Small-Molecule Space (KOSMOS). AIMe integrates three modular agents: DeepMS2Reasoner, which predicts MS2 spectra and fragmentation pathways; MS2KOSMOSGenerator, which constructs and indexes MS2KOSMOS, a searchable database of predicted MS2 spectra for known small organic molecules; and MS2KOSMOSMapper, which maps query spectra onto MS2KOSMOS to support molecular search, comparison, and visualization.

This is the guide for the graphical user interfaces for searching spectra in MS2KOSMOS and visualizing query results. A results file contains a set of molecules from PubChem deemed similar to a query MS2 spectrum, along with mutual similarities, or set of related spectra based on a predicted fragmentation process, along with predicted spectra and fragmentation DAGs for each. For more details, see the accompanying paper.

Search interface

Auto-fill from file

Use this when a supported spectrum file (.MGF or .MSP) is available to populate many of the metadata fields, as well as the spectra. Files can be downloaded from Mass Bank of North America, GNPS, etc.

Metadata

Provide the observed precursor ion mass-to-charge ratio (m/z), and if available, the molecular formula for the precursor ion (not the neutral molecule). If only the formula is available, it will be used to compute m/z.

The Experiment Name field is for a human-readable label, and the InChIKey can be included as an identifier if known.

Spectra data

This section provides the spectra to use in the search. Use the Add Spectrum button to provide multiple spectra at different collision energies.

Two Ion Modes are supported: [M+H]+ (positive mode protonated ions) or [M-H]- (negative mode deprotonated ions). Enter an integer Collision Energy for each spectrum, in either NCE or eV.

The Peak List should include one m/z–intensity pair per line.

Candidates

Select the Validate Candidates Only checkbox to propose your own candidate molecules, even if absent from MS2KOSMOS. In this mode, enter the structures in the Candidate SMILES text box (plain SMILES strings only), one per line. The SMILES string should be the neutral/unionized form unless the compound is constitutively charged. DeepMS2Reasoner will predict their spectra using the conditions specified with the experimental spectra above, and rank then by predicted-spectrum validation. Use the Validate Candidates button to run the validation (MS2KOSMOS search and its options are disabled in this mode).

Search options

The Top K value determines the maximum number of candidates to return. Two Search Modes are available: Full Search considers all molecules in MS2KOSMOS, while Identity Search constrains the search based on the molecular formula, or based on the precursor m/z using the specified precursor PPM (relative) tolerance and precursor absolute tolerance (in Da).

The Spectrum Source option determines whether to use DeepMS2Reasoner to predict spectra using the conditions specified with the experimental spectra above. With either setting, the selected candidates are based on similarity to the precomputed spectra at the nearest collision energy available in the MS2KOSMOS database (NCE 20%, 30%, 50%, or 80%). Precomputed mode returns these precomputed spectra directly (without detailed fragmentation information). Predicted mode predicts the candidate spectra using the specific collision energies and other conditions given, and reranks them based on similarity to the query spectra (this mode includes detailed fragmentation information). It is recommended to use precomputed mode to find appropriate values for the other search options, then use predicted mode for more refined information about the returned candidates.

The Precursor PPM Tolerance and Precursor Abs. Tolerance values are the m/z tolerances (relative and absolute, respectively) for the identity search mode. The Fragment PPM Tolerance and Fragment Abs. Tolerance are the tolerances (relative and absolute, respectively) for matching fragment peaks to spectra, for both preprocessing and scoring. The Mapped Peak Cap value restricts the search and scoring to only consider the top N highest intensity peaks. The Min. Relative Intensity value can be used to filter out small peaks; the range is between 0 and 1, where 0 retains all processed peaks.

Use the Search MS2KOSMOS (Precomputed Spectra) button (in precomputed mode) or Predict Spectra for Top MS2KOSMOS Candidates button (in predicted mode) to perform the search and prediction.

Status and timing summary

While the search or validation is running, the step-by-step status is shown, along with timing information and operation counts.

Preprocessing impact

Once preprocessing is complete for a search, the summary shows the number of peaks in the input spectrum, as well as the number filtered out due to the selected tolerances an other settings, and the cosine similarity between the original and processed spectrum. Below that, the mirror plot compares the original and processed spectra. Various statistis about the preprocessing, as well information about the largest filtered peaks, are shown as well.

Candidate list summary

In predicted mode, once the prediction is complete, the Model Inference Results table lists the retrieved candidates ranked based on the cosine similarity of the input to the predicted spectra at the specified collision energy. The original ranking (based on the precomputed spectra), PubChem CID and link, m/z, formula, and SMILES are also shown. Hover over an entry to see a depiction of the structure.

Once the search is complete in either mode, the Precomputed Vector Results table shows the candidate list ranked based on the precomputed spectra, along with the PubChem CID and link, m/z, formula, and SMILES are also shown. Hover over an entry to see a depiction of the structure.

Download and visualize results

Use the Download JSON button to save the results for viewing later, or use the Open Visualizer button to view the results in a new window.

Visualization interface

Loading a data file

To load a local data file, such as one saved from a previous search, use the Browse button at the top of the page. Data files are in JSON format, structured as provided by the search page.

There are also example files provided, which can be loaded using the menu to the right of the browse button.

A data file hosted on a website can also be included by including its url as a query string, as is used for the visualizer button on the search page.

Selecting a predicted spectrum

The left sidebar contains 2 or 3 metadata panels, reflecting the 3 levels in the data hierarchy. If there are multiple distinct entries at a particular level in the data file, they are shown as rows in the table, which can be clicked to change the selection; otherwise, each row in the table corresponds to a metadata value. As space is limited, you can scroll the panel horizontally, or see the full information in a tooltip by hovering over the entry (hovering over a molecular rendering will show only a larger version of that image).

The bottom panel is the first level, corresponding to the molecule being investigated or a query consisting of a set of related spectra; it is only shown if the data file contains multiple sets of spectra or queries. Fields include the neutral formula, adduct, mass, and retention time.

The middle panel is the second level, the experimental conditions for MS2 spectrum collection. Unique entries are generally determined by the collision energy, but other details are also shown. Only the spectra corresponding the entry selected in the bottom panel is shown.

The top panel contains an entry for each query result molecule for the selected entry in each of the other panels, including information about the quality of the match (similarity between the measured and predicted spectra). Fields include a rendering of the molecular structure, molecular formula, mass, SMILES string, InChiKey, and PubChem CID, in addition to the similarity measures. This panel is the same height as the mirror plot of the spectra to its right, and can be scrolled if there are more entries than fit in the allotted space.

The selection at each level is generally remembered when returning from other selections at parent levels of the hierarchy, however, when selecting a prediction within a query with grouped experimental spectra, the selction will be shared across the whole query.

Mirror plot

The middle column provides more information about the predicted molecules and spectra based on the user's selections. At the top is a mirror plot comparing the experimental and predcited MS2 spectra. The spectral intensities in AIMe results files are scaled to a max value of 999 (arbitrary units) as a convention. A rendering of the molecule is shown at the top left of the panel. Data values are shown in a tooltip on hover.

Hovering or clicking on a peak in the predicted spectrum (or on a peak in the experimental spectrum that is matched explicitly by the prediction) brings up additional information about the fragmentation that produced that predicted peak in the panels described below. The currently selected peak (by click) is indicated with a yellow x marker. Selecting a peak in the mirror plot will cause the corresponding peak to be selected in all other predicted spectra within the same query.

Selected peak fragments

The two columns on the right provide information about the selected (most recently clicked) peak in the mirror plot (left), and the same for the currently hovered peak (far right). In each of those columns, there's a card with details about the peak itself at the top, followed by a card with information about each fragment that contributed to that peak.

The fragment renderings include additional information beyond the atom and bond structure (if provided by AIMe). If AIMe predicts further fragmentation, the probability of breaking each bond (above threshold) is shown adjacent to the bond; the probability of the fragment remaining intact is shown with a stop sign at the top right. If the possible next fragmentation steps include an excision, this is shown as a green dotted line between the atoms that would be joined by a synthetic bond, along with the probability also in green. As the fragments can include bond multiplicity at unspecified locations, a correction to hydrogen count with respect to the rendering is shown (if needed) at the bottom right, along with a correction for ionization.

Fragmentation DAG

If provided in the data file, the fragmentation DAG that was generated by the in silico fragmentation process, from which the currently selected predicted MS2 spectrum is derived, is shown in the second panel of the middle column (shared with the candidate network if both are present). Each node (circle) corresponds to either the precursor molecule or one of the fragments. Node labels are the mass (rounded to an integer), and sizes are proportional to the probability (spectral intensity). Each edge represents a parent-child relationship between the two endpoint fragments.

As this is a DAG, there can be multiple fragmentation paths leading to each substantially equivalent fragment, and these can be different lengths. For many layout options, the vertical axis represents the length of the longest path to reach a given fragment (or the maximum depth of that node). The color of each node represents the length of the shortest path to reach that fragment (or the minimum depth of that node); edge colors are a gradient between the colors of the endpoints.

The fragment probability threshold slider can be used show or hide low-probability fragments. Filtered out nodes (and the connected edges) are collapsed into a single edge to any remaining children.

You can hover over a node to see a tooltip with additional information from the Fragments table: a rendering of its structure, structure highlighed as a possible substructure of the precursor (if this relationship is provided in the data file), m/z, fragment probability (proportional to its contribution to predicted spectral intensity), molecular formula, complementary molecular formula, and SMILES. Hovering over an edge provides a tooltip with the same information about the nodes that are the edge's endpoints.

There are also highlights that provide information about the peak hovered or selected (clicked) in the mirror plot. The nodes corresponding to any fragments that explain the selected peak (with m/z values within tolerance) are shown with a foreground highlight. The nodes and edges along any fragmentation path from the precursor to those selected nodes are also shown with a background highlight.

The menus at the top of the panel provide multiple layout options and settings with different types of constraints on the relative positioning of the nodes. The bands button toggles the background shading of alternating depth levels of the DAG for layouts grouped by depth. The controls on the left can be used to zoom and pan, the overlay at the bottom right shows the whole DAG and can be clicked to navigate quickly when zoomed in, and there's an aspect ratio slider as the top as well.

If candidate network information is present in the data file, there's a button at the top left of the panel to switch to that mode.

Candidate network

If provided in the data file, all candidates for the current query will be shown in a network visualization in the alternate view of the second panel of the middle column (shared with the fragmentation DAG if both are present).

In this visualization, each blue node represents a candidate, with a size that represents the similarity with the query (relative to the range across the current candidates only). The red node represents the query spectrum. The currently selected candidate is foreground highlighted in purple.

The solid edges represent similarities among candidates, and dotted edges are similarities to the query. Edge color also represents the pairwise similarity. The Sim. threshold slider filters edges with similarities below the given value, in order to find the most relevant edges.

The node positions give some indication of the candidate similarities, using a force-directed layout based on the similarities assigned to the edges.

Finally, candidates that contain a peak that matches the one currently selected in the mirror plot are highlighted in blue if they match based inclusion of a fragment with the same structure (SMILES), or in purple if they match based inclusion of a fragment with the same molecular formula only.

Hovering over a node or edge shows a tooltip with additional information about the corresponding candidate, pair of candidates, or query. Clicking a node selects the corresponding prediction (as if it was clicked in the table panel).

If fragmentation DAG information is present in the data file, there's a button at the top left of the panel to switch to that mode.

Fragments table

Each row of this table in the bottom panel of the center column represents one of the fragment types that was generated by the in silico fragmentation process from which the currently selected predicted MS2 spectrum is derived. Columns include a rendering of the fragment's structure (same as shown to the right of the mirror plot), structure highlighed as a possible substructure of the precursor (if this relationship is provided in the data file), m/z, fragment probability (proportional to its contribution to predicted spectral intensity), molecular formula, complementary molecular formula, and SMILES (same information as shown when hovering on a node of the fragmentation DAG).

The substructure rendering is based on the precursor structure, and rendered in the same orientation, etc. It shows the atoms and bonds that the fragment includes from the precursor (based on one possible fragmentation path) highlighted in purple. If the fragment includes a synthetic bond from an excision (or multiple such bonds), the two bonds broken by each excision, and connecting atom(s) are highlighted in green (again, for the same fragmentation path). Atoms and bonds from the neutral loss are left without highlight.

The table can be sorted on different fields by clicking the corresponding heading. If the panel is not wide enough to show all the content, it can be scrolled horizontally, or a tooltip will be shown with the whole record when hovering over a row (hovering over a molecular rendering will show only a larger version of that image).