Learn R Programming

readme

digiRhythm

digiRhythm is an R library developed at Agroscope and provides a set of tools to analyze and visualize the rhythmic behavior of animals. It mainly focuses on the Degree of Functional Coupling (0 < DFC < 1), a measure used by several scientists to assess the welfare of animals. The library also provides tools to compute the diurnality index, to visualize the actogram and the average activity.

This repository contains the most updated version of the library, while the CRAN package and its vignettes could be found at CRAN.

The library is still under development and we are working on adding more functionalities to it. If you have any suggestions or you want to contribute to the library, please feel free to contact us. Email: hassan-roland.nasser@agroscope.admin.ch or hassan.nasser@me.com

Installation

You can install the development version from GitHub with:

#Uncomment the below two lines if you use the library for the first time of if
#you want to update the library
#install.packages("devtools")
#devtools::install_github("nasserdr/digiRhythm", dependencies = TRUE)

Examples:

You can access few examples from the vignettes provided along with the package, either on the package website or from the Vignettes:

Website Vignettes

Copy Link

Version

Install

install.packages('digiRhythm')

Monthly Downloads

240

Version

2.4

License

GPL-3

Maintainer

Hassan Roland Nasser

Last Published

December 19th, 2024

Functions in digiRhythm (2.4)

timedata

timedata Dataset of start and end of day and night
levopt

Returns the level given the p-value computed with pbaluev (2008). Copied from the LOMB library.
lomb_scargle_periodogram

Computes the Lomb Scargle Periodogram and returns the information needed for computing the DFC and HP. A plot visualizing the Harmonic Frequencies presence in the spectrum is possible. The function is inspired from the Lomb library in a great part, with modifications to fit the requirements of harmonic powers and computation of the DFC. This function is inspired by the lsp function from the lomb package and adapted to add different colors for harmonic and non harmonic frequencies in the signal. For more information about lomb::lsp, please refer to: https://cran.r-project.org/web/packages/lomb/
print_v

Print if Verbose is true
pbaluev

Returns p-value of a frequency peak according to pbaluev (2008) given Z, fmax and tm. Reused from the LOMB library (https://rdrr.io/cran/lomb/)
remove_activity_outliers

Remove outliers from the data
resample_dgm

Change the sampling of a digiRhythm friendly dataset
df759a_3

df759a_3 Activity Data Sets
actogram

Plot a an single actogram over a period of time for a specific variable
daily_activity_wrap_plot

Plot daily average over a period of time for a specific variable.
daily_average_activity

Plot daily average over a period of time for a specific variable.
diurnality_customTimes

Computes the diurnality index, using different start and end definitions for each day and night, based on an activity dataframe
highest_possible_harm_cutoff

Function to calculate the smallest possible harmonic to consider given a sampling frequency. The minimum possible harmonic = 2 x the period of the maximum frequency according to the Shanon theorem. Example: if the sampling period is 15 min, the minimum possible treatable period is 30 minutes and that corresponds to the 48th harmonic (24 hours * 60 minutes / 48 = 30 minutes)
dgm_periodicity

Returns the periodicity of a digiRhythm dataframe
diurnality

Computes the diurnality index based on an activity dataframe
is_dgm_friendly

Informs if a dataset is digiRhythm Friendly
import_raw_activity_data

Reads Raw Activity Data from csv files
df689b_3

df689b_3 Activity Data Sets
df678_2

df678_2 Activity Data Sets
df625

df625 Activity Data Sets
df516b_2

df516b_2 Activity Data Sets
df691b_1

df691b_1 Activity Data Sets
df603

df603 Activity Data Sets
dfc

Computes the Degree of Function coupling (DFC), Harmonic Part (HP) and Weekly Lomb-Scargle Spectrum (LSP Spec) for one variable in an activity dataset. The dataset should be digiRhythm friendly.
df_act_info

Outputs some information about the activity dataframe