This function tries to identify cycles in which the pressure has dropped fast. It first disables all the cycles above or below certain thresholds (min, max), and then calculates whether the next cycle has dropped by more than fac times either the initial (relative to = "init", default) or the previous (relative_to = "prev") cycle.

find_bad_cycles(
  .data,
  ...,
  min,
  max,
  fac,
  v44 = "v44.mV",
  cycle = "cycle",
  relative_to = "init",
  quiet = NULL
)

Arguments

.data

A tibble, resulting from isoreader::iso_get_raw_data().

...

These dots are for future extensions and must be empty.

min

Minimum intensity level for good cycles. Defaults to 1,500 mV.

max

Maximum intensity level for good cycles. Defaults to 50,000 mV.

fac

Factor for how much larger the current drop should be than the one specified in relative_to.

v44

Column name of mass 44.

cycle

Column name of the column with the measurement cycle number.

relative_to

cycle Drop detection occurs relative to either the first cycle ("init", default) or to the previous cycle ("prev").

quiet

If TRUE, print info messages. If NULL (default) listens to options(clumpedr.quiet)

Value

Same as .data but with some new columns that allow us to disable certain cycles/whole samples.

Details

The drop in intensity can be defined relative to the first change in intensity (default), or to the previous cycle.

Note that the min, max, and fac input parameters must be columns in the input data, so that reproducibility is guaranteed.

Examples

# get the raw data from the example dataset
isoreader::iso_get_raw_data(standards, include_file_info = "Analysis") |>
  # add new columns with criteria
  dplyr::mutate(dis_min = 500, dis_max = 50000, dis_fac = 3) |>
  find_bad_cycles(min = "dis_min", max = "dis_max",
                  fac = "dis_fac", relative_to = "init")
#> Info: aggregating raw data from 27 data file(s), including file info '"Analysis"'
#> Info: found 0 out of 27 acquisitions with a drop in pressure of mass 44.
#> # A tibble: 2,187 × 23
#>    file_id Analysis type  cycle v44.mV v45.mV v46.mV v47.mV v48.mV v49.mV v54.mV
#>    <chr>   <chr>    <chr> <int>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>
#>  1 180814… 4841     stan…     0 16647. 19675. 23072. 25664.  2124.  -268.  -270.
#>  2 180814… 4841     stan…     1 16406. 19391. 22738. 25293.  2094.  -264.  -265.
#>  3 180814… 4841     stan…     2 16153. 19091. 22387. 24899.  2062.  -259.  -261.
#>  4 180814… 4841     stan…     3 15891. 18782. 22024. 24502.  2029.  -255.  -257.
#>  5 180814… 4841     stan…     4 15631. 18476. 21665. 24100.  1997.  -250.  -252.
#>  6 180814… 4841     stan…     5 15383. 18182. 21321. 23717.  1964.  -246.  -249.
#>  7 180814… 4841     stan…     6 15135. 17889. 20978. 23336.  1934.  -241.  -244.
#>  8 180814… 4841     stan…     7 14892. 17603. 20641. 22959.  1903.  -237.  -240.
#>  9 180814… 4841     stan…     8 14656. 17323. 20313. 22600.  1873.  -234.  -236.
#> 10 180814… 4841     stan…     9 14422. 17047. 19990. 22234.  1844.  -229.  -232.
#> # ℹ 2,177 more rows
#> # ℹ 12 more variables: dis_min <dbl>, dis_max <dbl>, dis_fac <dbl>,
#> #   outlier_cycle_low <lgl>, outlier_cycle_high <lgl>, cycle_diff <dbl>,
#> #   first_diff_fac <dbl>, cycle_drop <lgl>, cycle_has_drop <lgl>,
#> #   cycle_drop_num <int>, outlier_cycle_drop <lgl>, outlier_cycle <lgl>