Companion Data Page Neuronal control of locomotor handedness in DrosophilaSean Buchanan ^{1}, Jamey Kain^{1}, Benjamin de Bivort^{1,2,3}^{1}The Rowland Institute at Harvard, Cambridge, Massachusetts, USA. ^{2}Center for Brain Science, Harvard University, Cambridge, Massachusetts, USA.^{3}Department of Organismic and Evolutionary Biology, Harvard University, Cambridge, Massachusetts, USA. | |

## Hardware | |

Buchanan2015_imaging_box.zip | Zip archive containing a parts list for the behavior imaging boxes and pdf laser-cutting schematics for producing the acrylic panels of the imaging box. |

## Instrument control .VI (LabVIEW 8.6) | |

y maze v3.1.vi | Main data acquisition interface. Performs tracking of the centroid of pixels dark with respect
to a singly acquired reference image, within positionable regions of interest that the user centers
over the Y-maze centers. Has fields for experimental meta data. Exports two files, one with the extension
".labels.txt" which contains meta data, and one with the extension ".data.txt" containing the tracking data.
The file path serving as the base name of these two files is the inputs to flyY120LoadData.m
which reads the data into MATLAB and converts the tracking data into directional choices.Calls y maze Save data v3.vi and y maze ROI centroid v3.vi. |

y maze ROI centroid v3.vi | Determines the centroid of pixels exceeding a darkness threshold compared to a reference image within
all the user-designated ROIs. Addorns the difference image between the current camera view and the
reference image with red circles marking the positions of the centroids, and yellow boxes indicating the
ROI boundaries. Called by y maze v3.1.vi. |

y maze Save data v3.vi | Writes a line of output to the .data.txt output file of y maze v3.1.vi once per frame.
Called by y maze v3.1.vi. |

## Data .mats (MATLAB 2011a) | |

handednessAllData.mat | Individual Y-maze left-right choice data for all the flies reported in the study. Contains two
variables: allHandData, an n x 9 cell array where n is the individual fly data and the 9 columns contain
meta data on each experiment and the raw turn sequences and timings; and allHandDataStatusSummary,
an m x 4 cell array where m is experimental groups and the four columns contain aggregate data
from all the individuals within each group. Columns of allHandData are: 1) maze number within the array, 2) Buchanan experiment ID, 3) tray number, 4) imaging rig number, 5) experimental group / genotype, 6) number of turns, 7) turn bias, 8) vector of turn directions (0=left, 1=right), 9) vector of turn times in ms (0=start of experiment). Columns of allHandDataStatusSummary are: 1) experimental group / genotype, 2) groups sample size, 3) turn bias MAD, 4) 1 standard error of the turn bias MAD, estimated by bootstrap resampling. Large file (96MB). |

handednessWingFoldingData.mat | All wing-folding data reported in the study. Contains one variable per genotype, each an n x k array where n is the number of flies per genotype and k is independent measurements. 1 indicates instances where the right wing was on top, 0 the left. Single columns of NaNs separate recordings made over subsequent days. Variable are named as "wingFolding_XXX" where XXX is the genotype. Variables with "_WxY_F1" after their genotype correspond to F1 individuals resulting from single male-female matings between the individual flies in rows W and Y of the corresponding genotype data. |

handednessLegLengthData.mat | All leg length measurements reported in the study. Contains two variables: legSegmentData, an n x 33 array where n is individual flies, and the columns include the raw leg segment and body length measurements (in pixels), possible metrics to correlate to turn bias, and the turn bias of these individuals (measured prior to leg dissection); legSegmentDataColLabels, a 1 x 33 array of strings containing the labels of the columns of legSegmentData. |

## Analysis .m functions (MATLAB 2011a) | |

basic analysis and data handling | |

flyY120LoadData.m | Loads turn choice data from the output of y maze v3.1.vi into MATLAB. Takes one parameter, pathname,
which is the file path to the data to be imported, including directories as needed, but excluding
the .dat.txt and .label.txt extensions created by the instrument control vi. Integrates turn direction
and timing vectors with experimental meta data from the .label.txt file.Calls flyY120.m. |

