Analyzing Shoaling Behavior in Zebrafish, Danio rerio


  • Shoaling and schooling are complex social behaviors exhibited by many aquatic species.
  • Individuals that form a group due to social reasons are referred to as a shoal, while a school is a shoal that displays synchronized, polarized (i.e. relative orientation and density) motion as one unit.2
  • These social behaviors are believed to promote advantages such as predator avoidance, foraging success, and in some cases locate potential mates.2
  • Zebrafish (Danio rerio) are commonly used as model organisms in genetics and developmental biology laboratories due to the complex biological organization social tendencies they share with other vertebrates, including humans.2
  • While several studies have examined these social behaviors in fish, few have attempted to effectively quantify this behavior.
Figure 1: Zebrafish, Danio rerio (Image from Smithsonian Magazine)


  • I used R programming software to analyze a sample of videos collected by Miller and Gerlai3.
  • While Miller and Gerlai3 described using a highly sophisticated program written using Mathematica to analyze shoaling and schooling behavior, I utilized R software to learn to create a more basic version of that program.
  • To do so, I tracked the movement of the individual mature zebrafish throughout the sample video, and will quantify their individual movement relative to that of all other individuals in the future to determine if schooling or shoaling was observed independent of Miller and Gerlai’s3 findings.
  • Finally, I will analyze these same two variables observed in individual African Clawed Frog larvae, Xenopus laevis, which are known to exhibit shoaling behavior similarly to zebrafish.

Methods – Video Analysis

  • For preliminary analysis, idTracker software was used to process the raw data collected and published by Miller and Gerlai3 on the social behaviors (more specifically, shoaling and schooling) of D. rerio. An open source dataset, the sample of 10 videos collected during this study are publicly available from Google Datasets.
  • After import, variables including the number of individuals, threshold, and region of interest in the program were specified for Video 1 to isolate the fish from the arena and prepare the video for processing.
  • After customizing these settings, the software ran the video and created a text file with coordinates of individual locations in each frame (video is 45 seconds long and the camera used to take the video was 12 fps).
  • R programming software was then used to create a program that imported this text file and plotted the relative coordinates of each individual fish over time.
  • More specifically, it plots the coordinate locations of each fish (replicates) on the x and y axis relative to each other and the frame of the video at each second interval of the full 45 second video sample.
Figure 2: Screenshot of idTracker processing Video 1 from Miller and Gerlai3


Still of Sample Videos

Figure 3: Still image at 26 seconds of 45 isolated from Video 1 of Experiment 1 from Miller and Gerlai3
8 mature zebrafish 3-12 months of age and 3-4 cm in an arena with a diameter of 91 cm.

Replicate Position Over Time

Figure 4: Relative coordinate locations of the eight zebrafish individuals within an arena as shown in Figure 3.

Coordinate locations of all individuals detected by idTracker software are plotted at each second interval of the full video (45 seconds in length).
Each individual fish (replicate) is identified by a unique shade of blue.
Clusters of dots at a given second denote a relative proximity between individuals in the arena.

Discussion and Future Directions

  • The plot allows for visualization of individual Zebrafish movement over time.
  • Over several seconds, it is apparent that the relative locations of individuals change, but they remain clustered; this synchronized motion suggests shoaling or schooling behavior may be occurring.
  • However, further analysis is required to quantitatively determine any possible trends related to shoaling or schooling social behaviors.
  • Moving forward, I will determine the density or nearest neighbor distance (NND) between individual zebrafish at given time intervals within the plot; by doing so, I would be re-creating a simpler version of the program that Miller and Gerlai3 describe to quantify shoaling behavior.
  • I am currently conducting research with Keene State College faculty on the shoaling behavior of the African Clawed Frog, X. laevis larvae and how exposure to polycyclic aromatic hydrocarbons (PAHs) may affect that behavior. I hope to use this program to analyze the data I collect on X. laevis shoaling behavior.


  • 1Miller, N., & Gerlai, R. (2007). Quantification of shoaling behaviour in zebrafish (Danio rerio). Behavioural brain research, 184(2), 157-166.
  • 2Miller, N. Y., & Gerlai, R. (2011). Shoaling in zebrafish: what we don’t know. Reviews in the Neurosciences, 22(1), 17-25.
  • 3Miller, N., & Gerlai, R. (2012). From schooling to shoaling: patterns of collective motion in zebrafish (Danio rerio). PLoS One7(11), e48865.
  • 4Wassersug, R. J., Lum, A. M., & Potel, M. J. (1981). An analysis of school structure for tadpoles (Anura: Amphibia). Behavioral Ecology and Sociobiology9(1), 15-22.