From 6bc879ee6d662818bfaa77b2fb589fa5e4f9c290 Mon Sep 17 00:00:00 2001 From: Adriano Rutz Date: Mon, 31 Jul 2023 10:42:03 +0200 Subject: [PATCH] update --- DESCRIPTION | 6 +- NAMESPACE | 2 +- NEWS.md | 3 +- R/annotate_spectra.R | 78 ++++++------------- R/calculate_entropy.R | 6 +- R/create_edges.R | 48 ++++++++++++ R/create_edges_parallel.R | 44 ----------- R/create_edges_spectra.R | 68 ++++------------ R/parse_cli_params.R | 3 - codemeta.json | 62 +++++---------- inst/WORDLIST | 1 + inst/app/R/save_input.R | 6 -- inst/app/ui.R | 12 --- inst/params/default/annotate_spectra.yaml | 5 -- inst/params/default/create_edges_spectra.yaml | 5 -- inst/params/default/params.yaml | 3 - inst/pipelines/_targets.R | 2 - inst/scripts/docopt/annotate_spectra.txt | 6 +- inst/scripts/docopt/create_edges_spectra.txt | 6 +- man/annotate_spectra.Rd | 4 - man/calculate_entropy.Rd | 11 ++- ...eate_edges_parallel.Rd => create_edges.Rd} | 20 +++-- man/create_edges_spectra.Rd | 3 - tests/testthat/test_functions.R | 13 +--- 24 files changed, 139 insertions(+), 278 deletions(-) create mode 100644 R/create_edges.R delete mode 100644 R/create_edges_parallel.R rename man/{create_edges_parallel.Rd => create_edges.Rd} (55%) diff --git a/DESCRIPTION b/DESCRIPTION index d56a9bb26..0d61c109d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,13 +19,11 @@ Imports: docopt (>= 0.7.1), dplyr (>= 1.1.2), httr (>= 1.4.6), - future (>= 1.33.0), - future.apply (>= 1.11.0), igraph (>= 1.5.0.1), jsonlite (>= 1.8.7), MsBackendMgf (>= 1.8.0), msentropy (>= 0.1.3), - progressr (>= 0.13.0), + pbapply (>= 1.7.2), R.utils (>= 2.12.2), rotl (>= 3.1.0), Spectra (>= 1.10.1), @@ -81,7 +79,7 @@ Collate: 'create_adducts_neg.R' 'create_adducts_pos.R' 'create_components.R' - 'create_edges_parallel.R' + 'create_edges.R' 'keep_peaks.R' 'sanitize_spectra.R' 'remove_above_precursor.R' diff --git a/NAMESPACE b/NAMESPACE index 1e61fe707..133d2c56f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,7 +11,7 @@ export(create_adducts_neg) export(create_adducts_pos) export(create_components) export(create_dir) -export(create_edges_parallel) +export(create_edges) export(create_edges_spectra) export(decorate_bio) export(decorate_chemo) diff --git a/NEWS.md b/NEWS.md index 7400e511e..9bae15af2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,8 @@ # timaR 2.8.2 -* Change from pbmclapply to future.lapply +* Change from pbmclapply to pblapply +* Added spectral entropy * Fix empty chemical classes * [renv](https://rstudio.github.io/renv/index.html) removal * Performance improvement by replacing the [tidyverse](https://www.tidyverse.org) by the [fastverse](https://fastverse.github.io/fastverse) (in progress) diff --git a/R/annotate_spectra.R b/R/annotate_spectra.R index 64f6542e8..d6c6ecf0d 100644 --- a/R/annotate_spectra.R +++ b/R/annotate_spectra.R @@ -27,7 +27,6 @@ utils::globalVariables( #' #' @details It takes two files as input. #' A query file that will be matched against a library file. -#' Parallel processing is also made available. #' #' @include export_output.R #' @include export_params.R @@ -44,7 +43,6 @@ utils::globalVariables( #' @param condition Condition to be fulfilled. #' Either 'OR' or 'AND' (mass and peaks minima). #' @param qutoff Intensity under which ms2 fragments will be removed. -#' @param parallel Boolean. Process in parallel #' @param approx Perform matching without precursor match #' @param parameters Params #' @@ -62,7 +60,6 @@ annotate_spectra <- function(input = params$files$spectral$raw, ppm = params$ms$tolerances$mass$ppm$ms2, dalton = params$ms$tolerances$mass$dalton$ms2, qutoff = params$ms$intensity$thresholds$ms2, - parallel = params$options$parallel, approx = params$annotations$ms2$approx, parameters = params) { stopifnot("Your input file does not exist." = file.exists(input)) @@ -235,65 +232,34 @@ annotate_spectra <- function(input = params$files$spectral$raw, ) } } - ) + ) |> + Filter(f = Negate(is.null)) |> + dplyr::bind_rows() - inner_list <- Filter(Negate(is.null), inner_list) - inner_list <- dplyr::bind_rows(inner_list) return(inner_list) } log_debug("Performing spectral comparison") - ## TODO investigate issue with Windows - if (parallel && Sys.info()[["sysname"]] != "Windows") { - options(future.globals.onReference = "error") - future::plan(future::multisession) - progressr::handlers(list( - progressr::handler_progress( - format = ":current/:total [:bar] :percent in :elapsed ETA: :eta" - ) - )) - outer_list <- - future.apply::future_lapply( - X = seq_along(spectra), - p = progressr::progressor(along = seq_along(spectra)), - future.seed = TRUE, - FUN = function(spectrum, qp = query_precursors, p) { - p(sprintf("spectra=%g", length(qp))) - precursor <- qp[spectrum] - calculate_score_and_create_inner_list( - spectrum = spectrum, - precursor = precursor, - spectral_lib = lib_spectra, - query_spectra = query_spectra, - query_rts = query_rts, - lib_id = lib_id, - minimal = minimal, - maximal = maximal - ) - } - ) |> - progressr::with_progress() - } else { - outer_list <- - lapply( - X = seq_along(spectra), - FUN = function(spectrum, qp = query_precursors) { - precursor <- qp[spectrum] - calculate_score_and_create_inner_list( - spectrum = spectrum, - precursor = precursor, - spectral_lib = lib_spectra, - query_spectra = query_spectra, - query_rts = query_rts, - lib_id = lib_id, - minimal = minimal, - maximal = maximal - ) - } - ) - } + outer_list <- + pbapply::pblapply( + X = seq_along(spectra), + FUN = function(spectrum, qp = query_precursors) { + precursor <- qp[spectrum] + calculate_score_and_create_inner_list( + spectrum = spectrum, + precursor = precursor, + spectral_lib = lib_spectra, + query_spectra = query_spectra, + query_rts = query_rts, + lib_id = lib_id, + minimal = minimal, + maximal = maximal + ) + } + ) |> + dplyr::bind_rows() - return(dplyr::bind_rows(outer_list)) + return(outer_list) } df_final <- diff --git a/R/calculate_entropy.R b/R/calculate_entropy.R index 520330efe..2a9286227 100644 --- a/R/calculate_entropy.R +++ b/R/calculate_entropy.R @@ -7,6 +7,7 @@ #' @param frags Fragments #' @param ms2_tolerance MS2 tolerance #' @param ppm_tolerance ppm tolerance +#' @param threshold Threshold #' #' @return NULL #' @@ -17,7 +18,8 @@ calculate_entropy <- function(index, target, frags, ms2_tolerance, - ppm_tolerance) { + ppm_tolerance, + threshold = 0.1) { score <- msentropy::calculate_entropy_similarity( frags[[index]], @@ -31,7 +33,7 @@ calculate_entropy <- function(index, clean_spectra = TRUE ) - if (score >= 0.1) { + if (score >= threshold) { return( list( "feature_id" = index, diff --git a/R/create_edges.R b/R/create_edges.R new file mode 100644 index 000000000..49738a7fa --- /dev/null +++ b/R/create_edges.R @@ -0,0 +1,48 @@ +utils::globalVariables( + c( + "params" + ) +) + +#' @title Create edges +#' +#' @description This function applies similarity calculation to a list of +#' spectra to create edges +#' +#' @include calculate_entropy.R +#' +#' @param index Indices +#' @param frags Fragments +#' @param precs Precursors +#' @param nspecs Number of spectra +#' @param ms2_tolerance MS2 tolerance +#' @param ppm_tolerance ppm tolerance +#' @param threshold Threshold +#' +#' @return NULL +#' +#' @export +#' +#' @examples NULL +create_edges <- function(index, + frags, + precs, + nspecs, + ms2_tolerance, + ppm_tolerance, + threshold) { + # Calculate the similarity using lapply + inner_list <- lapply(X = (index + 1):nspecs, FUN = function(target) { + calculate_entropy( + index, + target, + frags, + ms2_tolerance, + ppm_tolerance, + threshold + ) + }) |> + dplyr::bind_rows() + + return(inner_list) +} diff --git a/R/create_edges_parallel.R b/R/create_edges_parallel.R deleted file mode 100644 index 25e9cb35c..000000000 --- a/R/create_edges_parallel.R +++ /dev/null @@ -1,44 +0,0 @@ -utils::globalVariables( - c( - "params" - ) -) - -#' @title Create edges parallel -#' -#' @description This function is slow so it had to be parallelized -#' -#' @include calculate_entropy.R -#' -#' @param index Indices -#' @param frags Fragments -#' @param precs Precursors -#' @param nspecs Number of spectra -#' @param ms2_tolerance MS2 tolerance -#' @param ppm_tolerance ppm tolerance -#' @param p Progressor -#' @param parallel Parallel -#' -#' @return NULL -#' -#' @export -#' -#' @examples NULL -create_edges_parallel <- function(index, - frags, - precs, - nspecs, - ms2_tolerance, - ppm_tolerance, - p = NA, - parallel) { - if (parallel) { - p(sprintf("spectra=%g", nspecs)) - } - # Calculate the similarity using lapply - inner_list <- lapply(X = (index + 1):nspecs, FUN = function(target) { - calculate_entropy(index, target, frags, ms2_tolerance, ppm_tolerance) - }) - - return(inner_list) -} diff --git a/R/create_edges_spectra.R b/R/create_edges_spectra.R index 7e03bec6e..d3b7cca30 100644 --- a/R/create_edges_spectra.R +++ b/R/create_edges_spectra.R @@ -10,7 +10,7 @@ utils::globalVariables(c( #' @description This function create edges #' based on fragmentation spectra similarity #' -#' @include create_edges_parallel.R +#' @include create_edges.R #' @include import_spectra.R #' @include normalize_peaks.R #' @include remove_above_precursor.R @@ -25,7 +25,6 @@ utils::globalVariables(c( #' @param ppm Relative ppm tolerance to be used #' @param dalton Absolute Dalton tolerance to be used #' @param qutoff Intensity under which ms2 fragments will be removed. -#' @param parallel Boolean. Process in parallel #' @param parameters Params #' #' @return NULL @@ -42,7 +41,6 @@ create_edges_spectra <- function( ppm = params$ms$tolerances$mass$ppm$ms2, dalton = params$ms$tolerances$mass$dalton$ms2, qutoff = params$ms$intensity$thresholds$ms2, - parallel = params$options$parallel, parameters = params) { stopifnot("Your input file does not exist." = file.exists(input)) ## Not checking for ppm and Da limits, everyone is free. @@ -62,62 +60,26 @@ create_edges_spectra <- function( log_debug("Performing spectral comparison") log_debug( - "As we do not bin the spectra, - nor limit the precursors delta, - expect a long processing time." + "As we do not limit the precursors delta, + expect a (relatively) long processing time." ) log_debug("Take yourself a break, you deserve it.") nspecz <- length(spectra) precz <- spectra$precursorMz fragz <- spectra@backend@peaksData - if (parallel) { - options(future.globals.onReference = "error") - future::plan(future::multisession) - progressr::handlers( - list( - progressr::handler_progress( - format = ":current/:total [:bar] :percent in :elapsed ETA: :eta" - ) - ) - ) - result_list <- - future.apply::future_lapply( - X = 1:(nspecz - 1), - FUN = create_edges_parallel, - p = progressr::progressor(along = 1:(nspecz - 1)), - future.seed = TRUE, - future.chunk.size = structure(TRUE, ordering = "random"), - frags = fragz, - precs = precz, - nspecs = nspecz, - ms2_tolerance = dalton, - ppm_tolerance = ppm, - parallel = parallel - ) |> - progressr::with_progress() - } else { - result_list <- - lapply( - X = 1:(nspecz - 1), - FUN = create_edges_parallel, - frags = fragz, - precs = precz, - nspecs = nspecz, - ms2_tolerance = dalton, - ppm_tolerance = ppm, - p = NA, - parallel = parallel - ) - } - edges <- do.call( - what = rbind, - args = unlist(result_list, recursive = FALSE) - ) |> - data.frame() - - log_debug("Collecting garbage ...") - gc() + edges <- + pbapply::pblapply( + X = 1:(nspecz - 1), + FUN = create_edges, + frags = fragz, + precs = precz, + nspecs = nspecz, + ms2_tolerance = dalton, + ppm_tolerance = ppm, + threshold = threshold + ) |> + dplyr::bind_rows() edges <- edges |> tidytable::select( diff --git a/R/parse_cli_params.R b/R/parse_cli_params.R index 425f626f9..319f7bb97 100644 --- a/R/parse_cli_params.R +++ b/R/parse_cli_params.R @@ -345,9 +345,6 @@ parse_cli_params <- function() { if (!is.null(arguments$force)) { params$options$force <- as.logical(arguments$force) } - if (!is.null(arguments$parallel)) { - params$options$parallel <- as.logical(arguments$parallel) - } if (!is.null(arguments$summarise)) { params$options$summarise <- as.logical(arguments$summarise) } diff --git a/codemeta.json b/codemeta.json index 39317e84d..ac9a9fe95 100644 --- a/codemeta.json +++ b/codemeta.json @@ -344,32 +344,6 @@ "sameAs": "https://CRAN.R-project.org/package=httr" }, "6": { - "@type": "SoftwareApplication", - "identifier": "future", - "name": "future", - "version": ">= 1.33.0", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=future" - }, - "7": { - "@type": "SoftwareApplication", - "identifier": "future.apply", - "name": "future.apply", - "version": ">= 1.11.0", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=future.apply" - }, - "8": { "@type": "SoftwareApplication", "identifier": "igraph", "name": "igraph", @@ -382,7 +356,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=igraph" }, - "9": { + "7": { "@type": "SoftwareApplication", "identifier": "jsonlite", "name": "jsonlite", @@ -395,7 +369,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=jsonlite" }, - "10": { + "8": { "@type": "SoftwareApplication", "identifier": "MsBackendMgf", "name": "MsBackendMgf", @@ -408,7 +382,7 @@ }, "sameAs": "https://bioconductor.org/packages/release/bioc/html/MsBackendMgf.html" }, - "11": { + "9": { "@type": "SoftwareApplication", "identifier": "msentropy", "name": "msentropy", @@ -421,20 +395,20 @@ }, "sameAs": "https://CRAN.R-project.org/package=msentropy" }, - "12": { + "10": { "@type": "SoftwareApplication", - "identifier": "progressr", - "name": "progressr", - "version": ">= 0.13.0", + "identifier": "pbapply", + "name": "pbapply", + "version": ">= 1.7.2", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", "name": "Comprehensive R Archive Network (CRAN)", "url": "https://cran.r-project.org" }, - "sameAs": "https://CRAN.R-project.org/package=progressr" + "sameAs": "https://CRAN.R-project.org/package=pbapply" }, - "13": { + "11": { "@type": "SoftwareApplication", "identifier": "R.utils", "name": "R.utils", @@ -447,7 +421,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=R.utils" }, - "14": { + "12": { "@type": "SoftwareApplication", "identifier": "rotl", "name": "rotl", @@ -460,7 +434,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=rotl" }, - "15": { + "13": { "@type": "SoftwareApplication", "identifier": "Spectra", "name": "Spectra", @@ -473,12 +447,12 @@ }, "sameAs": "https://bioconductor.org/packages/release/bioc/html/Spectra.html" }, - "16": { + "14": { "@type": "SoftwareApplication", "identifier": "stats", "name": "stats" }, - "17": { + "15": { "@type": "SoftwareApplication", "identifier": "stringi", "name": "stringi", @@ -491,7 +465,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=stringi" }, - "18": { + "16": { "@type": "SoftwareApplication", "identifier": "tidytable", "name": "tidytable", @@ -504,7 +478,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=tidytable" }, - "19": { + "17": { "@type": "SoftwareApplication", "identifier": "tidyfst", "name": "tidyfst", @@ -517,7 +491,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=tidyfst" }, - "20": { + "18": { "@type": "SoftwareApplication", "identifier": "tidyft", "name": "tidyft", @@ -530,12 +504,12 @@ }, "sameAs": "https://CRAN.R-project.org/package=tidyft" }, - "21": { + "19": { "@type": "SoftwareApplication", "identifier": "utils", "name": "utils" }, - "22": { + "20": { "@type": "SoftwareApplication", "identifier": "yaml", "name": "yaml", diff --git a/inst/WORDLIST b/inst/WORDLIST index b0dd1cf2d..96e66e3c5 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -72,6 +72,7 @@ nspectraangle ott parallelization params +pblapply pbmclapply pos pre diff --git a/inst/app/R/save_input.R b/inst/app/R/save_input.R index 5e6297193..112676c54 100644 --- a/inst/app/R/save_input.R +++ b/inst/app/R/save_input.R @@ -34,7 +34,6 @@ save_input <- function(input) { names_source <<- shiny::isolate(input$names_source) names_target <<- shiny::isolate(input$names_target) forceps <<- shiny::isolate(input$force) - parallel <<- shiny::isolate(input$parallel) summarise <<- shiny::isolate(input$summarise) ## Change 1 @@ -165,7 +164,6 @@ save_input <- function(input) { rt$ minutes <- ms_tol_rt_min - yamls_params$annotate_spectra$options$parallel <- parallel yamls_params$ create_edges_spectra$ @@ -242,10 +240,6 @@ save_input <- function(input) { ms_tol_rt_min yamls_params$create_edges_spectra$names$source <- names_source yamls_params$create_edges_spectra$names$target <- names_target - yamls_params$ - create_edges_spectra$ - options$ - parallel <- parallel yamls_params$prepare_features_edges$names$source <- names_source yamls_params$prepare_features_edges$names$target <- names_target diff --git a/inst/app/ui.R b/inst/app/ui.R index 508cd996c..ccf0f3bc9 100644 --- a/inst/app/ui.R +++ b/inst/app/ui.R @@ -1084,18 +1084,6 @@ ui <- fluidPage( "Really, do not use it." ) ), - checkboxInput( - inputId = "parallel", - label = "Execute processes in parallel when available", - value = TRUE - ) |> - shinyhelper::helper( - type = "inline", - content = c( - "When available, parallelize computation.", - "Note: parallelization is not properly handled on Windows." - ) - ), checkboxInput( inputId = "summarise", label = "Summarise results to one row per feature", diff --git a/inst/params/default/annotate_spectra.yaml b/inst/params/default/annotate_spectra.yaml index 0b897bdc9..82c524b15 100644 --- a/inst/params/default/annotate_spectra.yaml +++ b/inst/params/default/annotate_spectra.yaml @@ -80,8 +80,3 @@ ms: rt: #' Retention time tolerance in minutes. FLOAT minutes: 0.05 - -#' Options. -options: - #' Execute processes in parallel when available. BOOLEAN - parallel: yes diff --git a/inst/params/default/create_edges_spectra.yaml b/inst/params/default/create_edges_spectra.yaml index 9cad706b3..7fbd7e92f 100644 --- a/inst/params/default/create_edges_spectra.yaml +++ b/inst/params/default/create_edges_spectra.yaml @@ -55,8 +55,3 @@ names: #' Name of "target IDs" variable in the input. STRING target: CLUSTERID2 - -#' Options. -options: - #' Execute processes in parallel when available. BOOLEAN - parallel: yes diff --git a/inst/params/default/params.yaml b/inst/params/default/params.yaml index 77b712890..fda7b16f2 100644 --- a/inst/params/default/params.yaml +++ b/inst/params/default/params.yaml @@ -538,8 +538,5 @@ options: #' Do not use it. BOOLEAN force: no - #' Execute processes in parallel when available. BOOLEAN - parallel: yes - #' Summarise results to one row per feature. BOOLEAN summarise: yes diff --git a/inst/pipelines/_targets.R b/inst/pipelines/_targets.R index 8e36e9c03..a863e9e1c 100644 --- a/inst/pipelines/_targets.R +++ b/inst/pipelines/_targets.R @@ -1336,7 +1336,6 @@ list( ppm = par_ann_spe$ms$tolerances$mass$ppm$ms2, dalton = par_ann_spe$ms$tolerances$mass$dalton$ms2, qutoff = par_ann_spe$ms$intensity$thresholds$ms2, - parallel = par_ann_spe$options$parallel, approx = par_ann_spe$annotations$ms2$approx, parameters = par_ann_spe ) @@ -1359,7 +1358,6 @@ list( ppm = par_ann_spe$ms$tolerances$mass$ppm$ms2, dalton = par_ann_spe$ms$tolerances$mass$dalton$ms2, qutoff = par_ann_spe$ms$intensity$thresholds$ms2, - parallel = par_ann_spe$options$parallel, approx = par_ann_spe$annotations$ms2$approx, parameters = par_ann_spe ) diff --git a/inst/scripts/docopt/annotate_spectra.txt b/inst/scripts/docopt/annotate_spectra.txt index 06e979aa7..976a93bd9 100644 --- a/inst/scripts/docopt/annotate_spectra.txt +++ b/inst/scripts/docopt/annotate_spectra.txt @@ -1,8 +1,8 @@ You can use this script with the following example: - Rscript inst/scripts/annotate_spectra.R --fil-spe-raw data/source/examples/spectra.mgf --fil-lib-spe-pos data/interim/libraries/spectra/is/lotus_pos.sqlite --fil-ann-raw-spe data/interim/annotations/example_isdb.tsv.gz --ms-tol-mas-dal-ms2 0.02 --ms-tol-mas-ppm-ms2 10 --ann-ms2-thr-sim 0.2 --ms-int-thr-ms2 0 --ann-ms2-app false --parallel true + Rscript inst/scripts/annotate_spectra.R --fil-spe-raw data/source/examples/spectra.mgf --fil-lib-spe-pos data/interim/libraries/spectra/is/lotus_pos.sqlite --fil-ann-raw-spe data/interim/annotations/example_isdb.tsv.gz --ms-tol-mas-dal-ms2 0.02 --ms-tol-mas-ppm-ms2 10 --ann-ms2-thr-sim 0.2 --ms-int-thr-ms2 0 --ann-ms2-app false Usage: - annotate_spectra.R [--ann-ms2-app=] [--ann-ms2-met=] [--ann-ms2-thr-con=] [--ann-ms2-thr-pea-abs=] [--ann-ms2-thr-pea-rat=] [--ann-ms2-thr-sim=] [--fil-ann-raw-spe=] [--fil-lib-spe-neg=] [--fil-lib-spe-pos=] [--fil-spe-raw=] [--ms-int-thr-ms2=] [--ms-pol=] [--ms-tol-mas-ppm-ms2=] [--ms-tol-mas-dal-ms2=] [--ms-tol-rt-min=] [--fast=] [--parallel=] + annotate_spectra.R [--ann-ms2-app=] [--ann-ms2-thr-sim=] [--fil-ann-raw-spe=] [--fil-lib-spe-neg=] [--fil-lib-spe-pos=] [--fil-spe-raw=] [--ms-int-thr-ms2=] [--ms-pol=] [--ms-tol-mas-ppm-ms2=] [--ms-tol-mas-dal-ms2=] [--ms-tol-rt-min=] Arguments: ann-ms2-app Perform approximative matching without precursor matching? BOOLEAN @@ -19,8 +19,6 @@ Arguments: ms-tol-mas-dal-ms2 Absolute mass tolerance for MS2 in Dalton. FLOAT ms-tol-rt-min Retention time tolerance in minutes. FLOAT - parallel Execute processes in parallel when available. BOOLEAN - Options: -h --help Shows this screen. -v --version Shows version. \ No newline at end of file diff --git a/inst/scripts/docopt/create_edges_spectra.txt b/inst/scripts/docopt/create_edges_spectra.txt index f11a8e6f0..072608b2b 100644 --- a/inst/scripts/docopt/create_edges_spectra.txt +++ b/inst/scripts/docopt/create_edges_spectra.txt @@ -1,8 +1,8 @@ You can use this script with the following example: - Rscript inst/scripts/create_edges_spectra.R --fil-spe-raw data/source/examples/spectra.mgf --fil-net-spe-edg-raw data/interim/features/example_edges_spectra.tsv.gz --ms-tol-mas-dal-ms2 0.02 --ms-tol-mas-ppm-ms2 10 --ann-ms2-thr-sim 0.2 --ms-int-thr-ms2 0 --parallel true + Rscript inst/scripts/create_edges_spectra.R --fil-spe-raw data/source/examples/spectra.mgf --fil-net-spe-edg-raw data/interim/features/example_edges_spectra.tsv.gz --ms-tol-mas-dal-ms2 0.02 --ms-tol-mas-ppm-ms2 10 --ann-ms2-thr-sim 0.2 --ms-int-thr-ms2 0 Usage: - create_edges_spectra.R [--ann-ms2-met=] [--ann-ms2-thr-con=] [--ann-ms2-thr-pea-abs=] [--ann-ms2-thr-pea-rat=] [--ann-ms2-thr-sim=] [--fil-net-spe-edg-raw=] [--fil-spe-raw=] [--ms-int-thr-ms2=] [--ms-tol-mas-ppm-ms2=] [--ms-tol-mas-dal-ms2=] [--ms-tol-rt-min=] [--fast=] [--parallel=] + create_edges_spectra.R [--ann-ms2-thr-sim=] [--fil-net-spe-edg-raw=] [--fil-spe-raw=] [--ms-int-thr-ms2=] [--ms-tol-mas-ppm-ms2=] [--ms-tol-mas-dal-ms2=] [--ms-tol-rt-min=] Arguments: ann-ms2-thr-sim Similarity threhsold. FLOAT @@ -15,8 +15,6 @@ Arguments: ms-tol-mas-dal-ms2 Absolute mass tolerance for MS2 in Dalton. FLOAT ms-tol-rt-min Retention time tolerance in minutes. FLOAT - parallel Execute processes in parallel when available. BOOLEAN - Options: -h --help Shows this screen. -v --version Shows version. \ No newline at end of file diff --git a/man/annotate_spectra.Rd b/man/annotate_spectra.Rd index a733a0f85..9f57a052e 100644 --- a/man/annotate_spectra.Rd +++ b/man/annotate_spectra.Rd @@ -13,7 +13,6 @@ annotate_spectra( ppm = params$ms$tolerances$mass$ppm$ms2, dalton = params$ms$tolerances$mass$dalton$ms2, qutoff = params$ms$intensity$thresholds$ms2, - parallel = params$options$parallel, approx = params$annotations$ms2$approx, parameters = params ) @@ -36,8 +35,6 @@ Can be '.mgf' or '.sqlite' (Spectra formatted)} \item{qutoff}{Intensity under which ms2 fragments will be removed.} -\item{parallel}{Boolean. Process in parallel} - \item{approx}{Perform matching without precursor match} \item{parameters}{Params} @@ -51,7 +48,6 @@ This function annotates spectra \details{ It takes two files as input. A query file that will be matched against a library file. -Parallel processing is also made available. } \examples{ NULL diff --git a/man/calculate_entropy.Rd b/man/calculate_entropy.Rd index be026ddf4..772ab3e4e 100644 --- a/man/calculate_entropy.Rd +++ b/man/calculate_entropy.Rd @@ -4,7 +4,14 @@ \alias{calculate_entropy} \title{Calculate entropy} \usage{ -calculate_entropy(index, target, frags, ms2_tolerance, ppm_tolerance) +calculate_entropy( + index, + target, + frags, + ms2_tolerance, + ppm_tolerance, + threshold = 0.1 +) } \arguments{ \item{index}{Index} @@ -16,6 +23,8 @@ calculate_entropy(index, target, frags, ms2_tolerance, ppm_tolerance) \item{ms2_tolerance}{MS2 tolerance} \item{ppm_tolerance}{ppm tolerance} + +\item{threshold}{Threshold} } \description{ This function is part of the creation of edges diff --git a/man/create_edges_parallel.Rd b/man/create_edges.Rd similarity index 55% rename from man/create_edges_parallel.Rd rename to man/create_edges.Rd index ceb3f306d..0bc7ac0d2 100644 --- a/man/create_edges_parallel.Rd +++ b/man/create_edges.Rd @@ -1,18 +1,17 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/create_edges_parallel.R -\name{create_edges_parallel} -\alias{create_edges_parallel} -\title{Create edges parallel} +% Please edit documentation in R/create_edges.R +\name{create_edges} +\alias{create_edges} +\title{Create edges} \usage{ -create_edges_parallel( +create_edges( index, frags, precs, nspecs, ms2_tolerance, ppm_tolerance, - p = NA, - parallel + threshold ) } \arguments{ @@ -28,12 +27,11 @@ create_edges_parallel( \item{ppm_tolerance}{ppm tolerance} -\item{p}{Progressor} - -\item{parallel}{Parallel} +\item{threshold}{Threshold} } \description{ -This function is slow so it had to be parallelized +This function applies similarity calculation to a list of +spectra to create edges } \examples{ NULL diff --git a/man/create_edges_spectra.Rd b/man/create_edges_spectra.Rd index 82c424263..3d90f53e2 100644 --- a/man/create_edges_spectra.Rd +++ b/man/create_edges_spectra.Rd @@ -13,7 +13,6 @@ create_edges_spectra( ppm = params$ms$tolerances$mass$ppm$ms2, dalton = params$ms$tolerances$mass$dalton$ms2, qutoff = params$ms$intensity$thresholds$ms2, - parallel = params$options$parallel, parameters = params ) } @@ -34,8 +33,6 @@ create_edges_spectra( \item{qutoff}{Intensity under which ms2 fragments will be removed.} -\item{parallel}{Boolean. Process in parallel} - \item{parameters}{Params} \item{method}{Method to be used to perform spectral comparison} diff --git a/tests/testthat/test_functions.R b/tests/testthat/test_functions.R index 3375dd5b0..0b9988dcb 100644 --- a/tests/testthat/test_functions.R +++ b/tests/testthat/test_functions.R @@ -265,16 +265,11 @@ testthat::test_that("Whole process", { ### Appox annotate_spectra(approx = TRUE) ### Positive - annotate_spectra(parallel = FALSE) + annotate_spectra() ## Create MS2 based edges step <- "create_edges_spectra" params <- get_params(step = step) - ### Slow - create_edges_spectra( - parallel = FALSE - ) - ### Normal create_edges_spectra() ## additional test not covered by lapply @@ -283,11 +278,10 @@ testthat::test_that("Whole process", { # spectra <- spectra |> # sanitize_spectra(cutoff = params$ms$intensity$thresholds$ms2) # spectra <- spectra[1:2] - # create_edges_parallel( + # create_edges( # spectra = spectra, # ms2_tolerance = 0.01, - # ppm_tolerance = 5, - # parallel = FALSE + # ppm_tolerance = 5 # ) ## @@ -485,7 +479,6 @@ testthat::test_that("Whole process", { arguments$wei_che_22 <<- "x" arguments$wei_che_23 <<- "x" arguments$force <<- "x" - arguments$parallel <<- "x" arguments$summarise <<- "x" parse_cli_params()