Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danielvartan/actverse
🏃♀️ Tools for actigraphy data analysis
https://github.com/danielvartan/actverse
actigraphy chronobiology r r-package rstats sleep
Last synced: about 1 month ago
JSON representation
🏃♀️ Tools for actigraphy data analysis
- Host: GitHub
- URL: https://github.com/danielvartan/actverse
- Owner: danielvartan
- License: other
- Created: 2020-09-24T16:28:54.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-26T04:34:07.000Z (about 1 year ago)
- Last Synced: 2024-06-09T10:01:02.068Z (7 months ago)
- Topics: actigraphy, chronobiology, r, r-package, rstats, sleep
- Language: R
- Homepage: https://danielvartan.github.io/actverse/
- Size: 2.34 MB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 21
-
Metadata Files:
- Readme: README.Rmd
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: CITATION.cff
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)library(actverse)
library(dplyr)
library(lubridate)
library(hms)
```# actverse
[![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)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![R-CMD-check](https://github.com/giperbio/actverse/workflows/R-CMD-check/badge.svg)](https://github.com/giperbio/actverse/actions)
[![Codecov test coverage](https://codecov.io/gh/giperbio/actverse/branch/main/graph/badge.svg)](https://app.codecov.io/gh/giperbio/actverse?branch=main)
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://choosealicense.com/licenses/mit/)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](https://giperbio.github.io/actverse/CODE_OF_CONDUCT.html)## Overview
`actverse` is an R package that provides a complete toolkit to process, analyze and visualize actigraphy data. Its aim is to facilitate the work of sleep and chronobiology scientists with actigraphy data and to improve reproducibility in research.
`actverse` adheres to the [tidyverse principles](https://tidyverse.tidyverse.org/articles/manifesto.html) and integrates with the [tidyverse ecosystem](https://www.tidyverse.org/).
## Prerequisites
You need to have some familiarity with the [R programming language](https://www.r-project.org/) and with the [`tsibble`](https://tsibble.tidyverts.org/index.html) package to use `actverse` main functions.
If you don't feel comfortable with R, we 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).
Please refer to the [`tsibble`](https://tsibble.tidyverts.org/index.html) package documentation to learn more about it. `tsibble` is an essential package to deal with time series in R. We also recommend that you read the [Dates and times](https://r4ds.had.co.nz/dates-and-times.html) chapter from Wickham & Grolemund's book [R for Data Science](https://r4ds.had.co.nz/) and the [tsibble objects](https://otexts.com/fpp3/tsibbles.html) subchapter from Rob J. Hyndman & George Athanasopoulos' book [Forecasting: Principles and Practice](https://otexts.com/fpp3/).
## Installation
You can install `actverse` with:
``` {r, eval = FALSE}
# install.packages("remotes")
remotes::install_github("giperbio/actverse")
```## Usage
The R ecosystem has a [vast number](https://cran.r-project.org/view=TimeSeries) of time series standards and we had to choose one of them while developing `actverse`. A standard for time objects is a must, because [time can have many representations](https://youtu.be/eelVqfm8vVc) and can be rooted in different numerical systems. We believe that the best time series standard available for packages that adheres to the [tidyverse principles](https://tidyverse.tidyverse.org/articles/manifesto.html) is the [`tsibble`](https://tsibble.tidyverts.org/index.html). As the name suggests, `tsibble` is an adaptation for time series of the [tidyverse](https://www.tidyverse.org/) [`tibble`](https://tibble.tidyverse.org/) object.
Most `actverse` functions will require that your data be in the [`tsibble`](https://tsibble.tidyverts.org/index.html) standard. Adapting your data is a simple process and can make a big difference when dealing with time series in R. Please refer to [`tsibble`](https://tsibble.tidyverts.org/index.html) documentation to learn how to do this.
We also recommend seeing the [`tsbox`](https://www.tsbox.help/) package, an R
package that propose to be an "universal translator" (🖖) for R time series standards.### Read/Write
* `read_acttrust()`: Read, tidy, and validate an [ActTrust](https://condorinst.com/en/acttrust-actigraph/) file.
* `write_acttrust()`: Adapt and write a `tsibble` to a readable [ActTrust](https://condorinst.com/en/acttrust-actigraph/) file.Example:
```{r message = FALSE, warning = FALSE}
file <- get_from_zenodo(
doi = "10.5281/zenodo.4898822", path = tempdir(),
file = "processed.txt"
)data <- read_acttrust(file, tz = "America/Sao_Paulo")
data
```### Period functions
* `periodogram()`: Compute Sokolove & Bushell's $\chi^{2}$ periodogram.
* `spectrogram()`: Compute a spectrogram based on Sokolove & Bushell's periodogram.Example:
```{r message = FALSE, warning = FALSE}
per <- periodogram(data, "pim")spec <- spectrogram(data, "pim")
```### Data interpolation
* `na_approx()` `na_locf()` `na_overall_mean()` `na_overall_median()` `na_overall_mode()` `na_spline()` `na_weekly_mean()` `na_zero()` `na_plot()`: Replace `NA` by interpolation.
Example:
```{r message = FALSE, warning = FALSE}
x <- c(NA, 1, 5, 10, NA, 5, 10, 1, NA, 10, 1, 5, NA, NA)
index <- seq(as.Date("2020-01-01"), as.Date("2020-01-14"), by = "day")na_approx(x, index, fill_na_tips = TRUE)
na_plot(x, index, na_approx(x, index, fill_na_tips = TRUE))
```### API clients
* `get_from_zenodo()`: Get data from a Zenodo record.
* `get_sun_stats()`: Get sun related statistics from different APIs.Example:
```{r message = FALSE, warning = FALSE}
get_sun_stats(lat = -23.5489, lon = -46.6388, tz = "America/Sao_Paulo") %>%
dplyr::as_tibble() %>%
t()
```### Other features
`actverse` also comes with many utility functions and provides free actigraphy datasets for testing and learning purposes.
All functions are properly documented, showing all the guidelines behind the computations. Click [here](https://giperbio.github.io/actverse/) to see a list of them.
Example:
```{r message = FALSE, warning = FALSE}
# Find the epochs/periodicities in a 'tsibble'
read_acttrust(file, regularize = FALSE) %>%
find_epoch()
```## Citation
If you use `actverse` in your research, please consider citing it. We put a lot of work to build and maintain a free and open-source R package. You can find the citation below.
```{r}
citation("actverse")
```## Contributing
We welcome contributions, including bug reports.
Take a moment to review our [Guidelines for Contributing](https://giperbio.github.io/actverse/CONTRIBUTING.html).
## Acknowledgments
The initial development of `actverse` was supported by three scholarships provided by the [University of Sao Paulo (USP)](http://usp.br/) (❤️).
Become an `actverse` supporter!
Click [here](https://github.com/sponsors/danielvartan) to make a donation. Please indicate the `actverse` package in your donation message.