From bfab494212cd7ce22f51d7b32c4c0717c2e7c630 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Mon, 2 Sep 2024 18:27:52 +0200 Subject: [PATCH] rename sib to denap in the variables names to avoid confusion #967 --- R/g.part5.analyseRest.R | 38 +++++++++---------------- tests/testthat/test_chainof5parts.R | 2 +- tests/testthat/test_part5_analyseRest.R | 30 +++++++++---------- vignettes/GGIRoutput.Rmd | 12 ++++---- 4 files changed, 35 insertions(+), 47 deletions(-) diff --git a/R/g.part5.analyseRest.R b/R/g.part5.analyseRest.R index e3b088009..1b380ad74 100644 --- a/R/g.part5.analyseRest.R +++ b/R/g.part5.analyseRest.R @@ -27,9 +27,9 @@ g.part5.analyseRest = function(sibreport = NULL, dsummary = NULL, } else { dsummary[di,fi:(fi + 2)] = c(0, 0, 0) } - ds_names[fi:(fi + 2)] = c(paste0("mdur_sib_overl_", name), - paste0("tdur_sib_overl_", name), - paste0("perc_sib_overl_", name)) + ds_names[fi:(fi + 2)] = c(paste0("mdur_denap_overl_", name), + paste0("tdur_denap_overl_", name), + paste0("perc_denap_overl_", name)) fi = fi + 3 # Overlap selfreportwith sib if (length(xi) > 0) { @@ -40,9 +40,9 @@ g.part5.analyseRest = function(sibreport = NULL, dsummary = NULL, } else { dsummary[di,fi:(fi + 2)] = c(0, 0, 0) } - ds_names[fi:(fi + 2)] = c(paste0("mdur_", name, "_overl_sib"), - paste0("tdur_", name, "_overl_sib"), - paste0("perc_", name ,"_overl_sib")) + ds_names[fi:(fi + 2)] = c(paste0("mdur_", name, "_overl_denap"), + paste0("tdur_", name, "_overl_denap"), + paste0("perc_", name ,"_overl_denap")) fi = fi + 3 invisible(list(fi = fi, ds_names = ds_names, dsummary = dsummary, di = di)) } @@ -223,18 +223,17 @@ g.part5.analyseRest = function(sibreport = NULL, dsummary = NULL, # if (length(sleeplog_indices) > 1) browser() # Count number of occurrences (do not count sleeplog because not informative) - dsummary[di,fi:(fi + 7)] = c(length(sibs_indices), + dsummary[di,fi:(fi + 6)] = c(length(sibs_indices), length(nap_indices), length(nonwear_indices), length(SIBoverlapNap_indices), length(SIBoverlapNonwear_indices), length(NapOverlapSIB_indices), - length(NonwearOverlapSIB_indices), - length(SleeplogOverlapSIB_indices)) - ds_names[fi:(fi + 7)] = c("nbouts_day_sib", "nbouts_day_srnap", "nbouts_day_srnonw", - "noverl_sib_srnap", "noverl_sib_srnonw", - "noverl_srnap_sib", "noverl_srnonw_sib", "noverl_srsleep_sib") - fi = fi + 8 + length(NonwearOverlapSIB_indices)) + ds_names[fi:(fi + 6)] = c("nbouts_day_denap", "nbouts_day_srnap", "nbouts_day_srnonw", + "noverl_denap_srnap", "noverl_denap_srnonw", + "noverl_srnap_denap", "noverl_srnonw_denap") + fi = fi + 7 # mean and total duration in sib per day if (length(sibs_indices) > 0) { dsummary[di,fi:(fi + 1)] = c(mean(srep_tmp$duration[sibs_indices]), @@ -242,7 +241,7 @@ g.part5.analyseRest = function(sibreport = NULL, dsummary = NULL, } else { dsummary[di,fi:(fi + 1)] = c(0, 0) } - ds_names[fi:(fi + 1)] = c("frag_mean_dur_sib_day", "dur_day_sib_min") + ds_names[fi:(fi + 1)] = c("frag_mean_dur_denap_day", "dur_day_denap_min") fi = fi + 2 # mean and total duration in self-reported naps per day if (length(nap_indices) > 0) { @@ -288,17 +287,6 @@ g.part5.analyseRest = function(sibreport = NULL, dsummary = NULL, sumobject = so ) dsummary = so$dsummary; ds_names = so$ds_names; fi = so$fi - # Self-reported sleep (window could be time in bed, this depends on what user used in part 4) - so = summarise_overlap( - srep_tmp, - X = "SIBoverlapSleeplog", - Y = "SleeplogOverlapSIB", - xi = SIBoverlapSleeplog_indices, - yi = SleeplogOverlapSIB_indices, - name = "srsleep", - sumobject = so - ) - dsummary = so$dsummary; ds_names = so$ds_names; fi = so$fi rm(srep_tmp) } else { fi = fi + 33 diff --git a/tests/testthat/test_chainof5parts.R b/tests/testthat/test_chainof5parts.R index 25856c758..e3d79184e 100644 --- a/tests/testthat/test_chainof5parts.R +++ b/tests/testthat/test_chainof5parts.R @@ -222,7 +222,7 @@ test_that("chainof5parts", { expect_true(dir.exists(dirname)) expect_true(file.exists(rn[1])) expect_that(nrow(output),equals(5)) # changed because OO window is exported - expect_that(ncol(output),equals(205)) + expect_that(ncol(output),equals(198)) expect_that(round(as.numeric(output$wakeup[2]), digits = 4), equals(36)) expect_that(as.numeric(output$dur_day_spt_min[4]), equals(1150)) # WW window duration expect_that(as.numeric(output$dur_day_spt_min[5]), equals(1680)) # OO window duration diff --git a/tests/testthat/test_part5_analyseRest.R b/tests/testthat/test_part5_analyseRest.R index 8ec08f988..199fb4714 100644 --- a/tests/testthat/test_part5_analyseRest.R +++ b/tests/testthat/test_part5_analyseRest.R @@ -31,12 +31,12 @@ test_that("Overlap 1 nap and 1 sib", { names(dsummary) = ds_names dsummary = as.data.frame(t(dsummary)) - expect_equal(dsummary$nbouts_day_sib, 1) + expect_equal(dsummary$nbouts_day_denap, 1) expect_equal(dsummary$nbouts_day_srnap, 1) - expect_equal(dsummary$frag_mean_dur_sib_day, 15) + expect_equal(dsummary$frag_mean_dur_denap_day, 15) expect_equal(dsummary$frag_mean_dur_srnap_day, 20) - expect_equal(dsummary$perc_sib_overl_srnap, 100) - expect_equal(dsummary$perc_srnap_overl_sib, 75) + expect_equal(dsummary$perc_denap_overl_srnap, 100) + expect_equal(dsummary$perc_srnap_overl_denap, 75) expect_equal(sum(dsummary), 323) }) @@ -61,13 +61,13 @@ test_that("Overlap 1 nonwear and 1 sib", { names(dsummary) = ds_names dsummary = as.data.frame(t(dsummary)) - expect_equal(dsummary$nbouts_day_sib, 1) + expect_equal(dsummary$nbouts_day_denap, 1) expect_equal(dsummary$nbouts_day_srnonw, 1) - expect_equal(dsummary$frag_mean_dur_sib_day, 15) + expect_equal(dsummary$frag_mean_dur_denap_day, 15) expect_equal(dsummary$frag_mean_dur_srnonw_day, 20) - expect_equal(dsummary$perc_sib_overl_srnonw, 100) - expect_equal(dsummary$perc_srnonw_overl_sib, 75) - expect_equal(sum(dsummary), 324) + expect_equal(dsummary$perc_denap_overl_srnonw, 100) + expect_equal(dsummary$perc_srnonw_overl_denap, 75) + expect_equal(sum(dsummary), 323) }) @@ -95,17 +95,17 @@ test_that("No overlap 1 nonwear, 1 nap, and 1 sib", { names(dsummary) = ds_names dsummary = as.data.frame(t(dsummary)) - expect_equal(ncol(dsummary), 34) + expect_equal(ncol(dsummary), 27) expect_equal(nrow(dsummary), 1) - expect_equal(dsummary$nbouts_day_sib, 1) + expect_equal(dsummary$nbouts_day_denap, 1) expect_equal(dsummary$nbouts_day_srnap, 1) expect_equal(dsummary$nbouts_day_srnonw, 1) - expect_equal(dsummary$frag_mean_dur_sib_day, 20) + expect_equal(dsummary$frag_mean_dur_denap_day, 20) expect_equal(dsummary$frag_mean_dur_srnap_day, 20) expect_equal(dsummary$frag_mean_dur_srnonw_day, 20) - expect_equal(dsummary$perc_sib_overl_srnap, 0) - expect_equal(dsummary$perc_sib_overl_srnonw, 0) - expect_equal(dsummary$perc_srnonw_overl_sib, 0) + expect_equal(dsummary$perc_denap_overl_srnap, 0) + expect_equal(dsummary$perc_denap_overl_srnonw, 0) + expect_equal(dsummary$perc_srnonw_overl_denap, 0) expect_equal(sum(dsummary, na.rm = TRUE), 129) }) diff --git a/vignettes/GGIRoutput.Rmd b/vignettes/GGIRoutput.Rmd index 0ccd0e1b4..778474eb4 100644 --- a/vignettes/GGIRoutput.Rmd +++ b/vignettes/GGIRoutput.Rmd @@ -380,13 +380,13 @@ vigorous activity: | nap_totalduration | Total nap duration, only calculated when argument do.sibreport = TRUE, currently optimised for 3.5-year old. See function documentation for function `g.part5.classifyNaps` in the [GGIR function documentation (pdf)](https:/CRAN.R-project.org/package=GGIR/GGIR.pdf). | | sibreport_n_items | Only created if `do.sibreport = TRUE`. Number of items in the sibreport | | sibreport_n_items_day | Only created if `do.sibreport = TRUE`. Number of items in the sibreport for this specific day | -| nbouts_day_X | Only created if `do.sibreport = TRUE`. Number of bouts in a day of X where X can be sib (sustained inactivity bout), srnap (self-reported nap) or srnonw (self-reported nonwear) | -| noverl_X | Only created if `do.sibreport = TRUE`. Number of overlapping bouts in a day of X where X can be sib_srnap, sib_srnonw, srnap_sib, or srnonw_sib | +| nbouts_X | Only created if `do.sibreport = TRUE`. Number of bouts in a day of X where X can be a detected nap (denap), srnap (self-reported nap) or srnonw (self-reported nonwear) | +| noverl_X | Only created if `do.sibreport = TRUE`. Number of overlapping bouts in a day of X where X can be denap_srnap, denap_srnonw, srnap_denap, or srnonw_denap | | frag_mean_dur_X_day | Only created if `do.sibreport = TRUE`. Mean duration of X per day, where X can be sib, srnap or srnonw | -| dur_day_X_min | Only created if `do.sibreport = TRUE`. Total duration in minutes of X per day, where X can be sib, srnap or srnonw | -| mdur_X_overl_Y | Only created if `do.sibreport = TRUE`. Mean duration of the overlap between X and Y, which are combinations of sib, srnap or srnonw | -| tdur_X_overl_Y | Only created if `do.sibreport = TRUE`. Total duration in minutes of the overlap between X and Y, which are combinations of sib, srnap or srnonw | -| perc_X_overl_Y | Only created if `do.sibreport = TRUE`. Percentage of overlap between X and Y, which are combinations of sib, srnap or srnonw | +| dur_X_min | Only created if `do.sibreport = TRUE`. Total duration in minutes of X per day, where X can be detect nap (denap), srnap or srnonw | +| mdur_X_overl_Y | Only created if `do.sibreport = TRUE`. Mean duration of the overlap between X and Y, which are combinations of denap, srnap or srnonw | +| tdur_X_overl_Y | Only created if `do.sibreport = TRUE`. Total duration in minutes of the overlap between X and Y, which are combinations of denap, srnap or srnonw | +| perc_X_overl_Y | Only created if `do.sibreport = TRUE`. Percentage of overlap between X and Y, which are combinations of denap, srnap or srnonw | **Special note if you are working on compositional data analysis:**