reduce_resolution: Reduce the resolution of Spectra

Description Usage Arguments Note Examples

View source: R/utils.R

Description

Reduce the resolution of Spectra

Usage

1
2
3
4
reduce_resolution(x, ...)

## S3 method for class 'collection'
reduce_resolution(x, k, ...)

Arguments

x

Acollection object to normalize

...

further arguments passed to or from other methods(not currently used).

k

an integer expressing the reduction in resolution. For example k=2will keep every second point, k=3 every third.

Note

Reducing resolution of the spectra before computation intensive steps like AI binning can significantly improve their speed, while minimally affecting the output.

You should however be careful with the choice of k and in the caase of subsequent binning make sure to remove the outter limits of the returned results as these will not match the outter limits of the full resolution spectra.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(tidySpectR)
# Speeding up AI binning
reduced <- reduce_resolution(fa_nmr, k=2)
binned <- bucket_aibin(extract(reduced,0.5, 7.2), 
                       0.5, 
                       mask(reduced, -Inf, 8))
breaks <- pull_breaks(binned)

# last break does not match spectra limit, leaving it so would create 
# a bin at the ends of the spectra
breaks[1]
breaks[length(breaks)]
pull_limits(extract(fa_nmr, 0.5, 7.2))

breaks <- breaks[-1] # remove first break
breaks <- breaks[-length(breaks)] # remove last break
processed <- bucket_from_breaks(extract(fa_nmr, 0.5, 7.2), breaks)

# Full resolution bucketted spectra
processed

CVUA-RRW/tidySpectR documentation built on April 13, 2021, 11:41 a.m.