Learn R Programming

FCSlib (version 1.2.1)

boxcarDetrend: Boxcar filter detrending of a time series

Description

Performs the boxcar filter detrending algorithm over a vector

Usage

boxcarDetrend(f, w, acqTime, nIntervals, plot = TRUE)

Arguments

f

A vector

w

Size of the time window of the moving average

acqTime

Point acquisition rate (in seconds).

nIntervals

Number of intervals into which the moving average vector will be grouped.

plot

Boolean, set to TRUE (default) to plot the result

Value

Detrended version of 'f'

Details

First, an amount of zeroes equal to (w-1) is added at the tail of 'f' to compensate for the moving average effect when position (length(f) - w + 1) is reached. The moving average is then calculated and subtracted from the original vector 'f' to obtain the residuals. The moving average vector is then binned and the first value of the resulting vector is used as the lambda parameter for a Poisson distribution from which integer numbers will be randomly sampled and added to the residuals vector for trend correction.

See Also

expDetrend polyDetrend binTimeSeries

Examples

Run this code
# NOT RUN {
### Please navigate to
### (https://github.com/FCSlib/FCSlib/tree/master/Sample%20Data)
### to find this sample data

x <- read.table("PB030.dat", header = F)

x.d <- boxcarDetrend(x[,2], w = 100, acqTime = 4e-6, nIntervals = 100, plot = TRUE)
# }

Run the code above in your browser using DataLab