-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
100 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,55 @@ | ||
#' @title Create edges parallel | ||
#' | ||
#' @description This function part of the creation of edges | ||
#' @description This function is part of the creation of edges | ||
#' | ||
#' @include create_edges_progress.R | ||
#' | ||
#' @param index Indices | ||
#' @param frags Fragments | ||
#' @param precs Precursors | ||
#' @param nspecs Number of spectra | ||
#' | ||
#' @return NULL | ||
#' | ||
#' @export | ||
#' | ||
#' @examples NULL | ||
create_edges_parallel <- function(index, | ||
frags, | ||
precs, | ||
nspecs) { | ||
list <- lapply( | ||
X = (index + 1):nspecs, | ||
FUN = create_edges_progress, | ||
query = index, | ||
s1 = cbind(mz = frags[[index]][, 1], intensity = frags[[index]][, 2]), | ||
frags = frags, | ||
precs = precs | ||
) |> | ||
tidytable::bind_rows() | ||
return(list) | ||
create_edges_parallel <- function(spectra, | ||
ms2_tolerance = | ||
params$ms$tolerances$mass$dalton$ms2, | ||
ppm_tolerance = | ||
params$ms$tolerances$mass$ppm$ms2, | ||
parallel = | ||
params$options$parallel) { | ||
nspecz <- length(spectra) | ||
precz <- spectra$precursorMz | ||
fragz <- spectra@backend@peaksData | ||
msz <- ms2_tolerance | ||
ppmz <- ppm_tolerance | ||
|
||
if (parallel) { | ||
result_list <- | ||
pbmcapply::pbmclapply( | ||
X = 1:(nspecz - 1), | ||
FUN = create_edges_progress, | ||
mc.cores = parallelly::availableCores(), | ||
frags = fragz, | ||
precs = precz, | ||
nspecs = nspecz, | ||
ms2_tolerance = msz, | ||
ppm_tolerance = ppmz | ||
) | ||
} else { | ||
result_list <- | ||
lapply( | ||
X = 1:(nspecz - 1), | ||
FUN = create_edges_progress, | ||
frags = fragz, | ||
precs = precz, | ||
nspecs = nspecz, | ||
ms2_tolerance = msz, | ||
ppm_tolerance = ppmz | ||
) | ||
} | ||
|
||
# Combine the results into a single matrix | ||
edges <- | ||
do.call(rbind, unlist(result_list, recursive = FALSE)) |> | ||
data.frame() | ||
return(edges) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters