Restricts chromatograms to a range of retention times and/or wavelengths by subsetting the existing grid.
Arguments
- x
A numeric matrix (time × wavelength) or a list of such matrices. Row names must correspond to time points and column names to wavelengths.
- rt_range
Numeric vector of length 2 giving the inclusive range of retention times to keep, in the time unit of the data. Either element may be
NAfor an open bound. Defaults toNULL, which keeps every time point.- lambda_range
Numeric vector of length 2 giving the inclusive range of wavelengths to keep. Either element may be
NAfor an open bound. Defaults toNULL, which keeps every wavelength.
Details
Cropping is pure subsetting: the returned data are a submatrix of
the input, so values and dimnames pass through verbatim. This is the
difference from cropping via preprocess, which reaches a narrower range
by interpolating onto a new axis — resampling the signal unless the requested
grid happens to coincide with the existing time points, and reformatting the
retention times either way.
Bounds are inclusive, and either end of a range may be NA to leave it
open. Ranges are expressed in the units of the data itself: retention times
in whatever unit the chromatogram carries, as returned by get_times, and
wavelengths as labeled in the column names, as returned by get_lambdas.
An "estimated_baseline" attribute attached by preprocess or correct_baseline
is cropped alongside the data, so it stays aligned and can still be
retrieved with get_baseline.
A range that does not overlap the data at all is an error. A range that merely extends past one end is honored as far as the data allow, with a warning reporting what was actually kept, since this is usually a typo or a unit mismatch. Cropping chromatograms whose time axes are offset from one another — as unaligned chromatograms generally are — can leave them with different numbers of rows, which also warns: functions that read the time axis from the first chromatogram would then mislabel the rest, so align before cropping if the result needs a common time axis.
See also
preprocess, correct_baseline, get_times, get_lambdas
Other preprocessing functions:
correct_baseline(),
preprocess(),
subtract_blanks()
