Analyzing social behaviour and rhythmicity in honey bee colonies through advanced computational methods
- π― Goal
- π Project Structure
- π Getting Started
- π Analysis Pipeline
- π Visualization & Figures
- π¬ Simulation Framework
- πΎ Data Access
- π Citation
This project provides a comprehensive implementation of methods for studying and analyzing behavioral rhythmicity in honey bees, as detailed in our paper: Collective flow of circadian clock information in honeybee colonies.
Objective | Description |
---|---|
π Data Acquisition | Implement methods for collecting trajectory data of marked bees using the BeesBook system |
π Cosinor Modeling | Develop algorithms for fitting cosine curves to individual bee movement speeds to analyze rhythmic expression |
π€ Interaction Analysis | Implement techniques for detecting and analyzing bee interactions based on trajectory data |
π Statistical Validation | Conduct statistical tests to validate observed behavior patterns against null models |
π Visualization | Provide comprehensive visualization tools for interpreting and presenting analysis results |
π Analysis Period: August 1-25, 2016 and August 20 - September 14, 2019
π Click to expand directory structure
speedtransfer/
βββ π analysis/ # Core analysis scripts
β βββ cosinor_fit_per_bee.py # Individual rhythm analysis
β βββ velocity_change_per_interaction.py # Interaction detection
β βββ ...
βββ π figures/ # Visualization notebooks
β βββ figure_panel_1.ipynb # Movement speed analysis
β βββ figure_panel_2.ipynb # Speed transfer analysis
β βββ imgs/ # Generated figures
βββ π aggregated_results/ # Processed data outputs
β βββ 2016/ # 2016 analysis results
β βββ 2019/ # 2019 analysis results
βββ πΎ data/ # Raw data (download required)
β βββ 2016/
β βββ 2019/
βββ π§ simulation/ # Simulation scripts
βββ βοΈ path_settings.py # Path configuration
βββ π¦ environment.yml # Conda environment
βββ π³ Dockerfile # Container setup
Directory | Purpose | Key Features |
---|---|---|
π¬ analysis/ |
Core analysis scripts | SLURM-compatible, modular design |
π figures/ |
Jupyter visualization notebooks | Interactive plots, publication-ready figures |
π aggregated_results/ |
Processed data for visualization | Pre-computed results for faster plotting |
πΎ data/ |
Raw trajectory data | Download from Zenodo |
π§ simulation/ |
MATLAB simulation scripts | Agent-based modeling |
Option 1: Conda Environment
# Create conda environment
conda env create -f environment.yml
# Activate environment
conda activate speedtransfer
β οΈ Note: This environment only supports Linux.
Option 2: VS Code Dev Containers (Recommended)
- Install the Dev Containers extension in VS Code
- Click
Reopen in Container
when prompted, or:- Press
Ctrl+Shift+P
(Linux/Windows) orCmd+Shift+P
(Mac) - Type
Dev Containers: Reopen in Container
- Press
Option 3: Docker
# Build the container
docker build -t speedtransfer .
# Run the container
docker run -it speedtransfer
Our analysis framework provides comprehensive tools for studying bee rhythmicity and social interactions:
Script | Function | Key Features |
---|---|---|
π cosinor_fit_per_bee.py |
Individual Rhythm Analysis | Fits cosine curves to movement speeds, detects 24h rhythms |
π mean_velocity_per_age_group.py |
Age-based Velocity Analysis | Generates mean velocity data per age group (10-min intervals) |
π social_network_interaction_tree.py |
Social Network Analysis | Maps sequential interaction cascades, constructs graph-theoretic trees |
π€ velocity_change_per_interaction.py |
Interaction Detection | Identifies bee interactions, measures speed changes |
π² velocity_change_per_interaction_null_model.py |
Null Model Generation | Creates randomized interaction models for statistical validation |
π‘ Note: These scripts are designed for slurmhelper compatibility for high-performance computing environments.
For scripts with SLURM support, adapt the job configuration:
# create job
job = SLURMJob("foo_job_name", "foo_job_directory") # Choose job name and a directory where the job is stored
job.map(run_job_2016, generate_jobs_2016()) # either _2016 or _2019
# set job parameters for slurm settings
job.qos = "standard"
job.partition = "main,scavenger"
job.max_memory = "{}GB".format(2)
job.n_cpus = 1
job.max_job_array_size = 5000
job.time_limit = datetime.timedelta(minutes=60)
job.concurrent_job_limit = 100
job.custom_preamble = "#SBATCH --exclude=g[013-015],b[001-004],c[003-004],g[009-015]"
job.exports = "OMP_NUM_THREADS=2,MKL_NUM_THREADS=2"
job.set_postprocess_fun(concat_jobs_2016) # either _2016 or _2019
# Create SLURM job array
python analysis_script.py --create
# Run jobs automatically
python analysis_script.py --autorun
# Or run manually
python analysis_script.py --run
# Post-process/concatenate results
python analysis_script.py --postprocess
π More Information: See slurmhelper documentation or run
python script.py --help
The remaining scripts can either be executed locally or on a HPC cluster using the provided bash scripts:
run_individual_job.sh
- Single job executionrun_parallel_jobs.sh
- Parallel job execution
Explore our comprehensive Jupyter notebooks for data visualization and figure generation:
Notebook | Content | Key Visualizations |
---|---|---|
π figure_panel_1.ipynb |
Movement & Rhythm Analysis | Group/individual speeds, cosinor fits, age-based rhythmicity |
π€ figure_panel_2.ipynb |
Interaction Analysis | Speed transfer patterns, body-location mapping |
πΊοΈ figure_panel_3.ipynb |
Spatial Analysis | Activity phase distribution, interaction cascades |
π figure_supplementary.ipynb |
Supplementary Data | Observation statistics, additional metrics |
π¬ animations.ipynb |
Dynamic Visualizations | Animated activity flow patterns |
# Navigate to figures directory
cd figures/
# Launch Jupyter Lab
jupyter lab
# Open any notebook and run all cells
Our MATLAB-based simulation environment provides agent-based modeling capabilities for validating theoretical predictions:
Script | Purpose |
---|---|
run_simulation.m |
Main simulation runner |
sketch_agents_2D.m / sketch_agents_3D.m |
Agent visualization |
draw_positions_from_gaussian.m |
Spatial position generation |
draw_velocities.m |
Velocity distribution modeling |
fit_sine.m |
Sine wave fitting for rhythm analysis |
# Download data from Zenodo (adjust link for different files)
wget https://zenodo.org/records/10869728/files/interactions_side0_2019.zip
# Extract to data directory
unzip data.zip
# Verify structure
ls data/
β οΈ Important: Data must be placed in thedata/
directory for proper path imports in analysis scripts. Alternatively adjust thepath_settings.py
file.
If you use this code or methodology in your research, please cite our work:
@article{mellert2024collective,
title={Collective flow of circadian clock information in honeybee colonies},
author={Mellert, Julia and K{\l}os, Weronika and Dormagen, David M and Wild, Benjamin and Zachariae, Adrian and Smith, Michael L and Galizia, C Giovanni and Landgraf, Tim},
journal={bioRxiv},
pages={2024--07},
year={2024},
publisher={Cold Spring Harbor Laboratory}
}
π Made with π for bee research
π Paper β’ πΎ Data β’ π Issues β’ π€ Contributing