sleepcleanr-pipeline Skill
Version: 1.4.5 Pipeline steps: 10
| Step | Label | Description |
|---|---|---|
| 1 | Load data | .rds/.csv auto-detected; schema validated; optional supplementary file merged |
| 1.5 | Field-misentry check | SOL/WASO clock-time vs duration-field misentry detection on raw data |
| 2-4 | Parse & normalize (S3 chain) | Parse timestamps → parse intervals → normalize sequence |
| 5 | Classify records | Generate manual review CSVs for human approval |
| 5.75 | Second-review consensus | Apply second-review checklist consensus |
| 6-7 | Correct & compute metrics (S3 chain) | Manual + duration corrections; TST/SOL/WASO/SE metrics; has_correction enum |
| 8 | Auto-detect remaining issues | TIMESTAMP/DURATION/AMOUNT/SELF-REPORTED flag classification |
| 8.5 | Cross-participant consistency check | Global consistency audit across participants |
| 9 | Generate diagnostic figures | 30 figures (14 QC + 16 research) + figure_index.png contact sheet + RUN_INFO.txt |
| 10 | Build delivered datasets | finalize_columns() selects/renames to Dataset A/B per column dictionary |
Delivered columns (36, from column dictionary):
pidday_numrow_idbedtime_selfreport_tssleeponset_selfreport_tsawakening_selfreport_tsgetup_selfreport_tstst_minutessol_computed_minutesse_percenttib_minutessleepperiod_minuteswaso_computed_minuteswaso_avg_bout_selfreport_minutessol_selfreport_minuteswaso_selfreport_minutesnum_waso_bouts_selfreportnap_selfreport_totalminutesexercise_light_minutesexercise_moderate_minutesexercise_vigorous_minutesexercise_strength_minuteshas_correctionis_errorerror_typeis_unusualunusual_typeis_reasonable_unusualrecord_statusflag_severityneeds_reviewcaffeine_numalcohol_numnicotine_dosescannabis_dosesStartDate
Runtime dependencies: 13 packages in Imports (renv::install() covers all)
Overview
Pipeline: raw timestamps → parse → correct → metrics → detect → visualize (see the auto-generated step table above). Configurable via YAML — maps your dataset columns without code changes.
Input: .rds or .csv sleep diary data Output: Cleaned dataset + diagnostic figures + figure_index.png contact sheet + audit reports
Quick Start
renv::install("cyracaid/sleepdiary-cleaner")
library(sleepcleanr)
run_pipeline()
For your own data:
file.copy(system.file("config_template.yaml", package = "sleepcleanr"), "my_study.yaml")
# Edit my_study.yaml → set data.files.main to your file
run_pipeline(config = "my_study.yaml")
Key Columns
| Column | Source | Description |
|---|---|---|
has_correction |
Step 7 | none / algorithmic / manual / both |
data_category |
Step 6 | clean / error / unusual / equal_time_ok / skipped_na |
flag_severity |
Step 7 | Clean / Minor (1 flag) / Major (2+ flags) |
needs_review_flag |
Step 8 | Combined auto-detection flag |
auto_error_desc |
Step 8 | All detected issues in text form |
Config System
data.files.main— your data file (.rds or .csv, auto-detected)data.files.extra— optional supplementary file (StartDate, WASO counts)column_mapping— map your column names to pipeline internalsclassification.*— adjustable detection thresholds
Template: inst/config_template.yaml
Output
| Path | Contents |
|---|---|
latest_visualization_*/ |
All figures + RUN_INFO.txt + figure_index.png |
output/correction_status_final.csv |
Per-run summary |
output/appendix_step_ledger.csv |
Per-step flag tracking |
output/flagged_records_self_reported.csv |
SELF_REPORTED_FLAG records |
column_map.csv |
Column source mapping |
Key Figures
01_Pipeline_Flow_Diagram— record flow with counts and percentages02_Correction_Impact— delta lollipops + identity scatter + summary tableA1_Step_Flag_Ledger— per-step flag counts (merges former Fig 12 checkpoint convergence)figure_index.png— contact sheet of all figures