Skip to main content

A simplified package for cosinor analysis of circadian bioluminescent, fluorescent and omics datasets

Project description

cosinor-lite

cosinor-lite is a lightweight toolkit for exploring circadian oscillations across multiomics and live-cell imaging experiments. It relies on widely used statistical models and offers two modes of use.

  • Interactive Gradio dashboard to drag & drop your data files.
  • Python package for fine-grained customisation beyond the settings offered in the Gradio UI.

🚀 Try the interactive analysis pipeline on Hugging Face Spaces → cosinor-lite.

Why cosinor-lite?

  • Unified workflow for live cell data: Perform detrending and fit cosinor models with either a fixed 24 h, free-period or damped oscillation with consistent APIs across data modalities (i.e. bioluminescence, cytokines, qPCR etc.).
  • Differential rhythmicity across any omics type: Compare two conditions for differential rhythmicity for any type of omics data using BIC model-selection strategies with widespread use in the circadian literature.
  • Create publication-ready analysis with a simple UI: Launch a browser-based analysis console for visual quality control, plots, and parameter export.

Extracting circadian parameters from live-cell data

For live-cell data (see tutorial in notebooks/live_cell_tutorial), cosinor-lite offers the choice between three different cosinor models:

  • a) Fixed 24-h period

  • b) Free period

  • c) Free period with damped amplitude

Model selection

Once a model is chosen, it is fitted independently to each sample. The fitted parameters can be exported for downstream statistical analysis.

Differential rhytmicity analysis of omics datasets

cosinor-lite includes a toolbox for performing differential rhytmicity analysis of omics datasets (ee notebooks/omics_tutorial) for tutorial. The details of the method are nicely explained in the article:

Pelikan A, Herzel H, Kramer A, Ananthasubramaniam B. 2022. Venn diagram analysis overestimates the extent of circadian rhythm reprogramming. The FEBS Journal 289:6605–6621. doi:10.1111/febs.16095

Here is an adaptation of their figure explaining the methdology:

Model selection

The tool is very similar to the dryR package in R, but implemented in Python for ease of use with other Python-based data analysis pipelines. Please see the dryR tool for more details, and if you prefer implementing in R (https://github.com/naef-lab/dryR/tree/master).

For condition 1 (i.e. alpha cells) and condition 2 (i.e. beta cells), we fit 5 different models:

  • Model 1) Arrhythmic in alpha and beta cells

  • Model 2) Rhythmic in beta cells only

  • Model 3) Rhythmic in alpha cells only

  • Model 4) Rhythmic in alpha and beta cells with the same rhythmic parameters (i.e. phase and amplitude)

  • Model 5) Rhythmic in both but with differential rhythmicity in alpha vs beta cells

Installation

# clone the repository
git clone https://github.com/nick-e-p/cosinor-lite.git
cd cosinor-lite

# create and populate the local uv environment
uv sync

# activate the environment
source .venv/bin/activate

Quick Start

Launch the interactive app

uv run python app.py

Open the printed local URL to explore:

  • Live cell: Upload CSVs with participant, replicate, and time-series data, then compare detrending strategies or cosinor fits across groups.
  • Omics: Load expression matrices, build time vectors automatically or manually, compute differential rhythmicity, and download publication-ready plots.

Use the Python API

from cosinor_lite.livecell_dataset import LiveCellDataset
from cosinor_lite.livecell_cosinor_analysis import CosinorAnalysis

dataset = LiveCellDataset(
    ids=["mouse_a", "mouse_b"],
    group=["treated", "control"],
    replicate=[1, 1],
    time_series=my_expression_matrix,
    time=my_timepoints,
)

analysis = CosinorAnalysis(dataset=dataset)
fit = analysis.fit(group="treated", model="damped")
print(fit.parameters)

Sample Datasets

The data/ directory includes curated examples to help you get started:

  • bioluminescence_example.csv: Bioluminescence time series for live-cell analysis.
  • cytokine_example.csv: Cytokine time series for live-cell analysis.
  • qpcr_example.csv: qPCR time series for live-cell analysis.
  • GSE95156_Alpha_Beta.txt: RNA-seq data used in the omics differential rhythmicity workflow.

Each file is formatted to drag & drop into app.py as well as the library APIs.

Contributing

  1. Fork the repository and create a feature branch.
  2. Install dependencies with uv sync and activate the environment.
  3. Implement your changes with tests.
  4. Verify via pre-commit run --all-files and uv run pytest.
  5. Open a pull request describing the motivation and results.

Bug reports and feature proposals are welcome through GitHub issues. Please include reproducible examples whenever possible.

License

Licensed under the Apache License 2.0. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cosinor_lite-0.1.3.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cosinor_lite-0.1.3-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file cosinor_lite-0.1.3.tar.gz.

File metadata

  • Download URL: cosinor_lite-0.1.3.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cosinor_lite-0.1.3.tar.gz
Algorithm Hash digest
SHA256 859db22e586965c70bef592dc9b1181650e60fd40371b707b1a67e0c3a48acbf
MD5 e198dbee95b9c6617417bbde9c15fd61
BLAKE2b-256 fcbd02198af00a4b18bfb3b66d7f54c79fe55b771c96861655aaaec04e4d02f6

See more details on using hashes here.

File details

Details for the file cosinor_lite-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: cosinor_lite-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cosinor_lite-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ab737afbc81d31a4ee831bd6ba50d1a475949773e72654e1fc76148878eaa060
MD5 f28d23a4a82c40d7deeff2787fe67add
BLAKE2b-256 6711355a2b5ae0c101464ef96aff6f5c5c9749902687180cb900acc3288a2c61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page