From cab38f88d1dd37d94da5e38e284b34db84129ff9 Mon Sep 17 00:00:00 2001 From: jasenfinch Date: Thu, 29 Apr 2021 13:20:01 +0100 Subject: [PATCH 1/9] moved calculateMs into relationshipCalculator file --- R/calculateMs.R | 22 ---------------------- R/relationshipCalculator.R | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 22 deletions(-) delete mode 100644 R/calculateMs.R diff --git a/R/calculateMs.R b/R/calculateMs.R deleted file mode 100644 index 7dd264b..0000000 --- a/R/calculateMs.R +++ /dev/null @@ -1,22 +0,0 @@ -#' @importFrom tibble tibble rowid_to_column -#' @importFrom dplyr rowwise - -calculateMs <- function(mz,add,iso,trans,adductTable = adducts(), isotopeTable = isotopes(), transformationTable = transformations()) { - M <- map(trans,~{ - t <- . - t <- map(iso,~{ - i <- . - if (i == 'NA') {i <- NA} - if (t == 'NA') {t <- NA} - i <- tibble(`m/z` = mz, Adduct = add, Isotope = i, Transformation = t) %>% - rowwise() %>% - mutate(M = calcM(`m/z`,adduct = Adduct,isotope = Isotope,transformation = Transformation,adductTable = adductTable,isotopeTable = isotopeTable,transformationTable = transformationTable)) - return(i) - }) - t <- bind_rows(t) - return(t) - }) - M <- bind_rows(M) - M <- rowid_to_column(M, 'ID') - return(M) -} \ No newline at end of file diff --git a/R/relationshipCalculator.R b/R/relationshipCalculator.R index 8b48a1f..52176dd 100644 --- a/R/relationshipCalculator.R +++ b/R/relationshipCalculator.R @@ -59,4 +59,27 @@ relationshipCalculator <- function(mz, limit = 0.001, modes = NULL, adducts = c( combinations <- bind_rows(combinations) %>% as_tibble() return(combinations) +} + +#' @importFrom tibble tibble rowid_to_column +#' @importFrom dplyr rowwise + +calculateMs <- function(mz,add,iso,trans,adductTable = adducts(), isotopeTable = isotopes(), transformationTable = transformations()) { + M <- map(trans,~{ + t <- . + t <- map(iso,~{ + i <- . + if (i == 'NA') {i <- NA} + if (t == 'NA') {t <- NA} + i <- tibble(`m/z` = mz, Adduct = add, Isotope = i, Transformation = t) %>% + rowwise() %>% + mutate(M = calcM(`m/z`,adduct = Adduct,isotope = Isotope,transformation = Transformation,adductTable = adductTable,isotopeTable = isotopeTable,transformationTable = transformationTable)) + return(i) + }) + t <- bind_rows(t) + return(t) + }) + M <- bind_rows(M) + M <- rowid_to_column(M, 'ID') + return(M) } \ No newline at end of file From c9c0732ddbdbb6b2df89598944cfe22b3f8fba3a Mon Sep 17 00:00:00 2001 From: jasenfinch Date: Thu, 29 Apr 2021 13:35:02 +0100 Subject: [PATCH 2/9] updated Collate field in DESCRIPTION --- DESCRIPTION | 1 - 1 file changed, 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 82e9f22..46d6dc9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -39,7 +39,6 @@ Collate: allGenerics.R calcAdducts.R calcM.R calcMZ.R - calculateMs.R checks.R convert.R data.R From d491ab1bd32b30f1f2b74911bd50fca6d20bac9f Mon Sep 17 00:00:00 2001 From: jasenfinch Date: Thu, 29 Apr 2021 17:45:46 +0100 Subject: [PATCH 3/9] speed up relationshipCalculator --- NAMESPACE | 2 +- R/relationshipCalculator.R | 155 ++++++++++++++++++++-------------- man/relationshipCalculator.Rd | 15 +--- 3 files changed, 97 insertions(+), 75 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 215f4ed..b5c068f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -46,7 +46,6 @@ importFrom(dplyr,left_join) importFrom(dplyr,mutate) importFrom(dplyr,rename) importFrom(dplyr,right_join) -importFrom(dplyr,rowwise) importFrom(dplyr,select) importFrom(dplyr,summarise) importFrom(dplyr,tbl) @@ -71,6 +70,7 @@ importFrom(tibble,as_tibble) importFrom(tibble,deframe) importFrom(tibble,rowid_to_column) importFrom(tibble,tibble) +importFrom(tidyr,expand_grid) importFrom(tidyr,gather) importFrom(utils,combn) importFrom(utils,getFromNamespace) diff --git a/R/relationshipCalculator.R b/R/relationshipCalculator.R index 52176dd..c07becd 100644 --- a/R/relationshipCalculator.R +++ b/R/relationshipCalculator.R @@ -9,77 +9,106 @@ #' @param adductTable table containing adduct formation rules. Defaults to \code{\link{adducts}()}. #' @param isotopeTable table containing isotope rules. Defaults to \code{\link{isotopes}()}. #' @param transformationTable table containing transformation rules. Defaults to \code{\link{transformations}()}. +#' @examples +#' relationshipCalculator(c(132.03023,168.00691)) #' @author Jasen Finch #' @export #' @importFrom utils combn #' @importFrom dplyr left_join contains #' @importFrom stringr str_c -#' @examples -#' relationshipCalculator(c(132.03023,168.00691)) -#' -#' ## with modes declared -#' relationshipCalculator(c(132.03023,172.00067), -#' modes = c('n','p'), -#' adducts = list(n = c("[M-H]1-","[M+Cl]1-","[M+K-2H]1-"), -#' p = c('[M+H]1+','[M+K]1+','[M+Na]1+'))) - +#' @importFrom tidyr expand_grid +#' @importFrom tibble rowid_to_column tibble -relationshipCalculator <- function(mz, limit = 0.001, modes = NULL, adducts = c("[M-H]1-","[M+Cl]1-","[M+K-2H]1-"), isotopes = NULL, transformations = NULL, adductTable = adducts(), isotopeTable = isotopes(), transformationTable = transformations()){ - if (is.null(adducts)) { - adducts <- adductTable$Name - } - if (!is.null(modes) & is.list(adducts)) { - A1 <- adducts[[modes[1]]] - A2 <- adducts[[modes[2]]] - } else { - A1 <- adducts - A2 <- adducts - } - isotopes <- c('NA',isotopes) - transformations <- c('NA',transformations) +relationshipCalculator <- function(mz, limit = 0.001, adducts = c("[M-H]1-","[M+Cl]1-","[M+K-2H]1-"), isotopes = NA, transformations = NA, adductTable = adducts(), isotopeTable = isotopes(), transformationTable = transformations()){ + + Ms <- expand_grid(`m/z` = mz, + Adduct = adducts, + Isotope = isotopes, + Transformation = transformations) %>% + mutate(M = calculateMs(`m/z`,Adduct,Isotope,Transformation)) %>% + rowid_to_column(var = 'ID') + + relationships <- expand_grid(ID1 = Ms$ID, + ID2 = Ms$ID) %>% + filter(ID1 != ID2) %>% + left_join(Ms %>% + select(ID1 = ID,M1 = M), + by = 'ID1') %>% + left_join(Ms %>% + select(ID2 = ID,M2 = M), + by = 'ID2') %>% + mutate(Error = abs(M1 - M2)) %>% + filter(Error <= limit) %>% + left_join(Ms %>% + setNames(str_c(names(.),'1')), + by = c("ID1", "M1")) %>% + left_join(Ms %>% + setNames(str_c(names(.),'2')), + by = c("ID2", "M2")) %>% + filter(`m/z1` != `m/z2`) %>% + select(contains('ID'), + contains('m/z'), + contains('Adduct'), + contains('Isotope'), + contains('Transformation'),Error) - combinations <- combn(mz,2) + unique_rel <- relationships %>% + select(contains('ID')) %>% + mutate(fill = 1) %>% + tidyr::spread(ID2,fill) %>% + { + id1 <- select(., ID1) + . <- select(.,-ID1) + + .[lower.tri(.)] <- NA + . <- bind_cols(.,id1) + . + } %>% + gather(ID2,fill,-ID1) %>% + tidyr::drop_na() %>% + select(-fill) %>% + mutate(ID2 = as.numeric(ID2)) - combinations <- apply(combinations,2,function(x){ - M1 <- calculateMs(x[1],A1,isotopes,transformations,adductTable,isotopeTable,transformationTable) - M2 <- calculateMs(x[2],A2,isotopes,transformations,adductTable,isotopeTable,transformationTable) - - coms <- expand.grid(M1$ID,M2$ID) - colnames(coms) <- c('ID1','ID2') - coms <- left_join(coms,M1,by = c('ID1' = 'ID')) - colnames(coms)[3:ncol(coms)] <- str_c(colnames(coms)[3:ncol(coms)],'1') - coms <- left_join(coms,M2,by = c('ID2' = 'ID')) - colnames(coms)[8:ncol(coms)] <- str_c(colnames(coms)[8:ncol(coms)],'2') - - coms <- mutate(coms,Error = abs(M1 - M2)) %>% - filter(Error <= limit) %>% - select(contains('m/z'),contains('Adduct'),contains('Isotope'),contains('Transformation'),Error) - return(coms) - }) - combinations <- bind_rows(combinations) %>% - as_tibble() - return(combinations) + relationships <- relationships %>% + dplyr::anti_join(unique_rel, + by = c("ID1", "ID2")) %>% + select(-contains('ID')) + + return(relationships) } -#' @importFrom tibble tibble rowid_to_column -#' @importFrom dplyr rowwise - -calculateMs <- function(mz,add,iso,trans,adductTable = adducts(), isotopeTable = isotopes(), transformationTable = transformations()) { - M <- map(trans,~{ - t <- . - t <- map(iso,~{ - i <- . - if (i == 'NA') {i <- NA} - if (t == 'NA') {t <- NA} - i <- tibble(`m/z` = mz, Adduct = add, Isotope = i, Transformation = t) %>% - rowwise() %>% - mutate(M = calcM(`m/z`,adduct = Adduct,isotope = Isotope,transformation = Transformation,adductTable = adductTable,isotopeTable = isotopeTable,transformationTable = transformationTable)) - return(i) - }) - t <- bind_rows(t) - return(t) - }) - M <- bind_rows(M) - M <- rowid_to_column(M, 'ID') - return(M) +calculateMs <- function(mzs, adducts, isotopes, transformations, adductTable = adducts(), isotopeTable = isotopes(), transformationTable = transformations()){ + + if (!identical(length(mzs),length(adducts),length(isotopes),length(transformations))){ + stop('Arguments mzs, adducts, isotopes, transformations should be vectors of the same length', + call. = FALSE) + } + + addRules <- adducts %>% + tibble(Adduct = .) %>% + left_join(adductTable , + by = c('Adduct' = 'Name')) + + isoRules <- isotopes %>% + tibble(Isotope = .) %>% + left_join(isotopeTable, by = "Isotope") %>% + { + .$`Mass Difference`[is.na(.$`Mass Difference`)] <- 0 + . + } + + transRules <- transformations %>% + tibble(Transformation = .) %>% + left_join(transformationTable, by = c("Transformation" = "MF Change")) %>% + { + .$Difference[is.na(.$Difference)] <- 0 + . + } + + M <- ((mzs - addRules$Add) * addRules$Charge) + M <- (M - isoRules$`Mass Difference`) + M <- M / addRules$xM + M <- M - transRules$Difference + + return(round(M,5)) } \ No newline at end of file diff --git a/man/relationshipCalculator.Rd b/man/relationshipCalculator.Rd index 9637f03..863822a 100644 --- a/man/relationshipCalculator.Rd +++ b/man/relationshipCalculator.Rd @@ -7,10 +7,9 @@ relationshipCalculator( mz, limit = 0.001, - modes = NULL, adducts = c("[M-H]1-", "[M+Cl]1-", "[M+K-2H]1-"), - isotopes = NULL, - transformations = NULL, + isotopes = NA, + transformations = NA, adductTable = adducts(), isotopeTable = isotopes(), transformationTable = transformations() @@ -21,8 +20,6 @@ relationshipCalculator( \item{limit}{limit of deviation for thresholding associations. Defaults to 0.001} -\item{modes}{character vector of ionisation modes of input mz} - \item{adducts}{character vector of adducts to use. If \code{NULL} all available adducts will be used. If \code{modes} is not \code{NULL}, this should be named list, the names denoting the adduct aquisition modes.} \item{isotopes}{character vector of isotopes to use.} @@ -34,18 +31,14 @@ relationshipCalculator( \item{isotopeTable}{table containing isotope rules. Defaults to \code{\link{isotopes}()}.} \item{transformationTable}{table containing transformation rules. Defaults to \code{\link{transformations}()}.} + +\item{modes}{character vector of ionisation modes of input mz} } \description{ adduct, isotope and biotransfromation calculation. } \examples{ relationshipCalculator(c(132.03023,168.00691)) - -## with modes declared -relationshipCalculator(c(132.03023,172.00067), - modes = c('n','p'), - adducts = list(n = c("[M-H]1-","[M+Cl]1-","[M+K-2H]1-"), - p = c('[M+H]1+','[M+K]1+','[M+Na]1+'))) } \author{ Jasen Finch From 23b1e612f342a8d2df03bd0318a13ec781779cfe Mon Sep 17 00:00:00 2001 From: jasenfinch Date: Thu, 29 Apr 2021 17:56:52 +0100 Subject: [PATCH 4/9] function imports --- NAMESPACE | 3 +++ R/ionisationProducts.R | 2 +- R/relationshipCalculator.R | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index b5c068f..2752885 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -42,6 +42,7 @@ importFrom(dplyr,contains) importFrom(dplyr,everything) importFrom(dplyr,filter) importFrom(dplyr,group_by) +importFrom(dplyr,inner_join) importFrom(dplyr,left_join) importFrom(dplyr,mutate) importFrom(dplyr,rename) @@ -70,8 +71,10 @@ importFrom(tibble,as_tibble) importFrom(tibble,deframe) importFrom(tibble,rowid_to_column) importFrom(tibble,tibble) +importFrom(tidyr,drop_na) importFrom(tidyr,expand_grid) importFrom(tidyr,gather) +importFrom(tidyr,spread) importFrom(utils,combn) importFrom(utils,getFromNamespace) useDynLib(mzAnnotation) diff --git a/R/ionisationProducts.R b/R/ionisationProducts.R index 75c6eb8..58dddf1 100644 --- a/R/ionisationProducts.R +++ b/R/ionisationProducts.R @@ -4,7 +4,7 @@ #' @param adductTable table of adduct rules. Defaults to adducts() #' @examples #' ionisationProducts(aminoAcids$SMILES[1]) -#' @importFrom dplyr ungroup +#' @importFrom dplyr ungroup rowwise #' @export ionisationProducts <- function(SMILES,adductTable = adducts()){ diff --git a/R/relationshipCalculator.R b/R/relationshipCalculator.R index c07becd..adadb2f 100644 --- a/R/relationshipCalculator.R +++ b/R/relationshipCalculator.R @@ -14,9 +14,9 @@ #' @author Jasen Finch #' @export #' @importFrom utils combn -#' @importFrom dplyr left_join contains +#' @importFrom dplyr left_join contains inner_join #' @importFrom stringr str_c -#' @importFrom tidyr expand_grid +#' @importFrom tidyr expand_grid spread drop_na #' @importFrom tibble rowid_to_column tibble relationshipCalculator <- function(mz, limit = 0.001, adducts = c("[M-H]1-","[M+Cl]1-","[M+K-2H]1-"), isotopes = NA, transformations = NA, adductTable = adducts(), isotopeTable = isotopes(), transformationTable = transformations()){ @@ -55,7 +55,7 @@ relationshipCalculator <- function(mz, limit = 0.001, adducts = c("[M-H]1-","[M+ unique_rel <- relationships %>% select(contains('ID')) %>% mutate(fill = 1) %>% - tidyr::spread(ID2,fill) %>% + spread(ID2,fill) %>% { id1 <- select(., ID1) . <- select(.,-ID1) @@ -65,12 +65,12 @@ relationshipCalculator <- function(mz, limit = 0.001, adducts = c("[M-H]1-","[M+ . } %>% gather(ID2,fill,-ID1) %>% - tidyr::drop_na() %>% + drop_na() %>% select(-fill) %>% mutate(ID2 = as.numeric(ID2)) relationships <- relationships %>% - dplyr::anti_join(unique_rel, + inner_join(unique_rel, by = c("ID1", "ID2")) %>% select(-contains('ID')) From a101b2341337d5943c894084d94f341ed75d53a6 Mon Sep 17 00:00:00 2001 From: jasenfinch Date: Thu, 29 Apr 2021 17:58:58 +0100 Subject: [PATCH 5/9] test fixes --- NAMESPACE | 1 + tests/testthat/test-relationshipCalculator.R | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 2752885..f51762f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -47,6 +47,7 @@ importFrom(dplyr,left_join) importFrom(dplyr,mutate) importFrom(dplyr,rename) importFrom(dplyr,right_join) +importFrom(dplyr,rowwise) importFrom(dplyr,select) importFrom(dplyr,summarise) importFrom(dplyr,tbl) diff --git a/tests/testthat/test-relationshipCalculator.R b/tests/testthat/test-relationshipCalculator.R index 3fb90f3..e48707a 100644 --- a/tests/testthat/test-relationshipCalculator.R +++ b/tests/testthat/test-relationshipCalculator.R @@ -3,9 +3,7 @@ context('relationship calculation') test_that('relationshipCalculator works',{ rel <- relationshipCalculator(c(132.03023,172.00067), - modes = c('n','p'), - adducts = list(n = c("[M-H]1-","[M+Cl]1-","[M+K-2H]1-"), - p = c('[M+H]1+','[M+K]1+','[M+Na]1+'))) + adducts = c("[M-H]1-","[M+Cl]1-","[M+K-2H]1-",'[M+H]1+','[M+K]1+','[M+Na]1+')) expect_false(F %in% (class(rel) == c("tbl_df","tbl","data.frame"))) expect_true(nrow(rel) == 1) From efd35b07d51af18b9abef420ea9d96880080a3f4 Mon Sep 17 00:00:00 2001 From: jasenfinch Date: Thu, 29 Apr 2021 18:00:04 +0100 Subject: [PATCH 6/9] bumped version to 1.7.4 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 46d6dc9..22b097e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: mzAnnotation Title: Signal Annotation Tools for High Resolution Metabolomics -Version: 1.7.3 +Version: 1.7.4 Authors@R: person(given = "Jasen", family = "Finch", From 12802a71893cbfeba75b0d3b95fd3d31243c722c Mon Sep 17 00:00:00 2001 From: jasenfinch Date: Thu, 29 Apr 2021 18:00:44 +0100 Subject: [PATCH 7/9] updated README --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e28b47b..d032dcc 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ res <- relationshipCalculator(c(132.03023,168.00691)) res #> # A tibble: 1 x 9 -#> `m/z1` `m/z2` Adduct1 Adduct2 Isotope1 Isotope2 Transformation1 -#> -#> 1 132. 168. [M-H]1- [M+Cl]… NA NA NA +#> `m/z1` `m/z2` Adduct1 Adduct2 Isotope1 Isotope2 Transformation1 +#> +#> 1 132. 168. [M-H]1- [M+Cl]1- NA NA NA #> # … with 2 more variables: Transformation2 , Error ``` @@ -82,9 +82,9 @@ res <- PIPsearch(db = db, isotope = NA) res #> # A tibble: 1 x 12 -#> ID NAME InChI InChIKey SMILES MF Accurate_Mass Isotope Adduct -#> -#> 1 4 L-As… InCh… CKLJMWT… C([C@… C4H7… 133. NA [M-H]… -#> # … with 3 more variables: `Measured m/z` , `Theoretical m/z` , `PPM -#> # Error` +#> ID NAME InChI InChIKey SMILES MF Accurate_Mass Isotope Adduct +#> +#> 1 4 L-Asp… InChI=1S/C… CKLJMWTZI… C([C@@… C4H7… 133. NA [M-H]… +#> # … with 3 more variables: Measured m/z , Theoretical m/z , +#> # PPM Error ``` From 927c80423fcb511bc0fcded1165b448bf17008c5 Mon Sep 17 00:00:00 2001 From: jasenfinch Date: Thu, 29 Apr 2021 18:12:34 +0100 Subject: [PATCH 8/9] check fixes --- .github/workflows/R-CMD-check.yaml | 4 ++-- NAMESPACE | 1 + R/mzAnnotation.R | 3 ++- R/relationshipCalculator.R | 4 ++-- man/relationshipCalculator.Rd | 4 +--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 195eccd..e405a46 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -21,8 +21,8 @@ jobs: fail-fast: false matrix: config: - - {os: windows-latest, r: 'release'} - - {os: macOS-latest, r: 'release'} + # - {os: windows-latest, r: 'release'} + # - {os: macOS-latest, r: 'release'} - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} diff --git a/NAMESPACE b/NAMESPACE index f51762f..ba92553 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -63,6 +63,7 @@ importFrom(purrr,map_chr) importFrom(purrr,map_dbl) importFrom(purrr,map_df) importFrom(purrr,map_int) +importFrom(stats,setNames) importFrom(stringr,str_c) importFrom(stringr,str_extract) importFrom(stringr,str_replace) diff --git a/R/mzAnnotation.R b/R/mzAnnotation.R index d0142e5..e19eb6d 100644 --- a/R/mzAnnotation.R +++ b/R/mzAnnotation.R @@ -8,5 +8,6 @@ globalVariables(c('Name','ID','MF','Accurate Mass','Smile 1','Adduct', 'Theoretical m/z','True','desc','m/z','Adducts', 'Negative_Charge','Positive_Charge','SMILES','Total_Charge', 'NHH','COO','ACCESSION_ID','Accurate_Mass','Measured m/z', - 'HBA1','TPSA','.','Possible','Rule','x' + 'HBA1','TPSA','.','Possible','Rule','x','Transformation','ID1', + 'ID2','M','M1','M2','m/z1','m/z2','fill' )) \ No newline at end of file diff --git a/R/relationshipCalculator.R b/R/relationshipCalculator.R index adadb2f..c86bd07 100644 --- a/R/relationshipCalculator.R +++ b/R/relationshipCalculator.R @@ -2,8 +2,7 @@ #' @description adduct, isotope and biotransfromation calculation. #' @param mz numeric \code{vector} of accurate m/z #' @param limit limit of deviation for thresholding associations. Defaults to 0.001 -#' @param modes character vector of ionisation modes of input mz -#' @param adducts character vector of adducts to use. If \code{NULL} all available adducts will be used. If \code{modes} is not \code{NULL}, this should be named list, the names denoting the adduct aquisition modes. +#' @param adducts character vector of adducts names to use #' @param isotopes character vector of isotopes to use. #' @param transformations character vector of transformations to use #' @param adductTable table containing adduct formation rules. Defaults to \code{\link{adducts}()}. @@ -18,6 +17,7 @@ #' @importFrom stringr str_c #' @importFrom tidyr expand_grid spread drop_na #' @importFrom tibble rowid_to_column tibble +#' @importFrom stats setNames relationshipCalculator <- function(mz, limit = 0.001, adducts = c("[M-H]1-","[M+Cl]1-","[M+K-2H]1-"), isotopes = NA, transformations = NA, adductTable = adducts(), isotopeTable = isotopes(), transformationTable = transformations()){ diff --git a/man/relationshipCalculator.Rd b/man/relationshipCalculator.Rd index 863822a..6265e95 100644 --- a/man/relationshipCalculator.Rd +++ b/man/relationshipCalculator.Rd @@ -20,7 +20,7 @@ relationshipCalculator( \item{limit}{limit of deviation for thresholding associations. Defaults to 0.001} -\item{adducts}{character vector of adducts to use. If \code{NULL} all available adducts will be used. If \code{modes} is not \code{NULL}, this should be named list, the names denoting the adduct aquisition modes.} +\item{adducts}{character vector of adducts names to use} \item{isotopes}{character vector of isotopes to use.} @@ -31,8 +31,6 @@ relationshipCalculator( \item{isotopeTable}{table containing isotope rules. Defaults to \code{\link{isotopes}()}.} \item{transformationTable}{table containing transformation rules. Defaults to \code{\link{transformations}()}.} - -\item{modes}{character vector of ionisation modes of input mz} } \description{ adduct, isotope and biotransfromation calculation. From ded6b3f793f4d1f38a986e902bac3aa6f321903c Mon Sep 17 00:00:00 2001 From: jasenfinch Date: Thu, 29 Apr 2021 18:17:52 +0100 Subject: [PATCH 9/9] update pkgdown site --- docs/404.html | 2 +- docs/LICENSE-text.html | 2 +- docs/authors.html | 2 +- docs/index.html | 18 +++++------ docs/news/index.html | 2 +- docs/pkgdown.yml | 2 +- docs/reference/MetaboliteDatabase-class.html | 2 +- docs/reference/PIPsearch.html | 2 +- docs/reference/adductTransformMF.html | 2 +- docs/reference/adducts.html | 2 +- docs/reference/aminoAcids.html | 2 +- docs/reference/calcAccurateMass.html | 2 +- docs/reference/calcAdducts.html | 2 +- docs/reference/calcM.html | 2 +- docs/reference/calcMZ.html | 2 +- docs/reference/convert.html | 2 +- docs/reference/descriptors.html | 6 ++-- docs/reference/elements.html | 2 +- docs/reference/filterACCESSIONS.html | 2 +- docs/reference/filterER.html | 2 +- docs/reference/filterIP.html | 2 +- docs/reference/filterMF.html | 2 +- docs/reference/filterMR.html | 2 +- docs/reference/generateMF.html | 2 +- docs/reference/getAccessions.html | 2 +- docs/reference/getDescriptors.html | 2 +- docs/reference/index.html | 2 +- docs/reference/ionisationProducts.html | 2 +- docs/reference/isotopeDistribution.html | 2 +- docs/reference/isotopes.html | 2 +- docs/reference/metaboliteDB.html | 2 +- docs/reference/ppmError.html | 2 +- docs/reference/ppmRange.html | 2 +- docs/reference/relationshipCalculator.html | 31 +++++-------------- .../show-MetaboliteDatabase-method.html | 2 +- docs/reference/smartsSearch.html | 2 +- docs/reference/smileToAccurateMass.html | 2 +- docs/reference/smileToMF.html | 2 +- docs/reference/transformMF.html | 2 +- docs/reference/transformations.html | 2 +- 40 files changed, 57 insertions(+), 72 deletions(-) diff --git a/docs/404.html b/docs/404.html index 6f39e40..afaf4dc 100644 --- a/docs/404.html +++ b/docs/404.html @@ -71,7 +71,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index f599f36..fdc6099 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -71,7 +71,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/authors.html b/docs/authors.html index a7cfab4..f0cbb5d 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -71,7 +71,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/index.html b/docs/index.html index 25c7e15..89bed56 100644 --- a/docs/index.html +++ b/docs/index.html @@ -32,7 +32,7 @@ mzAnnotation - 1.7.3 + 1.7.4 @@ -95,9 +95,9 @@

