Add a custom library for matching

add_lib(file, class_name = NULL, and_cols = "all", or_cols = "rest",
  mode = c("Pos", "Neg"), adduct = "[M+H]+", dda = TRUE,
  aif = TRUE)

Arguments

file

CSV file or a data frame, with lipid names as first column, and precursor M/Z in second column and a column for each potential fragment.

class_name

Full name of the lipid class. Defaults to basename of the input file

and_cols

Character or numeric vector for Columns containing all necessary fragments for ID. Defaults to 'all', i.e. all fragments must be observed in data.

or_cols

Character or numeric vector for Columns containing fragments where at least one fragment must be observed for ID. Defaults to 'rest', i.e. all fragments not included in and_cols. Set argument to FALSE to have no or_cols.

mode

Whether this library is for 'Pos' or 'Neg' mode. Default is 'Pos'.

adduct

Adduct of molecules in the library. Default is '[M+H]+'

dda

Whether this library is suitable for DDA data.

aif

Whether this library is suitable for AIF data.

Value

A tibble with a single row containing the library information and data. The created library is also added to the full list of available libraries.

Examples

csv_file <- system.file("extdata", "PC_H.csv", package = "lipID") lib_data <- readr::read_csv(csv_file)
#> Parsed with column specification: #> cols( #> PC = col_character(), #> `[M+H]+` = col_double(), #> `MH-PC` = col_double(), #> `MH-tail1&TrimethylAmine` = col_double(), #> `MH-tail2&TrimethylAmine` = col_double(), #> `MH-Tail1` = col_double(), #> `MH-Tail2` = col_double(), #> LPC_T1_H = col_double(), #> LPC_T2_H = col_double(), #> `RCOO+58_T1` = col_double(), #> `RCOO+58_T2` = col_double(), #> `PC Head` = col_double() #> )
head(lib_data)
#> # A tibble: 6 x 12 #> PC `[M+H]+` `MH-PC` `MH-tail1&Trime… `MH-tail2&Trime… `MH-Tail1` `MH-Tail2` #> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 PC(1… 735. 552. 419. 419. 478. 478. #> 2 PC(1… 733. 549. 417. 419. 476. 478. #> 3 PC(1… 763. 580. 447. 419. 506. 478. #> 4 PC(1… 761. 578. 445. 419. 504. 478. #> 5 PC(1… 759. 576. 443. 419. 502. 478. #> 6 PC(1… 791. 608. 475. 419. 534. 478. #> # … with 5 more variables: LPC_T1_H <dbl>, LPC_T2_H <dbl>, `RCOO+58_T1` <dbl>, #> # `RCOO+58_T2` <dbl>, `PC Head` <dbl>
amended_libs <- add_lib( csv_file, class_name = 'MyPhosphatidylCholine', and_cols = c(2, 12), or_cols = c(8, 9), mode = 'Pos', adduct = '[M+H]+', dda = TRUE, aif = TRUE )
#> Parsed with column specification: #> cols( #> PC = col_character(), #> `[M+H]+` = col_double(), #> `MH-PC` = col_double(), #> `MH-tail1&TrimethylAmine` = col_double(), #> `MH-tail2&TrimethylAmine` = col_double(), #> `MH-Tail1` = col_double(), #> `MH-Tail2` = col_double(), #> LPC_T1_H = col_double(), #> LPC_T2_H = col_double(), #> `RCOO+58_T1` = col_double(), #> `RCOO+58_T2` = col_double(), #> `PC Head` = col_double() #> )
amended_libs
#> # A tibble: 219 x 13 #> `basename(file)` and_cols or_cols dda aif class_only mode adduct #> <chr> <list> <list> <lgl> <lgl> <lgl> <chr> <chr> #> 1 PC_H.csv <chr [2… <chr [… TRUE TRUE FALSE Pos [M+H]+ #> 2 <NA> <chr [1… <chr [… TRUE FALSE FALSE Neg [M-H]- #> 3 <NA> <chr [1… <chr [… TRUE FALSE FALSE Neg [M-H]- #> 4 <NA> <chr [3… <chr [… TRUE FALSE FALSE Neg [M-H]- #> 5 <NA> <chr [4… <chr [… TRUE FALSE FALSE Neg [M-H]- #> 6 <NA> <chr [2… <chr [… TRUE TRUE FALSE Pos [M+H]+ #> 7 <NA> <chr [1… <chr [… TRUE TRUE FALSE Neg [M-H]- #> 8 <NA> <chr [2… <chr [… TRUE TRUE FALSE Neg [M-H]- #> 9 <NA> <chr [1… <chr [… TRUE TRUE FALSE Neg [M-H]- #> 10 <NA> <chr [2… <chr [… TRUE TRUE FALSE Pos [M+NH… #> # … with 209 more rows, and 5 more variables: class_name <chr>, classkmd <dbl>, #> # ions <named list>, user_defined <lgl>, file <chr>
# Get only the added library amended_libs %>% dplyr::filter(user_defined)
#> # A tibble: 1 x 13 #> `basename(file)` and_cols or_cols dda aif class_only mode adduct #> <chr> <list> <list> <lgl> <lgl> <lgl> <chr> <chr> #> 1 PC_H.csv <chr [2… <chr [… TRUE TRUE FALSE Pos [M+H]+ #> # … with 5 more variables: class_name <chr>, classkmd <dbl>, ions <named list>, #> # user_defined <lgl>, file <chr>
# Get built-in libraries as well as added ones for # speific polarity / acquisition mode. amended_libs %>% dplyr::filter(mode == 'Pos', dda) # Pos DDA libs
#> # A tibble: 84 x 13 #> `basename(file)` and_cols or_cols dda aif class_only mode adduct #> <chr> <list> <list> <lgl> <lgl> <lgl> <chr> <chr> #> 1 PC_H.csv <chr [2… <chr [… TRUE TRUE FALSE Pos [M+H]+ #> 2 <NA> <chr [2… <chr [… TRUE TRUE FALSE Pos [M+H]+ #> 3 <NA> <chr [2… <chr [… TRUE TRUE FALSE Pos [M+NH… #> 4 <NA> <chr [2… <chr [… TRUE FALSE FALSE Pos [M+H]+ #> 5 <NA> <chr [4… <chr [… TRUE TRUE FALSE Pos [M+3N… #> 6 <NA> <chr [2… <chr [… TRUE TRUE FALSE Pos [M+NH… #> 7 <NA> <chr [1… <chr [… TRUE TRUE FALSE Pos [M+NH… #> 8 <NA> <chr [2… <chr [… TRUE TRUE FALSE Pos [M+NH… #> 9 <NA> <chr [1… <chr [… TRUE FALSE FALSE Pos [M+NH… #> 10 <NA> <chr [1… <chr [… TRUE FALSE TRUE Pos [M+NH… #> # … with 74 more rows, and 5 more variables: class_name <chr>, classkmd <dbl>, #> # ions <named list>, user_defined <lgl>, file <chr>
amended_libs %>% dplyr::filter(mode == 'Neg', aif) # Neg AIF libs
#> # A tibble: 75 x 13 #> `basename(file)` and_cols or_cols dda aif class_only mode adduct #> <chr> <list> <list> <lgl> <lgl> <lgl> <chr> <chr> #> 1 <NA> <chr [1… <chr [… TRUE TRUE FALSE Neg [M-H]- #> 2 <NA> <chr [2… <chr [… TRUE TRUE FALSE Neg [M-H]- #> 3 <NA> <chr [1… <chr [… TRUE TRUE FALSE Neg [M-H]- #> 4 <NA> <chr [4… <chr [… TRUE TRUE FALSE Neg [M-2H… #> 5 <NA> <chr [4… <chr [… TRUE TRUE FALSE Neg [M-H]- #> 6 <NA> <chr [2… <chr [… TRUE TRUE TRUE Neg [M-H]- #> 7 <NA> <chr [2… <chr [… TRUE TRUE FALSE Neg [M-H]- #> 8 <NA> <chr [3… <chr [… TRUE TRUE FALSE Neg [M-H]- #> 9 <NA> <chr [1… <chr [… FALSE TRUE FALSE Neg [M+C2… #> 10 <NA> <chr [1… <chr [… TRUE TRUE FALSE Neg [M-H]- #> # … with 65 more rows, and 5 more variables: class_name <chr>, classkmd <dbl>, #> # ions <named list>, user_defined <lgl>, file <chr>