merge_ms2.Rd
Merge MS2 data with MS1 features
merge_ms2(features, ms2_data, mz_window = 1, rt_window = 2, output = c("all", "best_match"))
features | two column dataframe, m/z and RT |
---|---|
ms2_data | MS2 data frame. Should be the result of |
mz_window | Quadropole isolation window (Daltons). |
rt_window | Retention time window. |
output | Whether to return all possible matches for each feature |
A merged data frame containing both MS1 features with their corresponding MS2 data.
ms2_file <- system.file("extdata", "ms2file.ms2", package = "lipID") features_file <- system.file("extdata", "features.csv", package = "lipID") features <- readr::read_csv(features_file)#>#> #> #> #> #> #> #> #> #> #>head(features)#> # A tibble: 6 x 8 #> mz rt Sample1 Sample2 Sample3 Sample4 Sample5 Sample6 #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 623. 36.6 11538991 31417167 1721597. 26270387 240068. 146196506 #> 2 649. 37.1 3026293. 4228799 2539904 4811817 34383605 1173481 #> 3 651. 38.1 2715640 71834. 1390301 4208460 18656983 15282626 #> 4 679. 26.9 78211. 942846. 402485. 11245291 2873644. 2362536 #> 5 691. 30.4 3210293 1832204 910287. 29621351 753207. 2049241 #> 6 691. 30.6 7495133. 3902430 8532539. 9627881 27338627 2198889#>#>annotated_features <- merge_ms2(features, confirmed_molecules)#>#>head(annotated_features)#> # A tibble: 6 x 31 #> mz rt name ms2_file precursor ms2_rt best_match partial_match confirmed #> <dbl> <dbl> <chr> <fct> <dbl> <dbl> <lgl> <dbl> <lgl> #> 1 789. 34.3 PC(3… ms2file 789. 34.2 TRUE 1 TRUE #> 2 747. 33.6 Plas… ms2file 747. 33.5 TRUE 1 TRUE #> 3 747. 33.6 Plas… ms2file 747. 33.5 FALSE 1 TRUE #> 4 783. 30.7 PC(1… ms2file 783. 31.1 TRUE 1 TRUE #> 5 783. 30.3 PC(1… ms2file 783. 31.1 TRUE 1 TRUE #> 6 811. 32.7 PC(1… ms2file 811. 33.2 TRUE 1 TRUE #> # … with 22 more variables: ions_matched <chr>, fragments_intensity <dbl>, #> # Sample1 <dbl>, Sample2 <dbl>, Sample3 <dbl>, Sample4 <dbl>, Sample5 <dbl>, #> # Sample6 <dbl>, nearest_ms2 <lgl>, file <chr>, class_name <chr>, #> # sum_composition <chr>, odd_chain <lgl>, modifs <chr>, total_cl <dbl>, #> # total_cs <dbl>, n_and <int>, n_or <int>, n_and_true <int>, n_or_true <int>, #> # and_cols <lgl>, or_cols <lgl>