Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

🏃‍♀️ Actigraphy Data Analysis in R

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

danielvartan/actverse

Repository files navigation

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.Lifecycle: experimentalR-CMD-checkCodecov test coverageLicense: MITContributor Covenant

Overview

actverse is an R package that provides a complete toolkit to process,analyze and visualize actigraphy data. Its aim is to facilitate the workof sleep and chronobiology scientists with actigraphy data and toimprove reproducibility in research.

actverse adheres to thetidyverseprinciples andintegrates with thetidyverse ecosystem.

Prerequisites

You need to have some familiarity with theR programminglanguage and with thetsibble package to useactverse main functions.

If you don’t feel comfortable with R, we strongly recommend checkingHadley Wickham and Garrett Grolemund’s free and online bookR for DataScience and the Coursera course from JohnHopkins UniversityData Science: Foundations usingR(free for audit students).

Please refer to thetsibble packagedocumentation to learn more about it.tsibble is an essential packageto deal with time series in R. We also recommend that you read theDates and times chapterfrom Wickham & Grolemund’s bookR for DataScience and thetsibbleobjects subchapter from Rob J.Hyndman & George Athanasopoulos’ bookForecasting: Principles andPractice.

Installation

You can installactverse with:

# install.packages("remotes")remotes::install_github("giperbio/actverse")

Usage

The R ecosystem has avastnumber of time seriesstandards and we had to choose one of them while developingactverse.A standard for time objects is a must, becausetime can have manyrepresentations and can be rooted indifferent numerical systems. We believe that the best time seriesstandard available for packages that adheres to thetidyverseprinciples isthetsibble. As the namesuggests,tsibble is an adaptation for time series of thetidyversetibble object.

Mostactverse functions will require that your data be in thetsibble standard. Adaptingyour data is a simple process and can make a big difference when dealingwith time series in R. Please refer totsibble documentation tolearn how to do this.

We also recommend seeing thetsbox package,an R package that propose to be an “universal translator” (🖖) for Rtime series standards.

Read/Write

  • read_acttrust(): Read, tidy, and validate anActTrust file.
  • write_acttrust(): Adapt and write atsibble to a readableActTrust file.

Example:

file<- get_from_zenodo(doi="10.5281/zenodo.4898822",path= tempdir(),file="processed.txt")data<- read_acttrust(file,tz="America/Sao_Paulo")data#> # A tsibble: 51,806 x 17 [1m] <America/Sao_Paulo>#>    timestamp             pim   tat   zcm orienta…¹ wrist…² exter…³ light ambie…⁴#>    <dttm>              <dbl> <dbl> <dbl>     <dbl>   <dbl>   <dbl> <dbl>   <dbl>#>  1 2021-04-24 04:14:00  7815   608   228         0    26.9    24.6  3.58    1.45#>  2 2021-04-24 04:15:00  2661   160    64         0    27.2    25.1  5.23    2.12#>  3 2021-04-24 04:16:00  3402   243    80         0    27.7    25.5  3.93    1.59#>  4 2021-04-24 04:17:00  4580   317   125         0    27.9    25.8  4.14    1.68#>  5 2021-04-24 04:18:00  2624   255    33         0    28.0    25.9  3.16    1.28#>  6 2021-04-24 04:19:00  3929   246   105         0    28.1    26.1  3.63    1.47#>  7 2021-04-24 04:20:00  5812   369   171         0    28.2    26.4 11.5     4.67#>  8 2021-04-24 04:21:00  3182   270    54         0    28.4    26.7  2.4     0.97#>  9 2021-04-24 04:22:00  6362   373   189         0    28.6    26.9  3.28    1.33#> 10 2021-04-24 04:23:00  2621   159    64         0    28.7    27.1  2.97    1.2#> # … with 51,796 more rows, 8 more variables: red_light <dbl>,#> #   green_light <dbl>, blue_light <dbl>, ir_light <dbl>, uva_light <dbl>,#> #   uvb_light <dbl>, event <dbl>, state <dbl>, and abbreviated variable names#> #   ¹​orientation, ²​wrist_temperature, ³​external_temperature, ⁴​ambient_light

Period functions

  • periodogram(): Compute Sokolove & Bushell’s$\chi^{2}$ periodogram.
  • spectrogram(): Compute a spectrogram based on Sokolove & Bushell’speriodogram.

Example:

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(): ReplaceNA by interpolation.

Example:

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)#>  [1]  1.0  1.0  5.0 10.0  7.5  5.0 10.0  1.0  5.5 10.0  1.0  5.0  5.0  5.0na_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:

get_sun_stats(lat=-23.5489,lon=-46.6388,tz="America/Sao_Paulo") %>%dplyr::as_tibble() %>%     t()#>                   [,1]#> date              "2023-02-23"#> lat               "-23.5489"#> lon               "-46.6388"#> tz                "America/Sao_Paulo"#> sunrise_start     "06:00:15"#> sunrise_end       "06:02:37"#> golden_hour_end   "06:30:30"#> solar_noon        "12:21:26"#> golden_hour_start "18:12:22"#> sunset_start      "18:40:15"#> sunset_end        "18:42:37"#> dusk              "19:05:42"#> nautical_dusk     "19:32:49"#> night_start       "20:00:22"#> nadir             "00:21:26"#> night_end         "04:42:30"#> nautical_dawn     "05:10:04"#> dawn              "05:37:10"

Other features

actverse also comes with many utility functions and provides freeactigraphy datasets for testing and learning purposes.

All functions are properly documented, showing all the guidelines behindthe computations. Clickhere tosee a list of them.

Example:

# Find the epochs/periodicities in a 'tsibble'read_acttrust(file,regularize=FALSE) %>%    find_epoch()#> $best_match#> [1] 60#>#> $prevalence#> # A tibble: 4 × 2#>   epoch proportion#>   <dbl>      <dbl>#> 1    60  1.00#> 2    94  0.0000193#> 3    86  0.0000193#> 4   101  0.0000193

Citation

If you useactverse in your research, please consider citing it. Weput a lot of work to build and maintain a free and open-source Rpackage. You can find the citation below.

citation("actverse")#>#> To cite {actverse} in publications use:#>#>   Vartanian, D., Matias, V. A., Serrano, C. A. M., & Benedito-Silva, A.#>   A. (2023). {actverse}: tools for actigraphy data analysis. R package#>   version 0.0.0.9000. https://giperbio.github.io/actverse/#>#> A BibTeX entry for LaTeX users is#>#>   @Unpublished{,#>     title = {{actverse}: tools for actigraphy data analysis},#>     author = {Daniel Vartanian and Vinicius {Alves Matias} and Cassio {Almeida Mattos Serrano} and Ana Amelia Benedito-Silva},#>     year = {2023},#>     url = {https://giperbio.github.io/actverse/},#>     note = {R package version 0.0.0.9000},#>   }

Contributing

We welcome contributions, including bug reports.

Take a moment to review ourGuidelines forContributing.

Acknowledgments

The initial development ofactverse was supported by threescholarships provided by theUniversity of Sao Paulo(USP) (❤️).


Become anactverse supporter!

Clickhere to make adonation. Please indicate theactverse package in your donationmessage.

About

🏃‍♀️ Actigraphy Data Analysis in R

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Languages


[8]ページ先頭

©2009-2025 Movatter.jp