Skip to content

Commit

Permalink
feat: filter matches with ms_filter_alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbass committed Nov 15, 2023
1 parent 2b5c265 commit 36bdbda
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mzinspectr 0.4.0

* Changed name of package to "mzinspectr".
* Updated `ms_filter_alignment` so it filters matches if columns are removed from the peak table.

# msdialreadr 0.3.3

Expand Down
10 changes: 7 additions & 3 deletions R/read_alignment.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ ms_read_alignment <- function(path){

#' Filter alignment by provided indices.
#' @param x An \code{msdial_alignment} object or matrix with rows as samples and features as columns.
#' @param idx Indices to be retained
#' @param what Which dimension to filter on. Either \code{rows} or columns (\code{cols}).
#' @param idx Indices to be retained or excluded according to the value of \code{inverse}.
#' @param what Which dimension to filter on. Either (\code{rows}) or columns
#' (\code{cols}).
#' @param inverse Whether to retain (default) or remove the specified columns.
#' @author Ethan Bass
#' @export
ms_filter_alignment <- function(x, idx, what=c("rows","cols"), inverse = FALSE){
what <- match.arg(what, c("rows","cols"))
what <- match.arg(what, c("rows", "cols"))
if (inverse){
idx <- -idx
}
Expand All @@ -46,6 +47,9 @@ ms_filter_alignment <- function(x, idx, what=c("rows","cols"), inverse = FALSE){
} else if (what == "cols"){
x$tab <- x$tab[,idx]
x$peak_meta <- x$peak_meta[idx,]
if (!is.null(x$matches)){
x$matches <- x$matches[idx]
}
}
x
}
Expand Down
5 changes: 3 additions & 2 deletions man/ms_filter_alignment.Rd

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

0 comments on commit 36bdbda

Please sign in to comment.