flyY120.m | Parses the data contained within the .dat.txt vi output file to extract the turn direction and
turn timing vectors. Sensitive to which mazes within each 120 maze array are rightside up (1 - 64),
and which are updside down (65-120). Called by flyY120LoadData.m. |

handGetExpGroup.m | Collects all the individual turn data from a single experimental group / genotype from within a master cell array variable such as expData_DGRPScreen. Output is a cell array of just the turn data for that experimental group. |

flyBurHandData.m | Analyzes the .data.txt output of y maze v3.1.vi for experiments in circular arenas and calculates
multiple parameters for each fly over time: the x- and y- coordinates, the radial distance from the
center of the arena, the angular position within the arena, the angular direction of motion (across
successive frames), the speed of motion, and the angular velocity (i.e. the frame to frame change in
angular direction of motion). Requires three inputs, the data, the number of flies in the data file,
and the size of the ROIs set in the .vi interface. Output is used by avgAngle.m. |

avgAngle.m | Calculates the average angular behavior of fly paths with respect to the center of the arena, i.e.
the theta-direction metric. Considers only segments of paths that are moving (speed > 0.5 px/frame) and
away from the wall to avoid edge effects (with a radial distance from the center of the arena at most 80%
of the arena radius). Inputs are the output from flyBurHandData.m and the ROI size. |

statistics | |

handMutualInfo.m | Caculates the mutual information between successive turns for sequences of turns (used in Figure S1f). Input is a n x 1 vector of turns where 0 indicates a left turn and 1 indicates a right turn. |

flyVacPersMetricPValue.m | Used to calculate p-values comparing the MADs of two experimental groups (e.g. Figure 3a,b). Inputs
are the MADs of each group and the standard deviation of estimates of the MAD across bootstrap resamplings
(the standard error of the MADs), found in allHandDataStatusSummary within handednessAllData.mat.
Computes the probability that a variable drawn from a Gaussian with mean and standard deviation corresponding
to the MAD and standard error of the MAD of the experimental group with the higher MAD would by chance
be less than a variable drawn from a Gaussian with mean and standard deviation corresponding to the MAD
and standard error of the MAD of the other experimental group. I.e. this is an estimate of the likelihood of seeing the
MAD ranking of the two experimental groups reversed due to sampling error alone. This test provides a one-tailed p-value which
was doubled to give the values reported in the manuscript. |

vofvMadzTest.m | Resamples the MAD value of a vector of turn bias scores. Second parameter is number of resamples
to perform. Used to generate standard error intervals, such as those in Figure 4d, or estimate the statistical support for the MAD
of an experimental group being greater or less than a null hypothesis value (e.g. the binomial-derived baseline presented in Figure 1e)
by calculating the frequency with which the resampled MAD falls below (or above) the null hypothesis value. |

handLinModBS.m | Performs a bootstrapping analysis on the linear model of effect on handedness variability coming
from each of the PFN sub-types analyzed in Figure 4. Output has three columns for each bootstrap replicate, the model coefficients
associated with each of the sub-types and the R^{2} statistic on the linear fit. Resamples the individual
data points comprising each experimental group as well as the experimental groups used to fit the linear models. |

visualization | |

handFig1dPlotMaker.m | Script that uses data from the CS experimental group within the allHandData variable of handednessAllData.mat
to make plots of the type in Figure 1d. Does this for a randomly chosen individual each time it is run. |

pathPlot.m | Produces a plot of the type in Figure 1c for data in the format of the .data.txt output of y maze v3.1.vi.
Input parameters are the data and the color of the lines to be plotted. |

modeling | |

handToyModel.m | Runs the differential equations model of left-right decision making from Figure S9. Requires
two input parameters: the intrinsic bias to the network (gamma)
and the signal to noise ratio of the input stimuli._{L}/gamma_{R} |