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 = detectCores())

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. Defaults to the number of threads on your computer.

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"),
                   meta_data =
                   mums2::mums2_example("meta_data_boryillus.csv"),
                   format = "None")
#> If peak table has corrupted compound names they will be converted to
#>       utf-8 and if there are any commas, they will be converted to periods(.).

filtered_data <- data |>
   filter_peak_table(filter_mispicked_ions_params()) |>
   filter_peak_table(filter_cv_params(cv_threshold = 0.2)) |>
   filter_peak_table(filter_group_params(group_threshold = 0.1,
                                             "Blanks")) |>
   filter_peak_table(filter_insource_ions_params())
#>  Checking 1500 peaks for mispicked peaks.
#>  Argument merge_peaks is: TRUE. Merging mispicked peaks with method sum.
#>  50 ions failed the mispicked filter, 1450 ions remain.
#>  Parsing 1450 peaks for replicability across technical replicates.
#>  329 ions failed the cv_filter filter, 1121 ions remain.
#>  Parsing 1121 peaks based on the sample group: Blanks.
#>  Argument remove_ions is: TRUE.Removing peaks from Blanks.
#>  342 ions failed the Blanks filter, 779 ions remain.
#>  Parsing 779 peaks for insource ions.
#>  55 ions failed the insource filter, 724 ions remain.


matched_data <- ms2_ms1_compare(mums2_example("botryllus_v2.gnps.mgf"),
 filtered_data, 10, 6)
#> [1] "Reading: /home/runner/work/_temp/Library/mums2/extdata/botryllus_v2.gnps.mgf ..."
#> Computing                                                    | 0%  ETA: -...
Computing  | 2%  ETA: ...
Computing ■■                                                 | 4%  ETA: ...
Computing ■■■                                                | 6%  ETA: ...
Computing ■■■■                                               | 8%  ETA: ...
Computing ■■■■■                                              | 10%  ETA: ...
Computing ■■■■■■                                             | 12%  ETA: ...
Computing ■■■■■■■                                            | 14%  ETA: ...
Computing ■■■■■■■■                                           | 16%  ETA: ...
Computing ■■■■■■■■■                                          | 18%  ETA: ...
Computing ■■■■■■■■■■                                         | 20%  ETA: ...
Computing ■■■■■■■■■■■                                        | 22%  ETA: ...
Computing ■■■■■■■■■■■■                                       | 24%  ETA: ...
Computing ■■■■■■■■■■■■■                                      | 26%  ETA: ...
Computing ■■■■■■■■■■■■■■                                     | 28%  ETA: ...
Computing ■■■■■■■■■■■■■■■                                    | 30%  ETA: ...
Computing ■■■■■■■■■■■■■■■■                                   | 32%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■                                  | 34%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■                                 | 36%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■                                | 38%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■                               | 40%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■                              | 42%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■                             | 44%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■                            | 46%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■                           | 48%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■                          | 50%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■                         | 52%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■                        | 54%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■                       | 56%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                      | 58%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                     | 60%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                    | 62%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                   | 64%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                  | 66%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                 | 68%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                | 70%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■               | 72%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■              | 74%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■             | 76%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■            | 78%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■           | 80%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■          | 82%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■         | 84%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■        | 86%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■       | 88%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■      | 90%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■     | 92%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    | 94%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■   | 96%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  | 98%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ | 100%  ETA: ...
#> [1] "185/724 peaks have an MS2 spectra."
 massbank <- read_msp(mums2_example("MSMS-Neg-Respect.msp"))
#> [1] "Reading: /home/runner/work/_temp/Library/mums2/extdata/MSMS-Neg-Respect.msp ..."
#> Computing                                                    | 0%  ETA: -...
Computing  | 2%  ETA: ...
Computing ■■                                                 | 4%  ETA: ...
Computing ■■■                                                | 6%  ETA: ...
Computing ■■■■                                               | 8%  ETA: ...
Computing ■■■■■                                              | 10%  ETA: ...
Computing ■■■■■■                                             | 12%  ETA: ...
Computing ■■■■■■■                                            | 14%  ETA: ...
Computing ■■■■■■■■                                           | 16%  ETA: ...
Computing ■■■■■■■■■                                          | 18%  ETA: ...
Computing ■■■■■■■■■■                                         | 20%  ETA: ...
Computing ■■■■■■■■■■■                                        | 22%  ETA: ...
Computing ■■■■■■■■■■■■                                       | 24%  ETA: ...
Computing ■■■■■■■■■■■■■                                      | 26%  ETA: ...
Computing ■■■■■■■■■■■■■■                                     | 28%  ETA: ...
Computing ■■■■■■■■■■■■■■■                                    | 30%  ETA: ...
Computing ■■■■■■■■■■■■■■■■                                   | 32%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■                                  | 34%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■                                 | 36%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■                                | 38%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■                               | 40%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■                              | 42%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■                             | 44%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■                            | 46%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■                           | 48%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■                          | 50%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■                         | 52%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■                        | 54%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■                       | 56%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                      | 58%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                     | 60%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                    | 62%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                   | 64%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                  | 66%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                 | 68%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                | 70%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■               | 72%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■              | 74%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■             | 76%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■            | 78%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■           | 80%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■          | 82%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■         | 84%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■        | 86%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■       | 88%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■      | 90%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■     | 92%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    | 94%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ | 100%  ETA: ...
 annotations <- annotate_ms2(mass_data = matched_data,
   reference = massbank, scoring_params = modified_cosine_params(0.5),
   ppm = 25,
   min_score =  0.5, chemical_min_score = 0)
#> Computing                                                    | 0%  ETA: -...
Computing  | 2%  ETA: ...
Computing ■■                                                 | 4%  ETA: ...
Computing ■■■                                                | 6%  ETA: ...
Computing ■■■■                                               | 8%  ETA: ...
Computing ■■■■■                                              | 10%  ETA: ...
Computing ■■■■■■                                             | 12%  ETA: ...
Computing ■■■■■■■                                            | 14%  ETA: ...
Computing ■■■■■■■■                                           | 16%  ETA: ...
Computing ■■■■■■■■■                                          | 18%  ETA: ...
Computing ■■■■■■■■■■                                         | 20%  ETA: ...
Computing ■■■■■■■■■■■                                        | 22%  ETA: ...
Computing ■■■■■■■■■■■■                                       | 24%  ETA: ...
Computing ■■■■■■■■■■■■■                                      | 26%  ETA: ...
Computing ■■■■■■■■■■■■■■                                     | 28%  ETA: ...
Computing ■■■■■■■■■■■■■■■                                    | 30%  ETA: ...
Computing ■■■■■■■■■■■■■■■■                                   | 32%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■                                  | 34%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■                                 | 36%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■                                | 38%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■                               | 40%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■                              | 42%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■                             | 44%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■                            | 46%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■                           | 48%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■                          | 50%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■                         | 52%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■                        | 54%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■                       | 56%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                      | 58%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                     | 60%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                    | 62%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                   | 64%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                  | 66%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                 | 68%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■                | 70%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■               | 72%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■              | 74%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■             | 76%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■            | 78%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■           | 80%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■          | 82%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■         | 84%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■        | 86%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■       | 88%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■      | 90%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■     | 92%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    | 94%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■   | 96%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  | 98%  ETA: ...
Computing ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ | 100%  ETA: ...