circadian


Namecircadian JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/Arcascope/circadian
SummaryTools for the simulation and analysis of circadian rhythms
upload_time2023-07-26 14:13:53
maintainer
docs_urlNone
authorArcascope Inc.
requires_python>=3.7
licenseApache Software License 2.0
keywords nbdev jupyter notebook python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Circadian

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://arcascope.github.io/circadian/)
![CI](https://github.com/Arcascope/circadian/actions/workflows/test.yaml/badge.svg)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/arcascope.svg?style=social&label=Follow%20%40arcascope)](https://twitter.com/arcascope)

Welcome to `circadian`, a computational package for the simulation and
analysis of circadian rhythms

## Install

`circadian` can be installed via `pip`:

``` sh
pip install circadian
```

## Overview

The `circadian` package implements key mathematical models in the field
such as:

- [`Forger99`](https://arcascope.github.io/circadian/api/models.html#forger99) -
  [Forger et al. (1999)](https://doi.org/10.1177/074873099129000867)
- [`Hannay19`](https://arcascope.github.io/circadian/api/models.html#hannay19)
  and
  [`Hannay19TP`](https://arcascope.github.io/circadian/api/models.html#hannay19tp) -
  [Hannay et al. (2019)](https://doi.org/10.1177/0748730419878298)
- [`Jewett99`](https://arcascope.github.io/circadian/api/models.html#jewett99) -
  [Kronauer et al. (1999)](https://doi.org/10.1177/074873049901400608)

See all the available models at
[circadian/models.py](https://github.com/Arcascope/circadian/blob/main/circadian/models.py)

Additionally, `circadian` provides a set of tools for simulating and
analzying circadian rhythms:

- Define light schedules using the `Light` class and feed directly into
  the models
- Calculate phase response curves using the
  [`PRCFinder`](https://arcascope.github.io/circadian/api/prc.html#prcfinder)
  class
- Generate actograms and phase plots with the `circadian.plots` module

Finally, the package streamlines the process of reading, processing, and
analyzing wereable data via the `circadian.readers` module.

Check out the [documentation](https://arcascope.github.io/circadian/)
for a full overview of the package and its features.

## Example

The code below shows how to simulate the circadian rhythm of a shift
worker for four different models and visualize the results in an
actogram plot

``` python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.lines as lines
from circadian.plots import Actogram
from circadian.lights import LightSchedule
from circadian.models import Forger99, Jewett99, Hannay19, Hannay19TP

days_night = 3
days_day = 2
slam_shift = LightSchedule.ShiftWork(lux=300.0, days_on=days_night, days_off=days_day)

total_days = 30
time = np.arange(0, 24*total_days, 0.10)
light_values = slam_shift(time)

f_model = Forger99()
kj_model = Jewett99()
spm_model = Hannay19()
tpm_model = Hannay19TP()

equilibration_reps = 2
initial_conditions_forger = f_model.equilibrate(time, light_values, equilibration_reps)
initial_conditions_kj = kj_model.equilibrate(time, light_values, equilibration_reps)
initial_conditions_spm = spm_model.equilibrate(time, light_values, equilibration_reps)
initial_conditions_tpm = tpm_model.equilibrate(time, light_values, equilibration_reps)
```

The models are integrated using an explicit Runge-Kutta 4 (RK4) scheme

``` python
trajectory_f = f_model(time, initial_conditions_forger, light_values)
trajectory_kj = kj_model(time, initial_conditions_kj, light_values)
trajectory_spm = spm_model(time, initial_conditions_spm, light_values)
trajectory_tpm = tpm_model(time, initial_conditions_tpm, light_values)
```

The Dim Light Melatonin Onset (DLMO), an experimental measurement of
circadian phase, is calculated for each model by

``` python
dlmo_f = f_model.dlmos()
dlmo_kj = kj_model.dlmos()
dlmo_spm = spm_model.dlmos()
dlmo_tpm = tpm_model.dlmos()
```

Lastly, the results of the simulation–DLMOs included– are visualized in
an
[`Actogram`](https://arcascope.github.io/circadian/api/plots.html#actogram)
plot from the `circadian.plots` module

``` python
acto = Actogram(time, light_vals=light_values, opacity=1.0, smooth=False)
acto.plot_phasemarker(dlmo_f, color='blue')
acto.plot_phasemarker(dlmo_spm, color='darkgreen')
acto.plot_phasemarker(dlmo_tpm, color='red')
acto.plot_phasemarker(dlmo_kj, color='purple')
# legend
blue_line = lines.Line2D([], [], color='blue', label='Forger99')
green_line = lines.Line2D([], [], color='darkgreen', label='Hannay19')
red_line = lines.Line2D([], [], color='red', label='Hannay19TP')
purple_line = lines.Line2D([], [], color='purple', label='Jewett99')

plt.legend(handles=[blue_line, purple_line, green_line, red_line], 
           loc='upper center', bbox_to_anchor=(0.5, 1.12), ncol=4)
plt.title("Actogram for a Simulated Shift Worker", pad=35)
plt.tight_layout()
plt.show()
```

![](index_files/figure-commonmark/cell-5-output-1.png)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Arcascope/circadian",
    "name": "circadian",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "nbdev jupyter notebook python",
    "author": "Arcascope Inc.",
    "author_email": "support@arcascope.com",
    "download_url": "https://files.pythonhosted.org/packages/cf/de/311f30f155948d2776ef1b3aaf46036fe8802f52d0df5274f39a96be2216/circadian-1.0.0.tar.gz",
    "platform": null,
    "description": "# Circadian\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://arcascope.github.io/circadian/)\n![CI](https://github.com/Arcascope/circadian/actions/workflows/test.yaml/badge.svg)\n[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/arcascope.svg?style=social&label=Follow%20%40arcascope)](https://twitter.com/arcascope)\n\nWelcome to `circadian`, a computational package for the simulation and\nanalysis of circadian rhythms\n\n## Install\n\n`circadian` can be installed via `pip`:\n\n``` sh\npip install circadian\n```\n\n## Overview\n\nThe `circadian` package implements key mathematical models in the field\nsuch as:\n\n- [`Forger99`](https://arcascope.github.io/circadian/api/models.html#forger99) -\n  [Forger et al.\u00a0(1999)](https://doi.org/10.1177/074873099129000867)\n- [`Hannay19`](https://arcascope.github.io/circadian/api/models.html#hannay19)\n  and\n  [`Hannay19TP`](https://arcascope.github.io/circadian/api/models.html#hannay19tp) -\n  [Hannay et al.\u00a0(2019)](https://doi.org/10.1177/0748730419878298)\n- [`Jewett99`](https://arcascope.github.io/circadian/api/models.html#jewett99) -\n  [Kronauer et al.\u00a0(1999)](https://doi.org/10.1177/074873049901400608)\n\nSee all the available models at\n[circadian/models.py](https://github.com/Arcascope/circadian/blob/main/circadian/models.py)\n\nAdditionally, `circadian` provides a set of tools for simulating and\nanalzying circadian rhythms:\n\n- Define light schedules using the `Light` class and feed directly into\n  the models\n- Calculate phase response curves using the\n  [`PRCFinder`](https://arcascope.github.io/circadian/api/prc.html#prcfinder)\n  class\n- Generate actograms and phase plots with the `circadian.plots` module\n\nFinally, the package streamlines the process of reading, processing, and\nanalyzing wereable data via the `circadian.readers` module.\n\nCheck out the [documentation](https://arcascope.github.io/circadian/)\nfor a full overview of the package and its features.\n\n## Example\n\nThe code below shows how to simulate the circadian rhythm of a shift\nworker for four different models and visualize the results in an\nactogram plot\n\n``` python\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.lines as lines\nfrom circadian.plots import Actogram\nfrom circadian.lights import LightSchedule\nfrom circadian.models import Forger99, Jewett99, Hannay19, Hannay19TP\n\ndays_night = 3\ndays_day = 2\nslam_shift = LightSchedule.ShiftWork(lux=300.0, days_on=days_night, days_off=days_day)\n\ntotal_days = 30\ntime = np.arange(0, 24*total_days, 0.10)\nlight_values = slam_shift(time)\n\nf_model = Forger99()\nkj_model = Jewett99()\nspm_model = Hannay19()\ntpm_model = Hannay19TP()\n\nequilibration_reps = 2\ninitial_conditions_forger = f_model.equilibrate(time, light_values, equilibration_reps)\ninitial_conditions_kj = kj_model.equilibrate(time, light_values, equilibration_reps)\ninitial_conditions_spm = spm_model.equilibrate(time, light_values, equilibration_reps)\ninitial_conditions_tpm = tpm_model.equilibrate(time, light_values, equilibration_reps)\n```\n\nThe models are integrated using an explicit Runge-Kutta 4 (RK4) scheme\n\n``` python\ntrajectory_f = f_model(time, initial_conditions_forger, light_values)\ntrajectory_kj = kj_model(time, initial_conditions_kj, light_values)\ntrajectory_spm = spm_model(time, initial_conditions_spm, light_values)\ntrajectory_tpm = tpm_model(time, initial_conditions_tpm, light_values)\n```\n\nThe Dim Light Melatonin Onset (DLMO), an experimental measurement of\ncircadian phase, is calculated for each model by\n\n``` python\ndlmo_f = f_model.dlmos()\ndlmo_kj = kj_model.dlmos()\ndlmo_spm = spm_model.dlmos()\ndlmo_tpm = tpm_model.dlmos()\n```\n\nLastly, the results of the simulation\u2013DLMOs included\u2013 are visualized in\nan\n[`Actogram`](https://arcascope.github.io/circadian/api/plots.html#actogram)\nplot from the `circadian.plots` module\n\n``` python\nacto = Actogram(time, light_vals=light_values, opacity=1.0, smooth=False)\nacto.plot_phasemarker(dlmo_f, color='blue')\nacto.plot_phasemarker(dlmo_spm, color='darkgreen')\nacto.plot_phasemarker(dlmo_tpm, color='red')\nacto.plot_phasemarker(dlmo_kj, color='purple')\n# legend\nblue_line = lines.Line2D([], [], color='blue', label='Forger99')\ngreen_line = lines.Line2D([], [], color='darkgreen', label='Hannay19')\nred_line = lines.Line2D([], [], color='red', label='Hannay19TP')\npurple_line = lines.Line2D([], [], color='purple', label='Jewett99')\n\nplt.legend(handles=[blue_line, purple_line, green_line, red_line], \n           loc='upper center', bbox_to_anchor=(0.5, 1.12), ncol=4)\nplt.title(\"Actogram for a Simulated Shift Worker\", pad=35)\nplt.tight_layout()\nplt.show()\n```\n\n![](index_files/figure-commonmark/cell-5-output-1.png)\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Tools for the simulation and analysis of circadian rhythms",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/Arcascope/circadian"
    },
    "split_keywords": [
        "nbdev",
        "jupyter",
        "notebook",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47c938e4c825a0a79b98c2511c675e7e64d212db4f4f90d4cad8683f01adcd50",
                "md5": "fbc137546c7700c0425c9338a2c0da10",
                "sha256": "61cab926f34c3a620428b8730c7bc22be2e5ef90155c3259c4826d76293bbb52"
            },
            "downloads": -1,
            "filename": "circadian-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fbc137546c7700c0425c9338a2c0da10",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 42883,
            "upload_time": "2023-07-26T14:13:51",
            "upload_time_iso_8601": "2023-07-26T14:13:51.952871Z",
            "url": "https://files.pythonhosted.org/packages/47/c9/38e4c825a0a79b98c2511c675e7e64d212db4f4f90d4cad8683f01adcd50/circadian-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cfde311f30f155948d2776ef1b3aaf46036fe8802f52d0df5274f39a96be2216",
                "md5": "d3664330552807cfd4b1983366f98001",
                "sha256": "bb448e34e94585fff4c5772b6916f9f9bda3c513bc64e70ecdaafc1a517cbbeb"
            },
            "downloads": -1,
            "filename": "circadian-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d3664330552807cfd4b1983366f98001",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 42085,
            "upload_time": "2023-07-26T14:13:53",
            "upload_time_iso_8601": "2023-07-26T14:13:53.647225Z",
            "url": "https://files.pythonhosted.org/packages/cf/de/311f30f155948d2776ef1b3aaf46036fe8802f52d0df5274f39a96be2216/circadian-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-26 14:13:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Arcascope",
    "github_project": "circadian",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "circadian"
}
        
Elapsed time: 0.23010s