peakIdentifier: Phase identifier for activity data

Description Usage Arguments Value Examples

View source: R/peakIdentifier.R

Description

This function generates a list of outputs. The first element is a plot of raw activity along with the smoothed data and objectively estimated phases of peak of activity data. Smoothing of activity is done using a Savitzky-Golay filter. The input of this function must be the output of the trimData function. This function requires the packages "plotly", "pracma" and "signal". As of now, this function works only for 24-hour T-cycles.

Usage

1
2
3
4
5
6
7
8
9
peakIdentifier(
  data,
  filt.order = 3,
  filt.length = 51,
  min.peak.dist = 100,
  peak.ht.scal = 0.5,
  windows = list(c(18, 6), c(6, 18)),
  rm.channels = c()
)

Arguments

data

Input data file. The input for this function must be the output of the function trimData(). See ??trimData(). This assumes that the output from trimData has data binned in 1-min intervals.

filt.order

The filter order. This defaults to 3.

filt.length

The length of filter in indices. This defaults to 51.

min.peak.dist

The minimum distance between peaks to be picked (in indices). This defaults to 100.

peak.ht.scal

A scaling factor to identify peaks. This defaults to 0.5. A value of 0.5 will only find peaks that are at least half as tall as that of the tallest peak.

windows

A list of vectors defining the start and end of the windows (in ZT) for morning and evening peaks, respectively around which the algorithm should look for peaks. This defaults to list(c(18,6), c(6,18)). The first window is treated as the window for morning peak, and the second as the window for evening peak.

rm.channels

All the channels that users want to remove from their averaging. This must be a vector, i.e., channels must be separated by commas. For instance, if users choose to remove channels 1 to 5, 25 and 32, then the input should be either c(1,2,3,4,5,25,32) or c(1:5,25,32). This defaults to an empty vector, meaning no individuals are removed from analysis.

Value

A list with two items:

Plots

A plotly htmlwidget with all the averaged activity overlayed with the smoothed data and markers to point out identified peaks in a 4-by-8 array.

Data

A matrix array with 32 rows (one for each fly) and 3 columns (Channel/Fly identity, Morning peak phase and Evening peak phase (measured in ZT)).

Examples

1
2
3
td <- trimData(data = df, start.date = "19 Dec 20", start.time = "21:00",
n.days = 3, bin = 1, t.cycle = 24)
pks <- peakIdentifier(data = td)

phase documentation built on Aug. 17, 2021, 1:06 a.m.

Related to peakIdentifier in phase...