Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zaunier, Udovicic, Spitschan - 2024 #132

Open
nuest opened this issue Nov 21, 2024 · 12 comments
Open

Zaunier, Udovicic, Spitschan - 2024 #132

nuest opened this issue Nov 21, 2024 · 12 comments
Assignees
Labels
community CODECHECK conducted as part of the community review process id assigned CODECHECK ID is assigned, please note when assigning new ones

Comments

@nuest
Copy link
Member

nuest commented Nov 21, 2024

Accepted for publication, currently in contact with author and editor if CODECHECK can be mentioned in the paper.

@sje30 volunteered as codechecker.

Preprint: https://www.researchsquare.com/article/rs-3771881/v1

Repository: https://github.com/tscnlab/ZaunerEtAl_PLoS_ONE_2024 | https://zenodo.org/records/14035243

Certificate: 2024-018

@nuest nuest added the community CODECHECK conducted as part of the community review process label Nov 21, 2024
@nuest nuest assigned nuest and sje30 and unassigned nuest Nov 21, 2024
@sje30
Copy link
Collaborator

sje30 commented Nov 27, 2024

I have good news @JZauner

after the normal wrangling with packages, I only hit one error, which I'll document below, and then I managed to get the same figures as originally provided in the manuscript.

I may well be finishing the certificate tomorrow live during the workshop at Rotterdam.

@sje30
Copy link
Collaborator

sje30 commented Nov 27, 2024

Set up

To start, I moved the original figures and html to new names, so I could compare my version with the originals:

 cp PowerCalc.html PowerCalc-orig.html
 mv Figures Figures-orig
 mkdir Figures

I then reduced n_samples (line 15, yaml, from 1000 to 10)

and then ran the document:

quarto render PowerCalc.qmd 

Note: this wasn't reported in the readme (it may well be obvious how to do the rendering).

@sje30
Copy link
Collaborator

sje30 commented Nov 27, 2024

Installation problem

I liked the use of the pacman package, which was new to me. However, I did get some error messages on the first run:


 ERROR: dependency ‘cards’ is not available for package ‘gtsummary’
* removing ‘/Users/stephen/NOBACKUP/RLIB/gtsummary’

ERROR: dependencies ‘minqa’, ‘nloptr’ are not available for package ‘lme4’
* removing ‘/Users/stephen/NOBACKUP/RLIB/lme4’

ERROR: dependency ‘nloptr’ is not available for package ‘lme4’
* removing ‘/Users/stephen/NOBACKUP/RLIB/lme4’

** byte-compile and prepare package for lazy loading
Note: wrong number of arguments to 'ceiling' 

Reading the source file, I saw the note about the Matrix package. Having seen errors with lme4, I thought it would be sensible to follow the advice to update Matrix and lme4:


oo <- options(repos = "https://cran.r-project.org/")
install.packages("Matrix", type = "source")
install.packages("lme4", type = "source")
options(oo)
library(lme4)
library(lmerTest)

This worked. And then the main packages loaded okay.

Failure to load the LightLogR package from github

I got this error:

