process_timeseries: Helper function to prepare raw data for analysis

View source: R/process_timeseries.R

process_timeseriesR Documentation

Helper function to prepare raw data for analysis

Description

Processes raw data in such a way that it can be directly inputted to the rythm_analysis_by_window function.

Usage

process_timeseries(df = NULL, sampling_rate = NULL, window_size_in_days = 3, window_step_in_days = 1,
movavg = TRUE, detrend_data = TRUE, butterworth = TRUE,
f_low = 1/4, f_high = 1/73, plot = TRUE,
smoothing_n = 4, datetime = NULL, values = NULL)

Arguments

df

A data.frame where the first column is a POSIXct object and the rest are independent measurement values.

sampling_rate

A character string indicating the sampling rate of the data. Examples: '30 minutes', '1 hour', '4 seconds', '100 days'.

window_size_in_days

a numeric indicating the width of the window size in day units.

window_step_in_days

a numeric indicating the amount of day by which to move the window in day units.

detrend_data

Logical. If TRUE (default) will detrend the data. If FALSE measurement values won't be detrended. If both, detrend_data and smooth_data are TRUE, the detrending will run over the smoothed data.

butterworth

Logical. If TRUE (default) will apply a buttwerworth filter to the measurement values using a moving average. If FALSE measurement values won't be filtered.

f_low

Frequency for the low pass filter. Default = 1/4.

f_high

Frequency for the high pass filter. Default = 1/72.

order

filter order. Default = 2.

plot

logical. If TRUE (default) plots the filtered data over the raw data. If FALSE, does not plot.

smoothing_n

A numeric which indicated the amount of bins over which to run the smoothing average. Default = 4.

datetime

Optional if a data.frame is supplied. A POSIXct vector.

values

Optional if a data.frame is supplied. A vector of values from a mesurement.

movavg

Logical. If TRUE (default) will smooth the measurement values useing a moving average. If FALSE measurement values won't be smoothed.

Value

A named list of data.frames containing the output of [circadiandynamics::butterworth], [find_gaps()], [makes_time_windows()], and [smooth_detrend_by_windows()] for each measurement value.

Examples

processed_data <- process_timeseries(df = raw_data, sampling_rate = "30 min")


edpclau/circadian-dynamics documentation built on Aug. 25, 2023, 12:18 p.m.