Skip to contents

Detect batch/block differences within analytical runs for each ionisation mode.

Usage

detectBatchDiff(x, by = "block", pthresh = 0.05)

# S4 method for Binalysis
detectBatchDiff(x, by = "block", pthresh = 0.05)

# S4 method for MetaboProfile
detectBatchDiff(x, by = "block", pthresh = 0.05)

Arguments

x

object of S4 class Binalysis or MetaboProfile

by

info class column to use for batch/block information

pthresh

p-value threshold for significance

Value

If no differences between batches are found then NULL is returned. If significant differences are found then a tibble is returned containing the ANOVA results for each ionisation mode and showing whether batch correction is needed.

Details

Analysis of Variance (ANOVA) is used to detect differences in total ion count (TIC) averages between batches/blocks.

Examples

## Retrieve file paths and sample information for example data
files <- metaboData::filePaths('FIE-HRMS','BdistachyonEcotypes',ask = FALSE)

info <- metaboData::runinfo('FIE-HRMS','BdistachyonEcotypes')

## Perform spectral binning
analysis <- binneR::binneRlyse(files, 
                               info, 
                               parameters = binneR::detectParameters(files))
#> 
#> Attaching package: ‘purrr’
#> The following object is masked from ‘package:metaboMisc’:
#> 
#>     reduce
#> binneR v2.6.3 Fri Jul 21 17:25:38 2023
#> ________________________________________________________________________________
#> Scans: 5:13 
#> ________________________________________________________________________________
#> Reading raw data
#> Gathering bins
#> Removing single scan events
#> Averaging intensities across scans
#> Calculating bin metrics
#> Calculating accurate m/z
#> Building intensity matrix
#> Gathering file headers
#> 
#> Completed! [41S]

## Detect batch differences
batch_diff <- detectBatchDiff(analysis)

## Display batch differences
batch_diff
#> # A tibble: 2 × 6
#>   Mode      F `num df` `denom df` `p-value` `Correction needed`
#>   <chr> <dbl>    <dbl>      <dbl>     <dbl> <lgl>              
#> 1 n      22.7        5       28.8  3.52e- 9 TRUE               
#> 2 p     197.         5       28.1  5.73e-21 TRUE