Behavioural Neuroscience
Mouse behaviour: mice → sessions → trials with cage effects
Twenty-four mice housed four per cage learn a two-choice task over eight days of 20 trials. Accuracy rises along an exponential learning curve whose rate depends on genotype and on a shared cage effect; latencies are log-normal and censored at a 60 s timeout.
mice (24, 4 per cage) → sessions (8 days) → trials (20)
Data structure
Animal behaviour has three nested levels (animal, session, trial) plus a housing factor: the canonical setting for pseudoreplication and GLMMs.
- miceone row = one animal
- Genotype, sex, cage and an individual learning rate that includes a cage-level random effect.
- sessionsone row = one daily session
- Training day and the probability of a correct choice on that day.
- trialsone row = one trial
- Correct (0/1) and latency in seconds, capped at the 60 s timeout, with a timeout flag.
Generate the mouse behaviour tables
The preset is a starting point: change any formula, noise step or row count and the preview, ER diagram and relation check update.
Key relationships
learning_rate = 0.35 - if(genotype == "KO", 0.12, 0) + group_effect(cage_id, 0.05)group_effect(cage_id, …) gives all mice in a cage the same draw: the cage effect that is often ignored.
p_correct = 0.5 + 0.45 * (1 - exp(-parent.learning_rate * (day - 1)))Learning curve from chance (0.5) toward 0.95.
latency_s = exp(2.8 - 0.12 * parent.day + rnorm(0, 0.35)) → clip(max 60)The clip creates right-censored latencies at the timeout.
Common pitfalls
- Pooling all 3 840 trials into a chi-square test: trials within a mouse and mice within a cage are correlated.
- Ignoring cage: if genotypes are housed separately, genotype and cage are confounded.
- Averaging latencies that include timeouts as if 60 s were the true value; treat them as censored.
- Analysing proportion correct per session with ANOVA instead of a binomial model.
Typical analysis
Binomial GLMM on trial outcomes with genotype × day as fixed effects and random intercepts for mouse nested in cage. Latency: a survival-style model or a log-normal mixed model that handles censoring.
library(lme4)
m <- read.csv("mice.csv", comment.char = "#"); s <- read.csv("sessions.csv", comment.char = "#"); t <- read.csv("trials.csv", comment.char = "#")
d <- merge(merge(t, s, by = "session_id"), m, by = "mouse_id")
fit <- glmer(correct ~ genotype * day + (1 | cage_id/mouse_id), family = binomial, data = d)
summary(fit)Further reading
- Lazic SE, Essioux L (2013). Improving basic and translational science by accounting for litter-to-litter variation in animal models. BMC Neuroscience 14:37.
- Percie du Sert N et al. (2020). The ARRIVE guidelines 2.0. PLOS Biology 18(7):e3000410.
Other relational presets
- qPCR (ΔΔCt) : plates (3) → samples (8 per plate) → reactions (2 genes × 3 technical replicates)
- Field ecology counts : sites (8) → plots (5) → counts (6 species)
- Schools / classes / students : schools (20) → classes (2–4) → students (Poisson ≈ 22, 10–32)
- All presets and the formula reference