Skip to content

Commit

Permalink
feat: added option to filter peak table by max intensity
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbass committed Sep 21, 2023
1 parent ba68365 commit 18f5604
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Fixed bug in preprocess function causing fatal error due to misrecognition of matrices.
* Fixed behavior of `plot_chroms` and `correct_rt` to allow automatic detection of `lambda` for 1D chromatograms.
* Fixed bug in `combine_peaks` (due to misplaced parenthesis).
* Added new option to filter by maximum peak area or height in `filter_peaktable` (`what = "max"`), as suggested by Katherine Holmes.

# chromatographR 0.5.5

Expand Down
9 changes: 5 additions & 4 deletions R/filter_peaks.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ filter_peaks <- function(peak_list, min_height, min_area,
#' @param rts Vector of retention times to include in the peak table.
#' @param min_rt Minimum retention time to include in the peak table.
#' @param max_rt Maximum retention time to include in the peak table.
#' @param min_value Minimal cutoff for average peak intensity.
#' @param what Whether to average intensities using \code{mean} or \code{median}.
#' @param min_value Minimal cutoff for summarized peak intensity.
#' @param what Whether to summarize intensities using \code{mean}, \code{median},
#' or \code{max}.
#' @param lambda Component(s) to include in peak table (e.g. wavelengths if you
#' are using HPLC-DAD/UV).
#' @param tol Tolerance for matching of retention times to \code{rts}.
Expand All @@ -96,15 +97,15 @@ filter_peaks <- function(peak_list, min_height, min_area,
#' @export filter_peaktable

filter_peaktable <- function(peak_table, rts, min_rt, max_rt, min_value, lambda,
what = c("median","mean"), tol = 0){
what = c("median", "mean", "max"), tol = 0){
check_peaktable(peak_table)
if (missing(rts) & missing(min_rt) &
missing(max_rt) & missing(min_value) & missing(lambda)) {
warning("Nothing to filter...")
return(peak_table)
}
peak_table$pk_meta["rt",] <-as.numeric(peak_table$pk_meta["rt",])
what <- match.arg(what, c("median","mean"))
what <- match.arg(what, c("median", "mean", "max"))
if (!missing(rts)){
rts <- as.numeric(rts)
if (!inherits(rts, c("numeric"))){
Expand Down
7 changes: 4 additions & 3 deletions man/filter_peaktable.Rd

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

0 comments on commit 18f5604

Please sign in to comment.