Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianGoueguel committed Jun 25, 2024
1 parent e8e786b commit 069840e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
13 changes: 4 additions & 9 deletions R/normalize.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,10 @@
#' spectra, Trends in Analytical Chemistry, 28(10):1201-1222.
#'
#' @param x A numeric matrix or data frame containing the spectra.
#' @param method A character vector specifying the normalization method to apply.
#' Available methods are: "area", "background", and "internal".
#' @param bkg A numeric matrix or data frame of the same dimension as `x`, specifying
#' the intensity of the continuum radiation (background emission) used for
#' normalizing `x`. Required for "background" method.
#' @param wlength A character vector of the selected wavelength(s) related to the
#' internal standard(s) peak intensity. Optional for "background" method.
#' @param drop.na A logical value indicating whether to remove missing values before
#' normalizing (default: `TRUE`).
#' @param method A character vector specifying the normalization method to apply. Available methods are: "area", "background", and "internal".
#' @param bkg A numeric matrix or data frame of the same dimension as `x`, specifying the intensity of the continuum radiation (background emission) used for normalizing `x`. Required for "background" method.
#' @param wlength A character vector of the selected wavelength(s) related to the internal standard(s) peak intensity. Optional for "background" method.
#' @param drop.na A logical value indicating whether to remove missing values before normalizing. Default is `TRUE`.
#'
#' @return A data frame of normalized spectra.
#'
Expand Down
10 changes: 8 additions & 2 deletions R/outlierplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,19 @@ outlierplot <- function(x, quan = 1/2, alpha = 0.025, show.outlier = TRUE, show.
if (!is.numeric(quan) || quan < 0.5 || quan > 1) {
stop("'quan' must be a numeric value between 0.5 and 1")
}
if (!is.logical(show.outlier)) {
stop("'show.outlier' must be of type boolean (TRUE or FALSE)")
}
if (!is.logical(show.mahal)) {
stop("'show.mahal' must be of type boolean (TRUE or FALSE)")
}

if (is.data.frame(x) || tibble::is_tibble(x)) {
x <- as.matrix(x)
}

rob <- robustbase::covMcd(x, alpha = quan)
xarw <- adapt_reweight(x, rob$center, rob$cov, alpha = alpha)
xarw <- covARW(x, rob$center, rob$cov, alpha = alpha)

if (xarw$cn != Inf) {
alpha <- sqrt(c(xarw$cn, stats::qchisq(c(0.75, 0.5, 0.25), ncol(x))))
Expand Down Expand Up @@ -160,7 +166,7 @@ outlierplot <- function(x, quan = 1/2, alpha = 0.025, show.outlier = TRUE, show.
}


adapt_reweight <- function(x, m0, c0, alpha, pcrit){
covARW <- function(x, m0, c0, alpha, pcrit){
n <- nrow(x)
p <- ncol(x)

Expand Down
8 changes: 4 additions & 4 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ reference:
contents:
- zscore
- iqrMethod
- outlierplot
- adjusted_boxplot
- directOutlyingness
- generalized_boxplot

- title: Multivariate filtering

Expand Down Expand Up @@ -50,10 +47,13 @@ reference:

- title: Data visualization
desc: >
Functions that help visualize the state of the data.
Functions that help assess data visually.
contents:
- plotfit
- plotSpec
- outlierplot
- adjusted_boxplot
- generalized_boxplot

- title: Smoothing
desc: >
Expand Down
13 changes: 4 additions & 9 deletions man/normalize.Rd

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

0 comments on commit 069840e

Please sign in to comment.