Skip to content

Commit

Permalink
Add patch changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvartan committed Oct 12, 2024
1 parent f4fb05c commit 1be76d1
Show file tree
Hide file tree
Showing 15 changed files with 622 additions and 397 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright (c) Daniel Vartanian
Copyright (c) 2024 Daniel Vartanian

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion R/_dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
# source(here::here("R", "_pre-render-revealjs.R"))
#
# quarto render
# quarto render --profile gfm
# quarto render --profile pdf
# quarto render --profile html
# quarto render --profile revealjs
# quarto publish gh-pages

# # LaTeX
#
Expand Down
22 changes: 19 additions & 3 deletions R/_post-render-end.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# library(rutils, quietly = TRUE)
# library(here, quietly = TRUE)
# library(magrittr, quietly = TRUE)
# library(rutils)
# library(here)
# library(magrittr)
# library(readr)
# library(stringr)

# Copy output to `docs` folder -----

Expand Down Expand Up @@ -64,6 +66,20 @@ for (i in seq_along(output_docs_new_files)) {
)
}

# Update `LICENSE.md` year -----

file <- here::here("LICENSE.md")

data <-
file |>
readr::read_lines() |>
stringr::str_replace_all(
pattern = "20\\d{2}",
replacement = as.character(Sys.Date() |> lubridate::year())
)

data |> readr::write_lines(file)

# Delete unnecessary files and folders -----

dir_list <-
Expand Down
11 changes: 11 additions & 0 deletions R/_post-render-gfm.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# library(beepr)
# library(groomr) # github.com/danielvartan/groomr
# library(here)

# Remove empty lines from `README.md` -----

groomr::remove_blank_line_dups(here::here("README.md"))

# Check if the script ran successfully -----

# beepr::beep(1)
8 changes: 5 additions & 3 deletions R/_pre-render-begin.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ env_vars |> yaml::write_yaml(env_vars_file_path)
quarto_yml_pdf_path <- here::here("_quarto-pdf.yml")
quarto_yml_pdf_vars <- yaml::read_yaml(quarto_yml_pdf_path)

# (2024-06-05)
# This function only works with BetterBibTeX (BBT) for Zotero version v6.7.140
# or lower.
# (2024-08-25)
# This function should work with any version of BetterBibTeX (BBT) for Zotero.
# Verify if @wmoldham PR was merged in the `rbbt` package (see issue #47
# <https://github.com/paleolimbot/rbbt/issues/47>). If not, install `rbbt`
# from @wmoldham fork `remotes::install_github("wmoldham/rbbt")`.

