-
Notifications
You must be signed in to change notification settings - Fork 1
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
jasenfinch
committed
Jul 2, 2024
1 parent
f14887e
commit 05ea096
Showing
17 changed files
with
1,331 additions
and
1,193 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
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,96 +1,96 @@ | ||
#' Spectral binning parameters class | ||
#' @description An S4 class to store spectral binning parameters. | ||
#' @slot scans numeric vector containing the scan indexes to use for binning | ||
#' @slot cls the column of class labels to use for aggregating accurate | ||
#' mass data. Defaults to NULL where accurate mass data will be averaged | ||
#' @slot cls the column of class labels to use for aggregating accurate | ||
#' mass data. Defaults to NULL where accurate mass data will be averaged | ||
#' across all samples | ||
#' @seealso \code{\link{binParameters}} | ||
#' @export | ||
|
||
setClass('BinParameters', | ||
slots = list( | ||
scans = 'numeric', | ||
cls = 'character' | ||
), | ||
setClass("BinParameters", | ||
slots = list( | ||
scans = "numeric", | ||
cls = "character" | ||
), | ||
) | ||
|
||
#' Spectral binning analysis class | ||
#' @description An S4 class to store spectrally binned data and accurate | ||
#' @description An S4 class to store spectrally binned data and accurate | ||
#' mass information. | ||
#' @slot version package version | ||
#' @slot creation_date creation date | ||
#' @slot file_paths file paths for raw data | ||
#' @slot sample_info tibble containing runinfo data | ||
#' @slot binned_data list containing tibbles of spectrally binned data | ||
#' @slot binned_data list containing tibbles of spectrally binned data | ||
#' for each acquisition mode | ||
#' @slot accurate_mz tibble containin accurate mass information | ||
#' @slot spectra list containing tibbles of headers and class master | ||
#' @slot spectra list containing tibbles of headers and class master | ||
#' mix fingerprints | ||
#' @seealso \code{\link{binneRlyse}} | ||
#' @seealso \code{\link{binneRlyse}} | ||
#' @export | ||
|
||
setClass('Binalysis', | ||
slots = list( | ||
version = 'character', | ||
creation_date = 'character', | ||
file_paths = 'character', | ||
sample_info = 'tbl_df', | ||
binned_data = 'list', | ||
accurate_mz = 'tbl_df', | ||
spectra = 'list' | ||
), | ||
contains = 'BinParameters', | ||
prototype = list( | ||
version = packageVersion('binneR') %>% | ||
as.character(), | ||
creation_date = date(), | ||
sample_info = tibble( | ||
fileOrder = character(), | ||
injOrder = numeric(), | ||
fileName = character(), | ||
batch = numeric(), | ||
block = numeric(), | ||
name = character(), | ||
class = character() | ||
), | ||
accurate_mz = tibble() | ||
) | ||
setClass("Binalysis", | ||
slots = list( | ||
version = "character", | ||
creation_date = "character", | ||
file_paths = "character", | ||
sample_info = "tbl_df", | ||
binned_data = "list", | ||
accurate_mz = "tbl_df", | ||
spectra = "list" | ||
), | ||
contains = "BinParameters", | ||
prototype = list( | ||
version = packageVersion("binneR") %>% | ||
as.character(), | ||
creation_date = date(), | ||
sample_info = tibble( | ||
fileOrder = character(), | ||
injOrder = numeric(), | ||
fileName = character(), | ||
batch = numeric(), | ||
block = numeric(), | ||
name = character(), | ||
class = character() | ||
), | ||
accurate_mz = tibble() | ||
) | ||
) | ||
|
||
setValidity('Binalysis',function(object){ | ||
necessary_names <- c('fileOrder','injOrder','fileName','batch','block','name','class') | ||
|
||
info_names <- object %>% | ||
sampleInfo() %>% | ||
colnames() | ||
|
||
presence <- necessary_names %in% info_names | ||
|
||
if (FALSE %in% presence) { | ||
str_c('Sample information should contain the following column names: ', | ||
str_c(necessary_names,collapse = ', '), | ||
'.') | ||
} else { | ||
TRUE | ||
} | ||
setValidity("Binalysis", function(object) { | ||
necessary_names <- c("fileOrder", "injOrder", "fileName", "batch", "block", "name", "class") | ||
|
||
info_names <- object %>% | ||
sampleInfo() %>% | ||
colnames() | ||
|
||
presence <- necessary_names %in% info_names | ||
|
||
if (FALSE %in% presence) { | ||
str_c( | ||
"Sample information should contain the following column names: ", | ||
str_c(necessary_names, collapse = ", "), | ||
"." | ||
) | ||
} else { | ||
TRUE | ||
} | ||
}) | ||
|
||
setValidity('Binalysis',function(object){ | ||
file_path_names <- object %>% | ||
filePaths() %>% | ||
basename() | ||
|
||
info_file_names <- object %>% | ||
sampleInfo() %>% | ||
.$fileName | ||
|
||
matching <- file_path_names == info_file_names | ||
|
||
if (FALSE %in% matching) { | ||
'File names in paths do not match file names in the sample information.' | ||
} else { | ||
TRUE | ||
} | ||
|
||
|
||
setValidity("Binalysis", function(object) { | ||
file_path_names <- object %>% | ||
filePaths() %>% | ||
basename() | ||
|
||
info_file_names <- object %>% | ||
sampleInfo() %>% | ||
.$fileName | ||
|
||
matching <- file_path_names == info_file_names | ||
|
||
if (FALSE %in% matching) { | ||
"File names in paths do not match file names in the sample information." | ||
} else { | ||
TRUE | ||
} | ||
}) |
Oops, something went wrong.