Skip to content

Commit

Permalink
Merge pull request #49 from aberHRML/devel
Browse files Browse the repository at this point in the history
v2.5.0
  • Loading branch information
Jasen Finch authored Dec 7, 2020
2 parents 71e0f9b + a4fc5f4 commit b948254
Show file tree
Hide file tree
Showing 36 changed files with 9,424 additions and 364 deletions.
6 changes: 2 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: binneR
Title: Spectral Processing for High Resolution Flow Infusion Mass Spectrometry
Version: 2.4.2
Version: 2.5.0
Authors@R: person("Jasen", "Finch", email = "[email protected]", role = c("aut", "cre"))
Description: A spectral binning approach for high resolution flow infusion mass spectrometry data.
biocViews: MassSpectrometry, Metabolomics
Expand Down Expand Up @@ -34,9 +34,6 @@ Collate:
binParameters.R
spectralBinning-method.R
show-method.R
info-method.R
binnedData-method.R
accurateData-method.R
get.R
calc.R
readFiles.R
Expand All @@ -47,6 +44,7 @@ Collate:
singleSample.R
readBinningParameters.R
reexports.R
access.R
Suggests:
knitr,
rmarkdown,
Expand Down
6 changes: 5 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ exportMethods("cls<-")
exportMethods("scans<-")
exportMethods(accurateData)
exportMethods(binnedData)
exportMethods(binningParameters)
exportMethods(cls)
exportMethods(info)
exportMethods(creationDate)
exportMethods(filePaths)
exportMethods(plotBin)
exportMethods(plotCentrality)
exportMethods(plotChromatogram)
exportMethods(plotFingerprint)
exportMethods(plotPurity)
exportMethods(plotTIC)
exportMethods(sampleInfo)
exportMethods(scans)
exportMethods(show)
exportMethods(version)
importFrom(cli,console_width)
importFrom(crayon,blue)
importFrom(crayon,green)
Expand Down
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# binneR v2.5.0

* S4 class [`Binalysis`](https://aberhrml.github.io/binneR/reference/Binalysis-class.html) now inherits from S4 class [`BinParameters`](https://aberhrml.github.io/binneR/reference/BinParameters-class.html).

* Fixed retrieval of example data in the usage [vignette](https://aberhrml.github.io/binneR/articles/binneR.html)

* `version` and `creation_date` slots added to [`Binalysis`](https://aberhrml.github.io/binneR/reference/Binalysis-class.html) S4 class.

* Added additional accessor [methods](file:///home/jasen/Documents/tools/R-package-dev/binneR/docs/reference/results.html) for the [`Binalysis`](https://aberhrml.github.io/binneR/reference/Binalysis-class.html) S4 class.

* Fixed declaration of generics to ensure they are declared as standard generics.

* Added validators for [`Binalysis`](https://aberhrml.github.io/binneR/reference/Binalysis-class.html) S4 class to ensure that sample information contains the correct fields and that the file names in the specified paths match those in the sample information.

# binneR v2.4.2

* Bin measures are now correctly averaged across samples in [`binneR::plotCentrality()`](https://aberHRML.github.io/binneR/reference/plotCentrality.html) and [`binneR::plotPurity()`](https://aberHRML.github.io/binneR/reference/plotPurity.html).
Expand Down
92 changes: 92 additions & 0 deletions R/access.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#' Binalysis class get methods
#' @rdname results
#' @description Methods for accessing spectral binning results from the Binalysis S4 class.
#' @param x S4 object of class Binalysis
#' @details
#' \itemize{
#' \item{version}{ - Extract package version used to create the object.}
#' \item{creationDate}{ - Extract the creation date of the object.}
#' \item{filePaths}{ - Extract the sample file paths.}
#' \item{sampleInfo}{ - Extract sample meta information.}
#' \item{binnedData}{ - Extract a binned data intensity matrix.}
#' \item{accurateData}{ - Extract sample-wise accurate mass data and bin measures.}
#' \item{binningParametesr}{Extract the binning parameters.}
#' }
#' @seealso \code{\link{Binalysis-class}}, \code{\link{binneRlyse}}
#' @export

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

#' @rdname results
#' @export

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

#' @rdname results
#' @export

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

#' @rdname results
#' @export

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)
})

#' @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)
})

#' @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)
})
13 changes: 0 additions & 13 deletions R/accurateData-method.R

This file was deleted.

81 changes: 67 additions & 14 deletions R/allClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,80 @@ setClass('BinParameters',
#' Spectral binning analysis class
#' @description An S4 class to store spectrally binned data and accurate
#' mass information.
#' @slot binLog date and time of initiation of spectral binning
#' @slot binParameters object of class BinParameters containing the
#' parameters for spectral binning
#' @slot files file paths for raw data
#' @slot info tibble containing runinfo data
#' @slot binnedData list containing tibbles of spectrally binned data
#' @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
#' for each acquisition mode
#' @slot accurateMZ tibble containin accurate mass information
#' @slot accurate_mz tibble containin accurate mass information
#' @slot spectra list containing tibbles of headers and class master
#' mix fingerprints
#' @seealso \code{\link{binneRlyse}}
#' @export

setClass('Binalysis',
slots = list(
binLog = 'character',
binParameters = 'BinParameters',
files = 'character',
info = 'tbl_df',
binnedData = 'list',
accurateMZ = 'tbl_df',
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){
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 b948254

Please sign in to comment.