if (isTRUE(quarto_yml_pdf_vars$format$`abnt-pdf`$zotero)) {
rutils:::bbt_write_quarto_bib(
Expand Down
2 changes: 1 addition & 1 deletion R/test_normality.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ plot_hist <- function(x,
checkmate::assert_flag(print)

if (isTRUE(na_rm)) x <- x |> rutils:::drop_na()
y_lab <- ifelse("count", "Frequency", "Density")
y_lab <- ifelse(stat == "count", "Frequency", "Density")

plot <-
dplyr::tibble(y = x) |>
Expand Down
29 changes: 23 additions & 6 deletions R/utils-stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ std_error <- function(x){
# library(stats, quietly = TRUE)

# TODO: Move to `rutils`.
is_outlier <- function(x, method = "iqr", iqr_mult = 1.5, sd_mult = 3) {
is_outlier <- function( # Change name to `test_outlier`
x,
method = "iqr",
iqr_mult = 1.5,
sd_mult = 3
) {
checkmate::assert_numeric(x)
checkmate::assert_choice(method, c("iqr", "sd"))
checkmate::assert_number(iqr_mult)
Expand All @@ -62,11 +67,23 @@ is_outlier <- function(x, method = "iqr", iqr_mult = 1.5, sd_mult = 3) {
# library(checkmate, quietly = TRUE)

# TODO: Move to `rutils`.
remove_outliers <- function(x, method = "iqr", iqr_mult = 1.5, sd_mult = 3) {
remove_outliers <- function(
x,
method = "iqr",
iqr_mult = 1.5,
sd_mult = 3
) {
checkmate::assert_numeric(x)
checkmate::assert_choice(method, c("iqr", "sd"))
checkmate::assert_number(iqr_mult)
checkmate::assert_number(sd_mult)

x[!is_outlier(x, method = method, iqr_mult = iqr_mult, sd_mult = sd_mult)]
checkmate::assert_number(iqr_mult, lower = 1)
checkmate::assert_number(sd_mult, lower = 0)

x |>
test_outlier(
method = method,
iqr_mult = iqr_mult,
sd_mult = sd_mult
) %>%
`!`() %>%
magrittr::extract(x, .)
}
41 changes: 15 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# mastersthesis

<!-- badges: start -->

[![Project Status: WIP – Initial development is in progress, but there
has not yet been a stable, usable release suitable for the
public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![OSF
DOI](https://img.shields.io/badge/DOI-10.17605/OSF.IO/YGKTS-1284C5.svg)](https://doi.org/10.17605/OSF.IO/YGKTS)
[![License:
MIT](https://img.shields.io/badge/license-MIT-green)](https://choosealicense.com/licenses/mit/)
MIT](https://img.shields.io/badge/license-MIT-green.png)](https://choosealicense.com/licenses/mit/)
[![License: CC BY
4.0](https://img.shields.io/badge/License-CC_BY_4.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/)
<!-- badges: end -->
Expand Down Expand Up @@ -40,17 +36,14 @@ The analyses contained in this thesis are 100% reproducible. They were
made using the [R programming language](https://www.r-project.org/) and
the [Quarto](https://quarto.org/) publishing system. The
[`renv`](https://rstudio.github.io/renv/) package was used to ensure
that the R environment used can be restored (see `renv.lock`). The
that the R environment used can be restored (see `renv.lock`). All the
computational notebooks can be found in the `qmd` directory.

It’s important to note that some restrictions apply to the availability
of the main research data, which were used under the approval of a
Research Ethics Committee (REC) linked to the [Brazilian National
Research Ethics Committee
(CONEP)](https://conselho.saude.gov.br/Web_comissoes/conep/index.html).
As a result, this data cannot be publicly shared. To run the analyses,
users must have an internet connection and request a set of access keys
from the author.
of the main research data, which contain personal and sensitive
information. As a result, this data cannot be publicly shared. To run
the analyses, users must have an internet connection and request a set
of access keys from the author.

To reproduce the analyses do the following steps:

Expand All @@ -65,13 +58,12 @@ If you don’t feel comfortable with R, I strongly recommend checking
Hadley Wickham and Garrett Grolemund’s free and online book [R for Data
Science](https://r4ds.had.co.nz/) and the Coursera course from John
Hopkins University [Data Science: Foundations using
R](https://www.coursera.org/specializations/data-science-foundations-r)
(free for audit students).
R](https://www.coursera.org/specializations/data-science-foundations-r).

## License

[![License:
MIT](https://img.shields.io/badge/license-MIT-green)](https://opensource.org/license/mit/)
MIT](https://img.shields.io/badge/license-MIT-green.png)](https://opensource.org/license/mit/)
[![License: CC BY
4.0](https://img.shields.io/badge/License-CC_BY_4.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/)

Expand All @@ -80,24 +72,21 @@ license](https://opensource.org/license/mit/). Documents are released
under the [Creative Commons Attribution 4.0 International
license](https://creativecommons.org/licenses/by/4.0/).

The main research data were used under the approval of a Research Ethics
Committee (REC) linked to the [Brazilian National Research Ethics
Committee
(CONEP)](https://conselho.saude.gov.br/Web_comissoes/conep/index.html);
therefore, it cannot be publicly shared. However, it can be provided by
the author upon reasonable request. If the intention is to use the data
for new research, the request will need approval from CONEP, which must
be made with the author’s approval and participation.
The main research data contain personal and sensitive data, hence it
cannot be publicly shared. However, the data can be provided by the
author upon reasonable request.

## Citation

You can find the thesis citation below.

Vartanian, D. (2024). Is latitude associated with the regulation of circadian rhythms in humans? [Master's thesis, University of São Paulo]. https://github.com/danielvartan/mastersthesis
Vartanian, D. (2024). Is latitude associated with the regulation of
circadian rhythms in humans? \[Master’s thesis, University of São
Paulo\]. https://github.com/danielvartan/mastersthesis

A BibTeX entry for LaTeX users is

@mastersthesis{vartanian_2023,
@mastersthesis{vartanian2024,
title = {Is latitude associated with the regulation of circadian rhythms in humans?},
author = {Daniel Vartanian},
year = {2024},
Expand Down
27 changes: 5 additions & 22 deletions README.Rmd → README.qmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# mastersthesis

<!-- badges: start -->
Expand All @@ -34,9 +19,9 @@ The assemble of this repository was inspired by Ben Marwick, Carl Boettiger & Li

## How to use

The analyses contained in this thesis are 100% reproducible. They were made using the [R programming language](https://www.r-project.org/) and the [Quarto](https://quarto.org/) publishing system. The [`renv`](https://rstudio.github.io/renv/) package was used to ensure that the R environment used can be restored (see `renv.lock`). The computational notebooks can be found in the `qmd` directory.
The analyses contained in this thesis are 100% reproducible. They were made using the [R programming language](https://www.r-project.org/) and the [Quarto](https://quarto.org/) publishing system. The [`renv`](https://rstudio.github.io/renv/) package was used to ensure that the R environment used can be restored (see `renv.lock`). All the computational notebooks can be found in the `qmd` directory.

It's important to note that some restrictions apply to the availability of the main research data, which were used under the approval of a Research Ethics Committee (REC) linked to the [Brazilian National Research Ethics Committee (CONEP)](https://conselho.saude.gov.br/Web_comissoes/conep/index.html). As a result, this data cannot be publicly shared. To run the analyses, users must have an internet connection and request a set of access keys from the author.
It's important to note that some restrictions apply to the availability of the main research data, which contain personal and sensitive information. As a result, this data cannot be publicly shared. To run the analyses, users must have an internet connection and request a set of access keys from the author.

To reproduce the analyses do the following steps:

Expand All @@ -45,7 +30,7 @@ To reproduce the analyses do the following steps:
3. Run [`renv::restore()`](https://rstudio.github.io/renv//reference/restore.html) to install all software dependencies.
4. Open and run the analysis in the computational notebook.

If you don't feel comfortable with R, I strongly recommend checking Hadley Wickham and Garrett Grolemund's free and online book [R for Data Science](https://r4ds.had.co.nz/) and the Coursera course from John Hopkins University [Data Science: Foundations using R](https://www.coursera.org/specializations/data-science-foundations-r) (free for audit students).
If you don't feel comfortable with R, I strongly recommend checking Hadley Wickham and Garrett Grolemund's free and online book [R for Data Science](https://r4ds.had.co.nz/) and the Coursera course from John Hopkins University [Data Science: Foundations using R](https://www.coursera.org/specializations/data-science-foundations-r).

## License

Expand All @@ -55,20 +40,18 @@ MIT](https://img.shields.io/badge/license-MIT-green)](https://opensource.org/lic

Code related to this repository is released under the [MIT license](https://opensource.org/license/mit/). Documents are released under the [Creative Commons Attribution 4.0 International license](https://creativecommons.org/licenses/by/4.0/).

The main research data were used under the approval of a Research Ethics Committee (REC) linked to the [Brazilian National Research Ethics Committee (CONEP)](https://conselho.saude.gov.br/Web_comissoes/conep/index.html); therefore, it cannot be publicly shared. However, it can be provided by the author upon reasonable request. If the intention is to use the data for new research, the request will need approval from CONEP, which must be made with the author's approval and participation.
The main research data contain personal and sensitive data, hence it cannot be publicly shared. However, the data can be provided by the author upon reasonable request.

## Citation

You can find the thesis citation below.

```
Vartanian, D. (2024). Is latitude associated with the regulation of circadian rhythms in humans? [Master's thesis, University of São Paulo]. https://github.com/danielvartan/mastersthesis
```

A BibTeX entry for LaTeX users is

```
@mastersthesis{vartanian_2023,
@mastersthesis{vartanian2024,
title = {Is latitude associated with the regulation of circadian rhythms in humans?},
author = {Daniel Vartanian},
year = {2024},
Expand Down
6 changes: 6 additions & 0 deletions _quarto-gfm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
project:
output-dir: "."
render: [README.qmd]
post-render: "R/_post-render-gfm.R"

format: gfm
8 changes: 4 additions & 4 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ execute:

profile:
group:
- [html, pdf, revealjs]
- [gfm, html, pdf, revealjs]
default: pdf

book:
title: "Is latitude associated with human circadian rhythms?"
author: "Daniel Vartanian"
keyword: >
Chronobiology. Biological rhythms. Chronotype. Circadian phenotype. Sleep.
Complex systems. Entrainment. Latitude. MCTQ.
chronobiology. biological rhythms. chronotype. circadian phenotype. sleep.
complex systems. entrainment. latitude. mctq.
language: en-us
license: "Creative Commons Attribution 4.0 International (CC BY 4.0)"
publisher: "University of São Paulo"
publisher-place: "São Paulo, SP, Brazil"
submitted: 2023
submitted: 2024
url: https://danielvartan.github.io/mastersthesis/
site-url: https://danielvartan.github.io/mastersthesis/
repo-url: https://github.com/danielvartan/mastersthesis/
Expand Down
2 changes: 1 addition & 1 deletion qmd/appendice-chapter-4.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rutils:::quarto_status(
)
```

## Data wrangling
## Data munging

The data wrangling processes were performed using the [`targets`](https://github.com/ropensci/targets) R package. The full pipeline can be seen in the `_targets.R` file at the root of the [research compendium](https://github.com/danielvartan/mastersthesis).

Expand Down
14 changes: 5 additions & 9 deletions qmd/appendice-chapter-6.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ lubritime:::link_to_timeline(data) |>

See [`targets` R package manual](https://books.ropensci.org/targets/walkthrough.html).

### Data wrangling
### Data munging

```{r}
#| label: data-preparation
Expand Down Expand Up @@ -390,6 +390,8 @@ $$
```{r}
#| code-fold: false
# recipes::step_BoxCox()
lambda <- box_cox$x[which.max(box_cox$y)]
sprintf("%.50f", lambda) # Only ~16 digit precision
Expand Down Expand Up @@ -542,15 +544,9 @@ source(here::here("R/test_normality.R"))
# res_model |> olsrr::ols_plot_resid_qq()
qq_plot <- res_model |>
stats::residuals() |>
plot_qq(print = FALSE)
hist_plot <- res_model |>
res_model |>
stats::residuals() |>
plot_hist(print = FALSE)
cowplot::plot_grid(hist_plot, qq_plot, ncol = 2, nrow = 1)
test_normality()
```

[Source: Created by the author.]{.legend}
Expand Down
Loading

0 comments on commit 1be76d1

Please sign in to comment.