Skip to content

BioroboticsLab/speedtransfer

Repository files navigation

🐝 Collective Flow of Circadian Clock Information in Honeybee Colonies

Preprint License Python Conda Docker SLURM Zenodo

Analyzing social behaviour and rhythmicity in honey bee colonies through advanced computational methods

πŸ“‘ Table of Contents

🎯 Goal

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.

πŸ”¬ Key Objectives

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

Overview Figure Figure: Overview of the collective flow analysis framework

πŸ“ Project Structure

πŸ“‚ 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 Details

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

πŸš€ Getting Started

πŸ“¦ Installation

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)
  1. Install the Dev Containers extension in VS Code
  2. Click Reopen in Container when prompted, or:
    • Press Ctrl+Shift+P (Linux/Windows) or Cmd+Shift+P (Mac)
    • Type Dev Containers: Reopen in Container
Option 3: Docker
# Build the container
docker build -t speedtransfer .

# Run the container
docker run -it speedtransfer

πŸ“Š Analysis Pipeline

Our analysis framework provides comprehensive tools for studying bee rhythmicity and social interactions:

πŸ”¬ Core Analysis Scripts

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.

βš™οΈ SLURM Configuration

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 execution
  • run_parallel_jobs.sh - Parallel job execution

πŸ“Š Visualization & Figures

Explore our comprehensive Jupyter notebooks for data visualization and figure generation:

πŸ“ˆ Available Notebooks

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

🎯 Quick Start with Figures

# Navigate to figures directory
cd figures/

# Launch Jupyter Lab
jupyter lab

# Open any notebook and run all cells

πŸ”¬ Simulation Framework

Our MATLAB-based simulation environment provides agent-based modeling capabilities for validating theoretical predictions:

πŸ”§ Simulation Components

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

πŸ’Ύ Data Access

Zenodo DOI

πŸ“₯ Download Instructions

# 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 the data/ directory for proper path imports in analysis scripts. Alternatively adjust the path_settings.py file.

πŸ† Citation

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

About

This is a repository for the speedtransfer paper code.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •