Processes activity data to calculate traditional sleep metrics including sleep duration, activity index during wakefulness, brief awakenings, and detailed sleep bout characteristics. This function implements standard sleep analysis metrics commonly used in Drosophila sleep research.
A "brief awakening" is defined as a single time point of movement that is immediately preceded and followed by immobility, potentially indicating fragmented or shallow sleep.
Arguments
- dt_test
A
data.tablecontaining activity and sleep state data, typically the output fromHMMDataPrep. Must contain the following columns:id: Unique identifier for each individualmoving: Logical indicator of movementasleep: Logical indicator of sleep stateactivity: Numeric activity countphase: Factor with levels "Light" and "Dark"day: Integer day numbergenotype: Character or factor indicating genotypereplicate: Character or factor indicating replicate ID
Value
A named list containing seven data.table objects with sleep
metrics (all time values in minutes):
brief_awakenings_dataOriginal data with added
brief_awakeningscolumn (logical)sleep_summary_phaseTotal sleep time per phase (Light/Dark) and day for each individual
sleep_summary_whole_dayTotal sleep time per day for each individual
activity_index_phaseMean activity during wakefulness per phase and day (total activity / time awake)
activity_index_whole_dayMean activity during wakefulness per day
bout_summary_dayDetailed sleep bout metrics per day including:
latency: Time to first sleep bout (minutes from day start)first_bout_length: Duration of first sleep boutlatency_to_longest_bout: Time to longest boutlength_longest_bout: Duration of longest boutn_bouts: Number of sleep boutsmean_bout_length: Average bout durationtotal_bout_length: Total sleep time from bouts
bout_summary_phaseSleep bout metrics per phase and day
Details
The function calculates metrics separately for light and dark phases based on
the phase column. Sleep bouts are identified using
bout_analysis from the sleepr package.
Activity index provides a measure of movement intensity during wake periods, which can indicate arousal threshold or sleep depth.
See also
HMMDataPrep for preparing input data
bout_analysis for bout detection algorithm
Examples
if (FALSE) { # \dontrun{
# Assume 'processed_data' is output from HMMDataPrep()
sleep_metrics <- calcTradSleep(processed_data)
# Access individual metric tables
daily_bouts <- sleep_metrics$bout_summary_day
phase_sleep <- sleep_metrics$sleep_summary_phase
# View brief awakening data
head(sleep_metrics$brief_awakenings_data)
# Summary statistics
summary(sleep_metrics$sleep_summary_whole_day$time_spent_sleeping)
} # }