Skip to content

Commit

Permalink
Reformat source files using styler.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasenfinch committed Jul 2, 2024
1 parent f14887e commit 05ea096
Show file tree
Hide file tree
Showing 17 changed files with 1,331 additions and 1,193 deletions.
126 changes: 74 additions & 52 deletions R/access.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @rdname results
#' @description Methods for accessing spectral binning results from the Binalysis S4 class.
#' @param x S4 object of class Binalysis
#' @details
#' @details
#' \itemize{
#' \item{version}{ - Extract package version used to create the object.}
#' \item{creationDate}{ - Extract the creation date of the object.}
Expand All @@ -15,78 +15,100 @@
#' @seealso \code{\link{Binalysis-class}}, \code{\link{binneRlyse}}
#' @export

setMethod('version',signature = 'Binalysis',
function(x){
x@version
})
setMethod("version",
signature = "Binalysis",
function(x) {
x@version
}
)

#' @rdname results
#' @export

setMethod('creationDate',signature = 'Binalysis',
function(x){
x@creation_date
})
setMethod("creationDate",
signature = "Binalysis",
function(x) {
x@creation_date
}
)

#' @rdname results
#' @export

setMethod('filePaths',signature = 'Binalysis',
function(x){
x@file_paths
})
setMethod("filePaths",
signature = "Binalysis",
function(x) {
x@file_paths
}
)

#' @rdname results
#' @export

setMethod('sampleInfo',signature = 'Binalysis',
function(x){
x@sample_info
})
setMethod("sampleInfo",
signature = "Binalysis",
function(x) {
x@sample_info
}
)

#' @rdname results
#' @export

setMethod('binnedData',signature = 'Binalysis',
function(x){
x@binned_data
})

setMethod('binnedData<-',signature = 'Binalysis',
function(x,value){
x@binned_data <- value
return(x)
})
setMethod("binnedData",
signature = "Binalysis",
function(x) {
x@binned_data
}
)

setMethod("binnedData<-",
signature = "Binalysis",
function(x, value) {
x@binned_data <- value
return(x)
}
)

#' @rdname results
#' @export

setMethod('accurateData',signature = 'Binalysis',
function(x){
x@accurate_mz
})

setMethod('accurateData<-',signature = 'Binalysis',
function(x,value){
x@accurate_mz <- value
return(x)
})
setMethod("accurateData",
signature = "Binalysis",
function(x) {
x@accurate_mz
}
)

setMethod("accurateData<-",
signature = "Binalysis",
function(x, value) {
x@accurate_mz <- value
return(x)
}
)

#' @rdname results
#' @export

setMethod('binningParameters',signature = 'Binalysis',
function(x){
as(x,'BinParameters')
})

setMethod('spectra',signature = 'Binalysis',
function(x){
x@spectra
})

setMethod('spectra<-',signature = 'Binalysis',
function(x,value){
x@spectra <- value
return(x)
})
setMethod("binningParameters",
signature = "Binalysis",
function(x) {
as(x, "BinParameters")
}
)

setMethod("spectra",
signature = "Binalysis",
function(x) {
x@spectra
}
)

setMethod("spectra<-",
signature = "Binalysis",
function(x, value) {
x@spectra <- value
return(x)
}
)
142 changes: 71 additions & 71 deletions R/allClasses.R
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
}
})
Loading

0 comments on commit 05ea096

Please sign in to comment.