# Autonomous Circadian Oscillators Intrinsic to Cell Membranes

This repository contains the computational models and simulation code for the membrane-based circadian oscillator described in:

**"Autonomous circadian oscillators intrinsic to cell membranes"**  
Mauro A. Forlino, Oreste Piro, Monika Stengl & Martin E. Garcia  


## Overview

This work demonstrates that circadian rhythms can arise from membrane-associated post-translational feedback loops (PTFLs) operating independently of nuclear transcription-translation feedback loops (TTFLs). We provide computational models for two cell types:

1. **Red Blood Cells (RBCs)**: Anucleate cells that exhibit circadian oscillations in metabolism, redox state, and ion transport
2. **Neurons**: Nucleated cells where membrane oscillators modulate neuronal excitability and firing rate on a circadian timescale

## Repository Contents

### Python Scripts

- **`RBC.py`**: Red blood cell membrane oscillator model
  - Implements the Goodwin-type oscillator for RBC circadian rhythms
  - Simulates various experimental conditions (valinomycin, MG132, Conoidin A, K+ removal)
  - Generates plots for main figures

- **`NEURON.py`**: Neuronal membrane oscillator simulation
  - Couples Hodgkin-Huxley electrophysiology (millisecond timescale) with membrane oscillator (hour timescale)
  - Simulates 4 days of neuronal activity
  - Generates time series data files for analysis

- **`NEURON_plot.py`**: Visualization script for neuronal data
  - Loads simulation output from `NEURON.py`
  - Creates comprehensive figure showing circadian modulation of firing rate
  - Generates phase space plots and limit cycles

### Data Files (Generated)

When you run `NEURON.py`, it generates the following output files:
- `time_[0-3].txt`: Time points for each simulated day
- `Ncc_[0-3].txt`: Clock channel availability time series
- `Y_[0-3].txt`: Inhibitor concentration time series
- `cAMP_[0-3].txt`: Cyclic AMP concentration time series
- `spike_train_[0-3].txt`: Spike times for each day
- `T_series_min.txt`, `V_series_min.txt`, `Ca_series_min.txt`: 1-second window at minimum firing rate
- `T_series_max.txt`, `V_series_max.txt`, `Ca_series_max.txt`: 1-second window at maximum firing rate


## Usage

### Red Blood Cell Model

Run the RBC simulation and generate plots:

```bash
python RBC.py
```

**Outputs:**
- `test.svg`: Main figure showing oscillations and Hill functions
- `Sup.svg`: Supplementary figure comparing all experimental conditions

**What it simulates:**
- Control conditions (V = -10 mV)
- Hyperpolarized membrane (V = -30 mV, mimics valinomycin treatment)
- MG132 treatment (proteasomal inhibition)
- Conoidin A treatment (PRX inhibition)
- K+ removal experiment

### Neuronal Model

**Step 1**: Run the simulation (this may take several minutes):

```bash
python NEURON.py
```

This generates time series data files for 4 days of neuronal activity.

**Expected output:**
```
Starting 4-day simulation of neuronal membrane oscillator...
============================================================

Simulating day 1/4...
  - Completed day 1
  - Number of spikes: XXXX
  - Mean firing rate: X.XXX Hz
...
```

**Step 2**: Generate plots from the simulation data:

```bash
python NEURON_plot.py
```

**Outputs:**
- `Figure_2.svg`: Complete figure showing circadian modulation of neuronal firing


