This repository contains the analysis scripts for a study investigating the relationships between light exposure and various aspects of cognitive function in everyday life among UK adults.
RStudio project file. Double-click to open in RStudio. Required for features like relative paths using the here package.
preprocessing/– Contains numbered R scripts that must be run in order to preprocess raw data and create required variables.functions/– Custom R functions used in processing and analysis.figures/– Contains figures exported byanalysis_light_and_cognition.Rmd.figure data/– Data used to generate plots in GraphPad Prism, exported from the main analysis script.tables/– Tables exported byanalysis_light_and_cognition.Rmd.analysis_light_and_cognition.Rmd– R Markdown file for analysis and reporting. Knitted to a PDF. Uses and exports data from thedata/folder.
This folder should be downloaded from the Figshare repository: DOI-10.48420/28911977.
brightertime/– Cognition, subjective sleepiness, sleep, and baseline survey data collected via the mobile app.light_sensitivity/– Light sensitivity metrics (PIPR, brightness discrimination, subjective brightness), processed by Weolders et al. (2024). Also includes dose-response slopes between melanopic lux and cognitive function.spectrawear/– Light exposure data collected by Spectrawear. Includes calculated light exposure metrics and 2-hour history windows before cognitive tasks.
-
Sunrise and sunset times were calculated for:
latitude = 53.4808,longitude = -2.2426. -
All timestamps were recorded in local time (
Europe/London) by both Spectrawear and Brightertime. -
Timestamps in
.RDatafiles are stored inPOSIXctformat ("YYYY-MM-DD HH:MM:SS").
Although shown in local time, timestamps are labeled as UTC for consistency and ease of comparison.
To reproduce the analysis, install the required R packages using:
install.packages(c("here", "progress", "data.table", "dplyr", "lubridate", "lme4", "lmerTest", "ggplot2", "wesanderson", "moments", "ggpubr", "corrplot", "reshape2", "stats", "caret", "Hmisc", "car", "openxlsx", "suncalc", "parameters", "performance", "effectsize"))