From 460a0b94e6f7861866a01b39527d69ba81bb74ed Mon Sep 17 00:00:00 2001 From: Ethan Bass Date: Fri, 22 Dec 2023 16:13:43 -0500 Subject: [PATCH] docs: small changes to docs, whitespace --- NEWS.md | 2 +- R/normalization.R | 11 ++++++----- R/reshape_peaktable.R | 8 +++++--- man/ms_normalize_pqn.Rd | 3 ++- man/ms_reshape_peaktable.Rd | 3 ++- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/NEWS.md b/NEWS.md index 3684fa2..15776b0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/normalization.R b/R/normalization.R index 7dcc848..4f550e4 100644 --- a/R/normalization.R +++ b/R/normalization.R @@ -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. @@ -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")){ @@ -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) @@ -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) diff --git a/R/reshape_peaktable.R b/R/reshape_peaktable.R index 881c7aa..434e005 100644 --- a/R/reshape_peaktable.R +++ b/R/reshape_peaktable.R @@ -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}. @@ -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) @@ -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) } diff --git a/man/ms_normalize_pqn.Rd b/man/ms_normalize_pqn.Rd index 08f5813..536ee1e 100644 --- a/man/ms_normalize_pqn.Rd +++ b/man/ms_normalize_pqn.Rd @@ -7,7 +7,8 @@ ms_normalize_pqn(x, ref = c("median", "mean"), QC = NULL) } \arguments{ -\item{x}{An \code{ms_alignment} object or matrix with rows as samples and features as columns.} +\item{x}{A \code{ms_alignment} object or matrix with rows as samples and +features as columns.} \item{ref}{Reference for normalization: either \code{median} (default) to use the overall median of variables as the reference, or \code{mean} to use the diff --git a/man/ms_reshape_peaktable.Rd b/man/ms_reshape_peaktable.Rd index 5f6f063..834d747 100644 --- a/man/ms_reshape_peaktable.Rd +++ b/man/ms_reshape_peaktable.Rd @@ -25,7 +25,8 @@ the tidy output.} \item{treatments}{This argument is deprecated as of version 0.3.2. It is synonymous with the new metadata argument which should be used instead.} -\item{fixed_levels}{Fix factor levels of features in the order provided.} +\item{fixed_levels}{Logical. Whether to fix factor levels of features in the +order provided. Defaults to \code{TRUE}.} } \value{ If \code{export} is \code{TRUE}, returns spectrum as \code{data.frame}.