p_load_gh("tscnlab/LightLogR")
Error in utils::download.file(url, path, method = method, quiet = quiet,  : 
  download from 'https://api.github.com/repos/tscnlab/LightLogR/tarball/HEAD' failed
Warning messages:
1: In p_install_gh(package, dependencies, ...) :
  The following may have incorrect capitalization specification:

LightLogR
2: In p_load_gh("tscnlab/LightLogR") : 
Failed to install/load:
tscnlab/LightLogR

I couldn't see what was run, but luckily the package is also available
on github, and that did install fine for me:

install.packages("LightLogR")
Installing package into ‘/Users/stephen/NOBACKUP/RLIB’
(as ‘lib’ is unspecified)
also installing the dependencies ‘fontBitstreamVera’, ‘fontLiberation’, ‘fontquiver’, ‘jpeg’, ‘gdtools’, ‘officer’, ‘gridtext’, ‘warp’, ‘flextable’, ‘ggsci’, ‘ggtext’, ‘slider’

That took about 30 minutes to make progress (Eurostar wifi was having problems downloading the packages though...)

@sje30
Copy link
Collaborator

sje30 commented Nov 27, 2024

Running the code

After installations finished, the code seemed to work, until this chunk:

22/37 [nonwear summary]   
Error in gtsummary::tbl_summary(., statistic = list(NonWear ~ "{min} - {max}"),  : 
  Error processing `label` argument.
! Can't select columns that don't exist. ✖ Column `valid_Day` doesn't exist.
ℹ Select among columns "Id", "Season", "Day", and "NonWear"
Calls: .main ... withRestartList -> withOneRestart -> docall -> do.call -> fun

Quitting from lines 421-469 [nonwear summary] (PowerCalc.qmd)
Execution halted

TO debug this, I needed to run the document using Markdown, rather than quarto (as intermediate variables are kept:

rmarkdown::render("PowerCalc.qmd")

which allowed me to at least debug; I do not understand why valid_Day is supposed to be missing from the tibble, as it seems to be there:

> Nonwear_summary %>%
+ gtsummary::tbl_summary(
+ statistic = list(NonWear ~"{min} - {max}"),
+ label = list(NonWear ~ "Non-Wear Time",
+ valid_Day ~ "Valid Days"),
+ by = valid_Day)
Error in `gtsummary::tbl_summary()`:
! Error processing `label` argument.
! Can't select columns that don't exist. ✖ Column `valid_Day` doesn't exist.
ℹ Select among columns "Id", "Season", "Day", and "NonWear"
Run `rlang::last_trace()` to see where the error occurred.

> colnames(Nonwear_summary)
[1] "Id"        "Season"    "Day"       "NonWear"   "valid_Day"

My hack to get the code working was simply to remove the 2nd element of the list from the label argument (see my code); this then allowed the code to complete.

Rendering time is just a few minutes.

Do. you understand this error @JZauner ? I can't see the reason for it.
If it helps I can send you an Rdata file containing this object?

@sje30
Copy link
Collaborator

sje30 commented Nov 27, 2024

I put the .Rda file in this repo

library(pacman)
packages <- c("quarto", "tidyverse", "broom", "cowplot", "gt", "gtsummary", 
              "gghighlight", "patchwork", "readxl", "lme4", "lmerTest",
              "ggridges", "osfr")

p_load(packages, character.only = TRUE)

load("Nonwear_summary.Rda")
Nonwear_summary %>% 
   gtsummary::tbl_summary(
     statistic = list(NonWear ~"{min} - {max}"),
     label = list(NonWear ~ "Non-Wear Time",
                  valid_Day ~ "Valid Days"),
     by = valid_Day)

@sje30
Copy link
Collaborator

sje30 commented Nov 27, 2024

Summary

figures regenerated fine. Bootstrapping differences are seen in figure 4 -- my answers are based on far fewer samples.

@mischewu
Copy link

I encountered an error on line 160 of the master script.

Running the following code:

LLdata <- import$Actiwatch_Spectrum(files[german_encoding], 
                                    locale = locale(encoding="latin1"),
                                    tz = tz, na = na_s, auto.id = auto.id,
                                    column_names = column_names)

returns the following error:

Error in `purrr::map()`:
ℹ In index: 1.
Caused by error in `detect_starting_row()`:
! Could not find a line with this order of column names in the file: '08963_MES8_1A_2015-01-13_06_00_00_Neue_Analyse.csv'.
 Please check the correct order and spelling of the given columns: 'Line.*Date.*Time.*Off Wrist.*Activity.*Marker.*White Light.*Red Light.*Green Light.*Blue Light.*Sleep Wake.*Interval Status'
Backtrace:
  1. import$Actiwatch_Spectrum(...)
  8. purrr::map(...)
  9. purrr:::map_("list", .x, .f, ..., .progress = .progress)
 13. LightLogR (local) .f(.x[[i]], ...)
 14. LightLogR:::detect_starting_row(...)
 15. base::stop(...)

@JZauner
Copy link

JZauner commented Nov 28, 2024

Hi @sje30 and @mischewu ,

thanks for the great work reproducing the results!
@sje30:
I don't know why there are troubles with the packages and I will have to look at the Rda object for the valid_Day issue.
@mischewu : The error you are encountering is due to a change in LightLogR after version 0.3.8.
As this is the version on CRAN, @sje30 did not encounter the problem. The safest way would be to change LightLogR from github install to CRAN install, specifying the version to 0.3.8:

line 36 would then change to:
packages_github <- c("steffenhartmeyer/lightdosimetry")

and then two new lines:
install.packages("LightLogR", version="0.3.8")
library(LightLogR)

It would be interesting to see whether @mischewu gets the same error regarding the valid_Day column.

@nuest nuest added the id assigned CODECHECK ID is assigned, please note when assigning new ones label Nov 28, 2024
@mischewu
Copy link

Thanks, the suggestions fixed it. It runs smoothly now, until indeed the error with the valid_day column. That is, without the workaround proposed by @sje30.

Error in `gtsummary::tbl_summary()`:
! Error processing `label` argument.
! Can't select columns that don't exist. ✖ Column `valid_Day` doesn't exist.
ℹ Select among columns "Id", "Season", "Day", and "NonWear"
Backtrace:
 1. Nonwear_summary %>% ...
 2. gtsummary::tbl_summary(...)

@nuest
Copy link
Member Author

nuest commented Nov 29, 2024

@nuest
Copy link
Member Author

nuest commented Nov 29, 2024

@sje30 Let me know when the codecheck.yml is ready and I'll render the register locally - the CI still does not work because of rate limits.

Save travels!

@sje30
Copy link
Collaborator

sje30 commented Nov 29, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community CODECHECK conducted as part of the community review process id assigned CODECHECK ID is assigned, please note when assigning new ones
Projects
None yet
Development

No branches or pull requests

4 participants