add_lib.Rd
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)
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 |
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 |
mode | Whether this library is for 'Pos' or 'Neg' mode. Default is 'Pos'. |
adduct | Adduct of molecules in the library. Default is |
dda | Whether this library is suitable for DDA data. |
aif | Whether this library is suitable for AIF data. |
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.
csv_file <- system.file("extdata", "PC_H.csv", package = "lipID") lib_data <- readr::read_csv(csv_file)#>#> #> #> #> #> #> #> #> #> #> #> #> #> #>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 )#>#> #> #> #> #> #> #> #> #> #> #> #> #> #>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>#> # 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>#> # 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>