Skip to contents

Annotate query LC-MS/MS features in a mass_data object given a reference list.

annotate_ms2() allows for annotation of mass spectrometry features. Similarity between query and reference level 2 spectra are determined via spectral scoring methods. Currently scoring methods "gnps" and "spectral_entropy" are supported. The scoring method is specified by the score_params argument. score_params is a list of parameters for the chosen scoring method. Parameters for "gnps" and "spectral_entropy" can be created with functions modified_cosine_params() and spec_entropy_params(), respectively. If you are using an hmdb reference database, or a database that does not contain a precursormz please ensure that you expand your ppm to account for the difference.

Usage

annotate_ms2(mass_data, reference, scoring_params,
                    ppm, min_score,
                    chemical_min_score,
                    cluster_data = NULL, min_peaks = 0,
                    number_of_threads = 1)

Arguments

mass_data

The object generated from ms2_ms1_compare().

reference

Your reference database generated from the read_msp() function. We currently only support msp files.

scoring_params

Parameters for scoring method to be applied. This can be either modified_cosine_params() or spec_entropy_params().

ppm

Parts per million. MS2 scans with a difference in ppm less than or equal to this value will be scored.

min_score

Similarity score threshold to determine a match for annotation. Comparisons with scores below this value will not be reported.

chemical_min_score

data2

cluster_data

the cluster object that was generated by cluster_data(). Can also remain NULL if you wish to annotate the data without omu information.

min_peaks

the minimum number of peaks that need to be present before you compare the ms2 spectra.

number_of_threads

the number of threads you wish to use for this calculation.

Value

A data.frame with all comparisons with scores above the threshold. Information for the query scan include query_ms1_id (the variable_id for features in expression_data of the mass_data object) "query_ms2_id" (the ms2_spectrum_id in the query object), "query_mz" (the precursor mz for the scan), and "query_rt" (the retention time for the scan). query_mz and query_rt are derived from the ms2 matches data. A column ("ref_idx) is included to report the location for the matching reference molecule in "reference". Scores are reported in the "score" column. query_formula and chemical_similarity are also reported. Annotation information is returned given the information provided in the reference used as input.

a data.frame object containing annotations

Examples

data <-
   import_all_data(peak_table =
                   mums2::mums2_example("botryllus_pt_small.csv"),
                   metadata =
                   mums2::mums2_example("boryillus_metadata.csv"),
                   format = "None")


matched_data <- ms2_ms1_compare(mums2_example("botryllus_v2.gnps.mgf"),
 data, 1, 6)
#> Reading: /home/runner/work/_temp/Library/mums2/extdata/botryllus_v2.gnps.mgf ...
#> 17/349 peaks have an MS2 spectra.
 massbank <- read_msp(mums2_example("MSMS-Neg-Respect.msp"))
#> Reading: /home/runner/work/_temp/Library/mums2/extdata/MSMS-Neg-Respect.msp ...
 annotations <- annotate_ms2(mass_data = matched_data,
   reference = massbank, scoring_params = modified_cosine_params(0.5),
   ppm = 1.6e3,
   min_score =  0.5, chemical_min_score = 0,
   number_of_threads = 2)