Skip to contents

The function orbi_flag_outliers() flags outliers using one of the different methods provided by the parameters (to use multiple, please call this function several times sequentially). Note that this function evaluates outliers within each "filename", "block", "segment" and "injection" (if these columns exist), in addition to any groupings already defined before calling this function using dplyr's group_by(). It restores the original groupings in the returned data frame.

Usage

orbi_flag_outliers(dataset, agc_fold_cutoff = NA_real_, agc_window = c())

Arguments

dataset

Simplified IsoX dataset to have outliers flagged

agc_fold_cutoff

flags scans with a fold cutoff based on the average number of ions in the Orbitrap analyzer. For example, agc_fold_cutoff = 2 flags scans that have more than 2 times, or less than 1/2 times the average. TIC multiplied by injection time serves as an estimate for the number of ions in the Orbitrap.

agc_window

flags scans with a critically low or high number of ions in the Orbitrap analyzer. Provide a vector with 2 numbers c(x,y) flagging the lowest x percent and highest y percent. TIC multiplied by injection time serves as an estimate for the number of ions in the Orbitrap.

Value

A data frame with new columns is_outlier and outlier_type (if they don't already exist) that flags outliers identified by the method and provides the type of outlier (e.g. "2 fold agc cutoff"), respectively.

Details

Function is intended to flag scans that are outliers.

The input dataset is expected to have at least these 8 columns: filename, scan.no, time.min, compound, isotopocule, ions.incremental, tic, it.ms.

Examples

fpath <- system.file("extdata", "testfile_flow.isox", package = "isoorbi")
df <-
  orbi_read_isox(file = fpath) |>
  orbi_simplify_isox() |>
  orbi_flag_outliers(agc_window = c(1,99))
#> orbi_read_isox() is loading .isox data from 1 file(s)...
#> - loaded 6449 peaks for 1 compounds (HSO4-) with 5 isotopocules (M0, 33S,
#>    17O, 34S, 18O) from testfile_flow.isox in 0.02 seconds.
#> orbi_simplify_isox() will keep only columns 'filepath', 'filename',
#>    'scan.no', 'time.min', 'compound', 'isotopocule', 'ions.incremental',
#>    'tic', 'it.ms'...
#>    ...complete in 0.00 seconds.
#> orbi_flag_outliers() is flagging the 1 % of scans with the lowest and above
#>    99 % of scans with the highest number of ions (`tic` * `it.ms`) in the
#>    Orbitrap analyzer in 3 data group(s) (based on 'filename')...
#>    ...flagged 24/1290 scans (1.9%) as outliers (use `orbi_plot_raw_data(y =
#>    tic * it.ms)` to visualize them) across all data groups in 0.07 seconds.