Learn R Programming

FCSlib (version 1.2.1)

expDetrend: Exponential detrending of a time series

Description

Performs the exponential detrending algorithm over a vector

Usage

expDetrend(f, acqTime, nIntervals, pois = FALSE, plot = TRUE)

Arguments

f

A vector

acqTime

Point acquisition rate (in seconds)

nIntervals

Number of intervals into which the vector will be grouped before an exponential model fit

pois

Boolean, set to TRUE to add random, uncorrelated numbers sampled from a Poisson distribution

plot

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

Value

A vector

Details

First, the binTimeSeries() function is used to obtain a binned version of 'f' of 'nIntervals' points. An exponential model of the form (A0*e^(k*t) is then adjusted to the binned vector. The full time series is then evaluated using the obtained model and the residuals are calculated. When 'pois = FALSE', A0 is directly added to the full time series residuals for trend correction, in a quantity that will make the average counts remain constant across the whole time series. On the other hand, when 'pois = TRUE', then A0 will be used as the lambda parameter for a Poisson distribution from which integer numbers will be randomly sampled and added to the whole series for trend correction. This procedure asures that no photon counts with decimals will be obtained, though, it can add some noise to the data.

See Also

polyDetrend boxcarDetrend 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 <- expDetrend(x[,2], acqTime = 4e-6, nIntervals = 100, pois = F)

# Poisson sampling (this might take a little bit longer)
x.d.p <- expDetrend(x[,2], acqTime = 4e-6, nIntervals = 100, pois = T)
# }

Run the code above in your browser using DataLab