Skip to content

Commit

Permalink
docs: small changes to docs, whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbass committed Dec 22, 2023
1 parent 5fcb854 commit 460a0b9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Updated `ms_filter_alignment` so it filters matches when removing columns from the peak table.
* Added titles to mass spectra plots with peak name and retention index or time.
* Fixed bug in retention index matching algorithm for `ms_search_spectra` function.
* Added `fixed_levels` argument to `ms_reshape_peaktable` so features can be automatically plotted in the order they are provided by the user.
* Added `fixed_levels` argument to `ms_reshape_peaktable` so features can be plotted in the order they're provided by the user.
* Changed the name of the `mzinspectr` alignment object from `msdial_alignment` to `ms_alignment`.

# msdialreadr 0.3.3
Expand Down
11 changes: 6 additions & 5 deletions R/normalization.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#'
#' @description Performs Probabilistic Quotient Normalization on peak table.
#'
#' @param x An \code{ms_alignment} object or matrix with rows as samples and features as columns.
#' @param x A \code{ms_alignment} object or matrix with rows as samples and
#' features as columns.
#' @param ref Reference for normalization: either \code{median} (default) to use
#' the overall median of variables as the reference, or \code{mean} to use the
#' overall average of variables as the reference.
Expand All @@ -25,7 +26,7 @@
#' @export

ms_normalize_pqn <- function(x, ref = c("median", "mean"), QC = NULL) {
ref <- match.arg(ref, c("median","mean"))
ref <- match.arg(ref, c("median", "mean"))
if (inherits(x, what = "ms_alignment")){
X <- x$tab
} else if (class(x) %in% c("data.frame","matrix")){
Expand Down Expand Up @@ -160,7 +161,7 @@ ms_normalize_itsd <- function(x, idx, plot_it = FALSE) {
#' @export

ms_subtract_blanks <- function(x, blanks.idx, blanks.pattern,
what=c("mean","median"), drop = TRUE){
what=c("mean", "median"), drop = TRUE){
if (missing(blanks.idx)){
if (!missing(blanks.pattern)){
blanks.idx <- grep(blanks.pattern, x$sample_meta$full.name)
Expand All @@ -181,13 +182,13 @@ ms_subtract_blanks <- function(x, blanks.idx, blanks.pattern,
})

# Round any negative nunbers up to 0
x.n <- apply(x.n, c(1,2), function(y) max(y,0))
x.n <- apply(x.n, c(1, 2), function(y) max(y,0))

# drop 0 columns
if (drop){
zeros <- which(colMeans(x.n) == 0)
if (length(zeros) > 0){
x.n <- x.n[,-zeros]
x.n <- x.n[, -zeros]
}
}
x.n <- as.data.frame(x.n)
Expand Down
8 changes: 5 additions & 3 deletions R/reshape_peaktable.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#' the tidy output.
#' @param treatments This argument is deprecated as of version 0.3.2. It is
#' synonymous with the new metadata argument which should be used instead.
#' @param fixed_levels Fix factor levels of features in the order provided.
#' @param fixed_levels Logical. Whether to fix factor levels of features in the
#' order provided. Defaults to \code{TRUE}.
#' @importFrom dplyr select mutate any_of
#' @importFrom tidyr pivot_longer
#' @return If \code{export} is \code{TRUE}, returns spectrum as \code{data.frame}.
Expand All @@ -31,7 +32,7 @@ ms_reshape_peaktable <- function(x, peaks, metadata, treatments = NULL,
if (is.numeric(peaks)){
peaks <- colnames(df)[peaks]
}
df <- df[,match(peaks,colnames(df)), drop = FALSE]
df <- df[, match(peaks, colnames(df)), drop = FALSE]
if (!is.null(names(peaks))){
colnames(df) <- names(peaks)
peaks <- colnames(df)
Expand Down Expand Up @@ -69,5 +70,6 @@ ms_reshape_peaktable <- function(x, peaks, metadata, treatments = NULL,

ms_tidy_msdial <- function(x, peaks, metadata, treatments = NULL){
.Deprecated("ms_reshape_peaktable", package = "tidy_msdial")
ms_reshape_peaktable(x=x, peaks = peaks, metadata = metadata, treatments = treatments)
ms_reshape_peaktable(x = x, peaks = peaks, metadata = metadata,
treatments = treatments)
}
3 changes: 2 additions & 1 deletion man/ms_normalize_pqn.Rd

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

3 changes: 2 additions & 1 deletion man/ms_reshape_peaktable.Rd

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

0 comments on commit 460a0b9

Please sign in to comment.