res #> # A tibble: 1 x 9 -#> `m/z1` `m/z2` Adduct1 Adduct2 Isotope1 Isotope2 Transformation1 -#> <dbl> <dbl> <chr> <chr> <lgl> <lgl> <lgl> -#> 1 132. 168. [M-H]1- [M+Cl]… NA NA NA +#> `m/z1` `m/z2` Adduct1 Adduct2 Isotope1 Isotope2 Transformation1 +#> <dbl> <dbl> <chr> <chr> <lgl> <lgl> <lgl> +#> 1 132. 168. [M-H]1- [M+Cl]1- NA NA NA #> # … with 2 more variables: Transformation2 <lgl>, Error <dbl>
  • Molecular formula generation
  • @@ -140,11 +140,11 @@

    isotope = NA) res #> # A tibble: 1 x 12 -#> ID NAME InChI InChIKey SMILES MF Accurate_Mass Isotope Adduct -#> <int> <chr> <chr> <chr> <chr> <chr> <dbl> <lgl> <chr> -#> 1 4 L-As… InCh… CKLJMWT… C([C@… C4H7… 133. NA [M-H]… -#> # … with 3 more variables: `Measured m/z` <dbl>, `Theoretical m/z` <dbl>, `PPM -#> # Error` <dbl> +#> ID NAME InChI InChIKey SMILES MF Accurate_Mass Isotope Adduct +#> <int> <chr> <chr> <chr> <chr> <chr> <dbl> <lgl> <chr> +#> 1 4 L-Asp… InChI=1S/C… CKLJMWTZI… C([C@@… C4H7… 133. NA [M-H]… +#> # … with 3 more variables: Measured m/z <dbl>, Theoretical m/z <dbl>, +#> # PPM Error <dbl> diff --git a/docs/news/index.html b/docs/news/index.html index c0a426b..d8b993e 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -71,7 +71,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 616561a..aca1ef0 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 2.11.2 pkgdown: 1.6.1 pkgdown_sha: ~ articles: {} -last_built: 2021-02-17T23:51Z +last_built: 2021-04-29T17:14Z urls: reference: https://jasenfinch.github.io/mzAnnotation//reference article: https://jasenfinch.github.io/mzAnnotation//articles diff --git a/docs/reference/MetaboliteDatabase-class.html b/docs/reference/MetaboliteDatabase-class.html index 318b786..077fbd7 100644 --- a/docs/reference/MetaboliteDatabase-class.html +++ b/docs/reference/MetaboliteDatabase-class.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/PIPsearch.html b/docs/reference/PIPsearch.html index eb41c86..2d2eb4a 100644 --- a/docs/reference/PIPsearch.html +++ b/docs/reference/PIPsearch.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/adductTransformMF.html b/docs/reference/adductTransformMF.html index 22380b4..6b5f440 100644 --- a/docs/reference/adductTransformMF.html +++ b/docs/reference/adductTransformMF.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/adducts.html b/docs/reference/adducts.html index 312fa12..c973f46 100644 --- a/docs/reference/adducts.html +++ b/docs/reference/adducts.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/aminoAcids.html b/docs/reference/aminoAcids.html index f75b61e..d2eb810 100644 --- a/docs/reference/aminoAcids.html +++ b/docs/reference/aminoAcids.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/calcAccurateMass.html b/docs/reference/calcAccurateMass.html index c949c32..56dbdf5 100644 --- a/docs/reference/calcAccurateMass.html +++ b/docs/reference/calcAccurateMass.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/calcAdducts.html b/docs/reference/calcAdducts.html index 7768cb2..ede9777 100644 --- a/docs/reference/calcAdducts.html +++ b/docs/reference/calcAdducts.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/calcM.html b/docs/reference/calcM.html index 851f98c..a1fa2ad 100644 --- a/docs/reference/calcM.html +++ b/docs/reference/calcM.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/calcMZ.html b/docs/reference/calcMZ.html index 1ec9aa0..dd7b9fe 100644 --- a/docs/reference/calcMZ.html +++ b/docs/reference/calcMZ.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/convert.html b/docs/reference/convert.html index c310a11..2bb9548 100644 --- a/docs/reference/convert.html +++ b/docs/reference/convert.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/descriptors.html b/docs/reference/descriptors.html index c68b23f..94fcf37 100644 --- a/docs/reference/descriptors.html +++ b/docs/reference/descriptors.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 @@ -158,8 +158,8 @@

    Examp #> 18 c1ccc… C11H… 204. 0 0 0 3 #> 19 c1cc(… C9H1… 181. 0 0 0 4 #> 20 CC(C)… C5H1… 117. 0 0 0 3 -#> # … with 8 more variables: HBA2 <dbl>, HBD <dbl>, logP <dbl>, TPSA <dbl>, -#> # NHH <int>, OH <int>, COOH <int>, COO <int> +#> # … with 8 more variables: HBA2 <dbl>, HBD <dbl>, logP <dbl>, TPSA <dbl>, +#> # NHH <int>, OH <int>, COOH <int>, COO <int> diff --git a/docs/reference/filterACCESSIONS.html b/docs/reference/filterACCESSIONS.html index bf184f5..bdad60b 100644 --- a/docs/reference/filterACCESSIONS.html +++ b/docs/reference/filterACCESSIONS.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/filterER.html b/docs/reference/filterER.html index 347f46e..b6d6019 100644 --- a/docs/reference/filterER.html +++ b/docs/reference/filterER.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/filterIP.html b/docs/reference/filterIP.html index ea2943a..41e0bf1 100644 --- a/docs/reference/filterIP.html +++ b/docs/reference/filterIP.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/filterMF.html b/docs/reference/filterMF.html index 4c0ea61..daf0923 100644 --- a/docs/reference/filterMF.html +++ b/docs/reference/filterMF.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/filterMR.html b/docs/reference/filterMR.html index 14d2a3a..16dd4d1 100644 --- a/docs/reference/filterMR.html +++ b/docs/reference/filterMR.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/generateMF.html b/docs/reference/generateMF.html index 6718e9d..edd498c 100644 --- a/docs/reference/generateMF.html +++ b/docs/reference/generateMF.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/getAccessions.html b/docs/reference/getAccessions.html index 6382dc4..582e78d 100644 --- a/docs/reference/getAccessions.html +++ b/docs/reference/getAccessions.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/getDescriptors.html b/docs/reference/getDescriptors.html index 776cab9..f7a1e22 100644 --- a/docs/reference/getDescriptors.html +++ b/docs/reference/getDescriptors.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/index.html b/docs/reference/index.html index ee631b6..fb5c311 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -71,7 +71,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/ionisationProducts.html b/docs/reference/ionisationProducts.html index 19699c2..3eb7951 100644 --- a/docs/reference/ionisationProducts.html +++ b/docs/reference/ionisationProducts.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/isotopeDistribution.html b/docs/reference/isotopeDistribution.html index b127931..89558dd 100644 --- a/docs/reference/isotopeDistribution.html +++ b/docs/reference/isotopeDistribution.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/isotopes.html b/docs/reference/isotopes.html index 65db35d..5cb8596 100644 --- a/docs/reference/isotopes.html +++ b/docs/reference/isotopes.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/metaboliteDB.html b/docs/reference/metaboliteDB.html index 02b98fc..658ed48 100644 --- a/docs/reference/metaboliteDB.html +++ b/docs/reference/metaboliteDB.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/ppmError.html b/docs/reference/ppmError.html index 70e8d07..47bda90 100644 --- a/docs/reference/ppmError.html +++ b/docs/reference/ppmError.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/ppmRange.html b/docs/reference/ppmRange.html index a17b8a8..4a5f36f 100644 --- a/docs/reference/ppmRange.html +++ b/docs/reference/ppmRange.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/relationshipCalculator.html b/docs/reference/relationshipCalculator.html index 57a9eb1..d93f3a3 100644 --- a/docs/reference/relationshipCalculator.html +++ b/docs/reference/relationshipCalculator.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 @@ -123,10 +123,9 @@

    m/z relationship calculation

    relationshipCalculator(
       mz,
       limit = 0.001,
    -  modes = NULL,
       adducts = c("[M-H]1-", "[M+Cl]1-", "[M+K-2H]1-"),
    -  isotopes = NULL,
    -  transformations = NULL,
    +  isotopes = NA,
    +  transformations = NA,
       adductTable = adducts(),
       isotopeTable = isotopes(),
       transformationTable = transformations()
    @@ -143,13 +142,9 @@ 

    Arg limit

    limit of deviation for thresholding associations. Defaults to 0.001

    - - modes -

    character vector of ionisation modes of input mz

    - adducts -

    character vector of adducts to use. If NULL all available adducts will be used. If modes is not NULL, this should be named list, the names denoting the adduct aquisition modes.

    +

    character vector of adducts names to use

    isotopes @@ -180,20 +175,10 @@

    AuthorExamples

    relationshipCalculator(c(132.03023,168.00691))
    #> # A tibble: 1 x 9 -#> `m/z1` `m/z2` Adduct1 Adduct2 Isotope1 Isotope2 Transformation1 -#> <dbl> <dbl> <chr> <chr> <lgl> <lgl> <lgl> -#> 1 132. 168. [M-H]1- [M+Cl]… NA NA NA -#> # … with 2 more variables: Transformation2 <lgl>, Error <dbl>
    -## with modes declared -relationshipCalculator(c(132.03023,172.00067), - modes = c('n','p'), - adducts = list(n = c("[M-H]1-","[M+Cl]1-","[M+K-2H]1-"), - p = c('[M+H]1+','[M+K]1+','[M+Na]1+'))) -
    #> # A tibble: 1 x 9 -#> `m/z1` `m/z2` Adduct1 Adduct2 Isotope1 Isotope2 Transformation1 -#> <dbl> <dbl> <chr> <chr> <lgl> <lgl> <lgl> -#> 1 132. 172. [M-H]1- [M+K]1+ NA NA NA -#> # … with 2 more variables: Transformation2 <lgl>, Error <dbl>
    +#> `m/z1` `m/z2` Adduct1 Adduct2 Isotope1 Isotope2 Transformation1 +#> <dbl> <dbl> <chr> <chr> <lgl> <lgl> <lgl> +#> 1 132. 168. [M-H]1- [M+Cl]1- NA NA NA +#> # … with 2 more variables: Transformation2 <lgl>, Error <dbl>
    diff --git a/docs/reference/smartsSearch.html b/docs/reference/smartsSearch.html index 57e1b8a..48ab626 100644 --- a/docs/reference/smartsSearch.html +++ b/docs/reference/smartsSearch.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/smileToAccurateMass.html b/docs/reference/smileToAccurateMass.html index fb75e4f..9461e15 100644 --- a/docs/reference/smileToAccurateMass.html +++ b/docs/reference/smileToAccurateMass.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/smileToMF.html b/docs/reference/smileToMF.html index 48076e5..926b5f4 100644 --- a/docs/reference/smileToMF.html +++ b/docs/reference/smileToMF.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/transformMF.html b/docs/reference/transformMF.html index 29995b2..1fc9d38 100644 --- a/docs/reference/transformMF.html +++ b/docs/reference/transformMF.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4 diff --git a/docs/reference/transformations.html b/docs/reference/transformations.html index 06f17e0..bb2ba21 100644 --- a/docs/reference/transformations.html +++ b/docs/reference/transformations.html @@ -72,7 +72,7 @@ mzAnnotation - 1.7.3 + 1.7.4