Skip to content

Commit

Permalink
fix: naming system
Browse files Browse the repository at this point in the history
  • Loading branch information
philouail committed Jan 11, 2024
1 parent dbf7c01 commit 443b0ec
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 32 deletions.
33 changes: 17 additions & 16 deletions R/function-filtering.R → R/quality-assessment.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#' @title Basic filtering functions for metabolomics
#' @title Basic quality assessment functions for metabolomics
#'
#' @description
#'
#' When dealing with metabolomics results, it is often necessary to filter
#' features based on certain criteria. These criteria are typically derived
#' from statistical formulas applied to full rows of data, where each row
#' represents a feature. The following functions provide basic filtering
#' methods commonly used in the analysis of metabolomics data.
#' The following functions allow to calculate basic quality assessment estimates
#' typically employed in the analysis of metabolomics data. These functions are
#' designed to be applied to entire rows of data, where each row corresponds to
#' a feature. Subsequently, these estimates can serve as a foundation for
#' feature filtering.
#'
#' - `rsd` and `rowRsd` are convenience functions to calculate the relative
#' standard deviation (i.e. coefficient of variation) of a numerical vector
Expand Down Expand Up @@ -45,9 +45,9 @@
#' for non-gaussian distributed data.
#'
#' @note
#' For `rsd` and `rowRsd` the feature abundances are expected to be provided
#' in natural scale and not e.g. log2 scale as it may lead to incorrect
#' interpretations.
#' For `rsd` and `rowRsd` the feature abundances are expected to be provided in
#' natural scale and not e.g. log2 scale as it may lead to incorrect
#' interpretations.
#'
#' @return See individual function description above for details.
#'
Expand All @@ -57,7 +57,7 @@
#'
#' @importFrom stats sd mad median
#'
#' @name filteringFunctions
#' @name quality_assessment
#'
#' @references
#'
Expand Down Expand Up @@ -97,7 +97,7 @@
NULL

#' @export
#' @rdname filteringFunctions
#' @rdname quality_assessment
rsd <- function(x, na.rm = TRUE, mad = FALSE) {
if (mad)
mad(x, na.rm = na.rm) / abs(median(x, na.rm = na.rm))
Expand All @@ -106,12 +106,12 @@ rsd <- function(x, na.rm = TRUE, mad = FALSE) {
}

#' @export
#' @rdname filteringFunctions
#' @rdname quality_assessment
rowRsd <- function(x, na.rm = TRUE, mad = FALSE)
apply(x, MARGIN = 1, rsd, na.rm = na.rm, mad = mad)

#' @export
#' @rdname filteringFunctions
#' @rdname quality_assessment
rowDratio <- function(x, y, na.rm = TRUE, mad = FALSE){
if (mad)
vec <- apply(y, 1, mad, na.rm = na.rm) /
Expand All @@ -122,19 +122,20 @@ rowDratio <- function(x, y, na.rm = TRUE, mad = FALSE){
}

#' @export
#' @rdname filteringFunctions
#' @rdname quality_assessment
percentMissing <- function(x){
((sum(is.na(x))) / length(x))*100
}

#' @export
#' @rdname filteringFunctions
#' @rdname quality_assessment
rowPercentMissing <- function(x){
apply(x, MARGIN = 1, percentMissing)
}

#' @export
#' @rdname filteringFunctions
#' @rdname quality_assessment

rowBlank <- function(x, y, na.rm = TRUE){
m_samples <- apply(x, 1, mean, na.rm = na.rm)
m_blank <- apply(y, 1, mean, na.rm = na.rm)
Expand Down
22 changes: 11 additions & 11 deletions man/filteringFunctions.Rd → man/quality_assessment.Rd

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

12 changes: 7 additions & 5 deletions vignettes/MetaboCoreUtils.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,19 @@ Generally, injecting study samples in random order can reduce (or even avoid)
influence of any related technical bias in the downstream analysis and is highly
suggested to improve and assure data quality.

## Filtering data: Identifying measurement error
## Basic quality assessment and pre-filtering of metabolomics data

When dealing with metabolomics results, it is often necessary to filter
features based on certain criteria. These criteria are typically derived
from statistical formulas applied to full rows of data, where each row
represents a feature. In this tutorial, we'll explore a set of functions
designed for filtering metabolomics data.
designed designed to calculate basic quality assessment metrics on which
metabolomics data can subsequently be filtered.

First, to get more information on the available function you can check the documentation

```{r}
?filteringFunctions
?quality_assessment
```

We will use a matrix representing metabolomics measurements from different
Expand All @@ -581,8 +582,9 @@ cv_result <- rowRsd(metabolomics_data)
print(cv_result)
```

Next, we will compute the D-ratio, a measure of dispersion, by comparing the
standard deviation of QC samples to that of biological test samples.
Next, we will compute the D-ratio [@broadhurst_guidelines_2018], a measure of
dispersion, by comparing the standard deviation of QC samples to that of
biological test samples.

```{r}
# Generate QC samples
Expand Down

0 comments on commit 443b0ec

Please sign in to comment.