Skip to content

Commit

Permalink
Merge pull request #23 from jasenfinch/devel
Browse files Browse the repository at this point in the history
v0.4.2
  • Loading branch information
jasenfinch committed Dec 1, 2020
2 parents 296091d + e88ec4b commit 18fc7b6
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 13 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
@@ -1,6 +1,6 @@
Package: metaboMisc
Title: Miscellaneous Functions for Metabolomics Analyses
Version: 0.4.1
Version: 0.4.2
Authors@R: person("Jasen", "Finch", email = "jsf9@aber.ac.uk", role = c("aut", "cre"))
Description: Miscellaneous helper functions for metabolomics analyses that do not yet have a permanent home.
biocViews: Metabolomics
Expand Down Expand Up @@ -39,6 +39,7 @@ Collate:
plotRSD.R
export.R
parallel.R
featureSummary.R
License: GPL (>= 3)
Encoding: UTF-8
LazyData: true
Expand Down
8 changes: 2 additions & 6 deletions NAMESPACE
@@ -1,15 +1,10 @@
# Generated by roxygen2: do not edit by hand

export(addAssignments)
export(detectBatchDiff)
export(detectMissInjections)
export(detectPairwises)
export(export)
export(filterCorrelations)
export(reduce)
export(suitableParallelPlan)
export(theme_neat)
exportMethods(export)
exportMethods(featureSummary)
exportMethods(plotRSD)
exportMethods(preTreatModes)
importClassesFrom(MFassign,Assignment)
Expand All @@ -33,6 +28,7 @@ importFrom(dplyr,group_by_all)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,n)
importFrom(dplyr,n_distinct)
importFrom(dplyr,select)
importFrom(dplyr,summarise)
importFrom(future,availableCores)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
# metaboMisc 0.4.2

* Added `metaboMisc::featureSummary()` to summarise spectral features in the [`Binalysis`](https://aberhrml.github.io/binneR/reference/Binalysis-class.html) S4 class.

# metaboMisc 0.4.1

* Added a `NEWS.md` file to track changes to the package.
Expand Down
12 changes: 6 additions & 6 deletions R/allGenerics.R
Expand Up @@ -5,43 +5,43 @@ setGeneric("preTreatModes", function(processedData,parameters,verbose = T) {
})

#' @rdname detectBatchDiff
#' @export

setGeneric('detectBatchDiff',function(x, by = 'block', pthresh = 0.05){
standardGeneric('detectBatchDiff')
})

#' @rdname detectMissInjections
#' @export

setGeneric('detectMissInjections',function(x,idx = 'fileOrder'){
standardGeneric('detectMissInjections')
})

#' @rdname detectPairwises
#' @export

setGeneric('detectPairwises',function(x,cls,type){
standardGeneric('detectPairwises')
})

#' @rdname addAssignments
#' @export

setGeneric('addAssignments',function(analysis,assignment){
standardGeneric('addAssignments')
})

#' @rdname reduce
#' @export

setGeneric('reduce',function(x, isotopes = T, adducts = T, unknowns = F){
standardGeneric('reduce')
})

#' @rdname export
#' @export

setGeneric('export',function(analysis,outPath = '.'){
standardGeneric('export')
})

#' @rdname featureSummary

setGeneric('featureSummary',function(x){
standardGeneric('featureSummary')
})
30 changes: 30 additions & 0 deletions R/featureSummary.R
@@ -0,0 +1,30 @@
#' Summarise features
#' @rdname featureSummary
#' @description Summarise spectral binning features.
#' @param x S4 object of class Binalysis
#' @importFrom dplyr n_distinct
#' @export

setMethod('featureSummary',signature = 'Binalysis',
function(x){
x %>%
binnedData() %>%
map(~{{
.x %>%
rowid_to_column(var = 'Sample') %>%
gather('Feature','Intensity',-Sample)
}}) %>%
bind_rows() %>%
mutate(Mode = str_sub(Feature,1,1)) %>%
group_by(Mode) %>%
summarise(
`Number of bins` = n_distinct(Feature),
`Missing Data (%)` = round(length(which(Intensity == 0)) /
length(Intensity) * 100,2),
.groups = 'drop') %>%
{{
.$Mode[.$Mode == 'n'] = 'Negative'
.$Mode[.$Mode == 'p'] = 'Positive'
.
}}
})
17 changes: 17 additions & 0 deletions man/featureSummary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 18fc7b6

Please sign in to comment.