Supplementary material from "How predation shapes the social interaction rules of shoaling fish"

1 Department of Zoology, Stockholm University, 10691, Stockholm, Sweden, 2 Department of Mathematics, Uppsala University, 75106, Uppsala, Sweden, 3 School of Biological Sciences, University of Bristol, Bristol, UK, 4 Department of Life Sciences, Roehampton University, London, UK, 5 Department of Life Sciences,The University of The West Indies, St. Augustine, Trinidad and Tobago, 6 Faculty of Life Sciences, Albrecht Daniel Thaer-Institut, Humboldt-University zu Berlin, Invalidenstrasse 42, 10115 Berlin, Germany 7 Leibniz-Institute of Freshwater Ecology and Inland Fisheries, Department of Biology and Ecology of Fishes, Müggelseedamm 310, 12587 Berlin, Germany ∗ E-mail: Corresponding author james.herbert.read@gmail.com

in size, the total number of times it decreased in size, the total number of times it remained the same size, 48 and hence the total number of possible transitions. The corners of the arenas disrupted the shoaling behaviour of the guppies, often causing them to cross and 51 reducing their directional alignment. To ensure we only analysed times when the fish were shoaling, for the 52 following measures we removed tracks that were within 150 (∼ 130 mm) pixels of the corners of the arena. 53 To determine the average width and height of the subgroups that were exploring the arena together, on 54 each frame, we rotated the coordinates of fish belonging to a particular subgroup size by the average direction 55 those subgroup members were facing. In effect, the subgroups were rotated so that the group's mean heading 56 was aligned and facing along the positive X axis. The fish at the very front of the group, therefore, had the 57 largest x coordinate and the fish at the back of the group having the smallest x coordinate. We determined 58 the distance between the fish with the smallest and largest x coordinate as a measure of the subgroup's length. 59 In a similar way, the determined the distance between the fish with the largest and smallest y coordinate, 60 giving the subgroups's width at that frame. For each trial, we calculated the mean length and width for each 61 subgroup size. 62 To visualise the shape of the subgroups of 8 fish as shown in Figure 2 and Figure S2, we produced heat-63 maps of the positions of group members relative the subgroup's centroid. To construct these heat-maps, we 64 subtracted the centroid from the subgroup's rotated coordinates. This transformed the coordinates so that u c (t) =x sg (t + ∆t) −x sg (t) ∆t and v c (t) =ȳ sg (t + ∆t) −ȳ sg (t) ∆t . (S1) where ∆t is 1/24. We then calculated the speed of the subgroup's centroid as: For each trial, we calculated the median speed of each subgroup size within the trial.
Polarisation was calculated as these heat-maps were smoothed using a gaussian filter (sigma = 1 were discarded within these regions. We wanted to ensure that each trial contributed a sufficient amount 102 data in order to accurately quantify the fish's social interactions. Therefore, we only analysed videos where 103 we had at least 2 minutes worth of data for when the pair were shoaling together. Shoaling was defined as 104 when the two fish were less than 100 mm apart (4-5 body lengths) and the fish had moved at least 20 mm 105 within a second. This classification ensured we did not include trials where either the fish had not explored 106 the arena, were not moving, or were not exhibiting shoaling behaviour. Again, we chose 100 mm because this 107 represented 4-5 body lengths of the fish. In practise, the majority of social interactions occurred within this 108 region (Fig. S8A). In total, we removed 30 of the 254 trials (11 from low predation populations and 19 from 109 high predation populations) where data did not reach these criteria.

112
We determined the x and y components of each fish's, velocity using the standard forward-difference approx-113 imations: where ∆t = 1/24 s was the constant duration between consecutive video frames. A fish's speed at time t was 115 then approximated as: To detect the times when a fish decided to move (increase in speed), we smoothed these speeds using 117 a Savitzky-Golay filter with a span of 12 frames (1/2 second) and degree 3. We then detected the times 118 and heights of the peaks and troughs of these speeds using the findpeaks inbuilt function in MATLAB, with 119 a minimum distance of 8 frames (1/3) second between adjacent troughs or peaks (Fig. 3A). Because fish 120 showed strong directional alignment when they were less than 100 mm apart (Fig. S8A), and because we 121 were interested in how fish updated their position as a function of its neighbour's position when they were shoaling, we only analysed decisions when fish were less than 100 mm apart. Using a custom built script, we 123 paired each trough (magenta points in Fig. 3A) with the following peak (yellow points in Fig. 3A) of the 124 speed profile. Each paired trough and peak was classified as a decision. We removed spurious decisions where 125 the change in speed between the trough and peak of a decision was less than 20 mm/s. We determined this 126 cutoff by plotting a histogram of all decision speeds across all trials, which revealed a strong peak below 20 127 mm/s (Fig. S8B), revealing the spurious decisions (noise). An example of one of these spurious decisions can 128 be seen in Figure 3A at ∼ 9.5 seconds. We calculated the acceleration within each of these decisions as the 129 change in speed between the trough and the peak of a decision, divided by the time lag between the trough 130 and the peak of the decision. To calculate the deceleration after a decision, we calculated the change in speed 131 between the decision's peak and the next decision's trough, divided by the time between the decision's peak 132 and the next decision's trough. Because the fish did not always make a second decision immediately after 133 the first decision, we only included decelerations when the time between the decision peak and next decision's 134 trough was less that 15 frames (0.62 seconds). This ensured we captured the true deceleration of the fish, 135 without including long spurious periods of time between non-sequential decisions.

136
To generate the heat-maps shown in Figure 3D-G and Figure  both the x axis and the y axis. We then determined the mean acceleration and deceleration of fish when their 142 neighbour was in each of these discretised locations across all decisions, but separately for males or females, 143 and for fish from high or low predation populations. For plotting purposes, these heat-maps were smoothed 144 with a Gaussian filter, with sigma = 4. We also determined the total number of decisions that were made 145 when neighbours were in these locations, which was used to determine the probability contour regions using 146 the probcontour function. Note that the statistics were performed on the raw measures, and these plots were 147 purely for visualisation purposes.

148
At each decision point, we identified the fish that was in front or behind the other fish relative to the 149 pair's direction of travel. To remove any ambiguity about which fish was in front or behind the other, we only 150 assessed this positioning when the pair's polarisation was above 0.5. We then determined how the distance 151 between the pair varied in the two seconds following a decision by either the lead fish or the following fish 152 (see Fig. 3A). We also determined whether the pair switched positions during these decisions, by assessing 153 whether the fish that was at the front of the pair remained at the front of the pair 15 frames (0.62 seconds) 154 after either fish had made a decision. If the two fish had changed position, we counted this as a switch. The 155 number of times the fish did not switch position during these decisions was also counted.

156
To determine a decision rate for each fish, we counted the number of decisions a fish made, and divided of males and females in separate models (see statistics below and Table S5). Whilst it appeared that males from high predation populations made more decisions per second, this could be explained on the basis that smaller males made more decision per second than larger males (χ 2 = 4.45, d.f = 1, P = 0.035). On the 173 other hand, females from high predation populations made less decisions per second that females from low 174 predation populations (χ 2 = 7.92, d.f = 1, P = 0.005) with no effect of body size on this decision rate (χ 2 = 175 0.38, d.f = 1, P = 0.54) .  (Table S5), however, smaller females made more turns than larger females (χ 2 = 4.97, d.f = 195 1, P = 0.03).

196
To create the heat-map in Figure 4A, like the acceleration heat-maps, we determined the relative location of  Figure 4A. In each trial, we counted the total number of turns a fish made when their 204 neighbour was in each of these top two sections. We also counted the number of times a fish turned left 205 or right when their neighbour was in each of these top two sections. In each trial, therefore, we determined 206 the number of times a fish turned towards its neighbour out of the total number of turns it made. We also 207 determined the mean size of the turns that were directed towards the location of the neighbour in these top 208 two sections within each trial.

209
To create the heat-map in Figure 4B, for each turning decision, we determined the relative direction of the

255
Continuous response variables were modelled with linear mixed effects models (LME). These models were 256 fitted using maximum likelihood. To avoid violating LME assumptions (i.e. residual distribution and hetero-257 scedasticity which were checked with diagnostic plots), shoal width, shoal length, modal distance (eights), Contour lines represent regions containing the proportion of total observations where individuals were found relative to the shoal centroid located at (0,0). Shoals from high predation populations were generally more compact than shoals from low predation populations. These patterns were consistent in shoals of 8 female fish (Fig. 2) and across different subgroup sizes (Fig. S3).      Fig. 3A). We filtered decisions that were less than 20 mm/s changes in speed (red line), as these represented spurious decisions likely due to noise (i.e. decision at approximately 9.5 s in Fig. 3A). (C) Example of a guppy's turning profile. Guppies swim in the same direction with intermittent changes in heading. We used a step detection algorithm to detect these changes in direction. Blue line represents the original headings calculated during tracking. The red line represents the step changes detected. The times of these changes are plotted in Fig.  3A as the dashed lines.  Table S1. Bayesian GLMM of the proportion of time fish were observed in a group of 8