#' Read and process mulitple data files
#' @name readFiles
#' @description Apply spectral binning on multiple data files.
#' @param files A vector of converted data file paths
#' @param dp An integer denoting the number of decimal places for spectral
#' binning
#' @param scans A vector of scan numbers that should be retrieved
#' @return A list containing peak lists for the relevant scans with combined
#' scan ranges for each present mode in the data file.
#' @details
#' Parallel processing is managed by the \code{future} package. This can
#' be specified using the \code{plan() function}. See the example below
#' and \code{?future::plan} for details on how this can be specified.
#' @examples
#' ## Example file path
#' file_paths <- system.file('example-data/1.mzML.gz',package = 'binneR')
#'
#' ## Optionally declare parallel processing backend
#' # plan(future::multisession,workers = 2)
#'
#' ## Process example file
#' res <- readFiles(file_paths,
#' dp = 2,
#' scans = detectInfusionScans(file_paths))
#'
#' @importFrom furrr future_map
#' @importFrom dplyr bind_rows
#' @importFrom tidyr spread
#' @export
readFiles <- function(files,
dp,
scans){
pl <- future_map(files,
sampProcess,
scans = scans,
dp = dp) %>%
set_names(files) %>%
bind_rows(.id = 'file') %>%
mutate(mz = str_c(polarity,mz)) %>%
split(.$polarity) %>%
future_map(~{
.x %>%
spread(key = 'mz',value = 'intensity',fill = 0) %>%
ungroup() %>%
select(-file,-polarity)
})
return(pl)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.