Companion Data Page Spatiotemporal dynamics of locomotor decisions in Drosophila melanogaster Lior Lebovich1,2,3*, Tom Alisch4*, Edward Redhead5, Matthew Parker6, Yonatan Loewenstein7, Iain Couzin1,2,3, Benjamin de Bivort4 1 Department of Collective Behaviour, Max Planck Institute of Animal Behavior, Konstanz, Germany. 2 Centre for the Advanced Study of Collective Behaviour, University of Konstanz, Universitätsstraße 10, 78464, Konstanz, Germany. 3 Department of Biology, University of Konstanz, Konstanz, Germany. 4 Department of Organismic and Evolutionary Biology and Center for Brain Science, Harvard University, Cambridge, Massachusetts, USA. 5 School of Psychology, University of Southampton, UK. 6 School of Biosciences, University of Surrey, UK. 7 The Edmond and Lily Safra Center for Brain Sciences, The Alexander Silberman Institute of Life Sciences, Dept. of Cognitive and Brain Sciences and The Federmann Center for the Study of Rationality, The Hebrew University of Jerusalem, Jerusalem, Israel. * contributed equally. Manuscript PDF Manuscript: hosted at bioRxiv |
|
Repository of data and scripts (Zenodo) |
|
Zenodo repository | Archive .zip files containing all experimental and simulation data and analysis scripts. |
Data files |
|
Raw data | Folder containing raw human, wild-type, and mutant fly experimental data. |
Preprocessed data | Folder containing data preprocessed using data preprocessing scripts and analyzed in behavioral data scripts. |
Data preprocessing scripts |
|
drosophila_selectFlies.m |
Initial preprocessing stage of fly data and ABM simulation data. Selects flies, defines edges, computes bounding polygons, omits inavlid trials and flies.
Output: Turndata_[DATASET_NAME]_visInsp.mat; Turndata_[DATASET_NAME]_edgesDef.mat; poly360_Turndata_[DATASET_NAME].mat; selectedFlies360DBTurndata_[DATASET_NAME].mat; saved_yMinByFly360_[DATASET_NAME].mat |
yCorrectionExample.m | Illustrates trajectories normalization. Plots the noramlized bounding polygons in the short WT vs long WT datasets as well as the further correction required so that the short and long mazes size will reflect absolute proportions. |
drosophila_mainPreprocess.m |
Main preprocessing stage of fly data and ABM simulation data. Normalizes trajectories, computes relative time in trial, determines turn decisions, excludes invalid trials.
Output: output_drosophila_main_[DATASET_NAME].mat |
human_selectHumans.m |
Initial preprocessing stage of human data. Defines edges, divides into turns, omits invalid trials and participants.
Output: HumanTurndata_human_visInsp.mat; Turndata_humanHuman.mat; humanHuman_edgesDef.mat |
human_mainPreprocess.m |
Main preprocessing stage of human data. Normalizes trajectories, computes relative time in trial, determines turn decisions, excludes invalid trials.
Output: output_drosophila_main_HumanYy.mat |
drosophila_reshapeSimulationsCell.m |
Restructring of ABM simulation datasets. Reshapes each model simulation dataset (cell array) to real flies data structures.
Output: Turndata_Short[DATATYPE_NAME(5:end)].mat |
Behavioral data scripts |
|
drosophila_exampleFlyShort.m |
Example fly illustrations. Plots raw and corrected trajectories, pdf(x) and TPI illustration for an example WT fly in the short maze.
Output: saved_exampleFlyLoc.mat. Figures: Fig. 1B: exampleFly87__procTrajectories_YX.fig; Fig. 1C: exampleFly87__correctedTrajectories_YX.fig; Fig. 1D: exampleFly87__yBinEample_xPDF.fig; Fig. 1D: exampleFly87__yBinEample_xDeltaPDF.fig; Fig. 1E: exampleFly87__yBinEample_pRightGivenMedX.fig; Fig. 1E: exampleFly87_TPIY.fig; Fig. S1A: exampleFly87_TPIT.fig |
drosophila_exampleBrownian.m |
Plots raw and corrected trajectories for an example ABM agent.
Output: saved_exampleBrownianLoc.mat. Figures: Fig. S14A: exampleBrownian1__procTrajectories_YX.fig; Fig. S14B: exampleBrownian1__correctedTrajectories_YX.fig |
drosophila_pdfYLastTransition.m |
Computes and plots the probability density function of last midline-crossings, PDF(y|last midline- crossing) across flies/agents or across trials in each datasets.
Output: flies_PdfLastTrans.mat. Figures: Fig. S1C: flies_pdfLastTrans_Short.fig; Figs. 1F, 4A, S3C (modify code for S3B), S13A: fliesAll_[COMPNAME] Comp_pdfLastTrans.fig; Fig. 1G: fliesAll_[COMPNAME]Comp_pdfLastTransT.fig; Fig. 3B: fliesAll_LongAlignComp_pdfLastTrans.fig; |
drosophila_speed.m |
Plots avg. speed, distance and relative time by y-bins and relative time-bins for all flies in the short WT dataset.
Output: flies_speed.mat. Figures: Fig. S1D: fliesShort_avg[PARAM_NAME]Y.fig; Fig. S1E: fliesShort_avg[PARAM_NAME]T.fig |
drosophila_normBoundingPolygon.m |
Computes normalized and x-centered average bounding polygon across flies in dataset.
Output: flies_boundPolProc_[DATASET_NAME(10:END-2)].mat |
drosophila_TPI.m |
Spatial and temporal Turn Prdictiveness Index (TPI). Computes and plots TPI(y) and TPI(rel. trial time) of for all decision-makers in each data set.
Output: flies_TPIs.mat. Figures: Figs. 1F, 1G, 4F, S11A: flies[DATATYPE(10:END-2)]_TPI[DOMAIN].fig; Figs. 4A, S3C, S4A, S8A, S8A, S13A, S15B: fliesAll_[COMPNAME] Comp_TPI[DOMAIN].fig; Figs. S6A, S15A: fliesAll_[COMPNAME]Comp_slopeTPI[DOMAIN].fig; Figs. 3B: fliesAll_LongAlignComp_TPIy.fig; Fig. S3B: fliesAll_LongAbsComp_TPIy.fig |
drosophila_tsne.m |
t-distributed stochastic neighbor embedding of behavioral data TPI. Dimensionality reduction (2D) of the individual TPI curves (within the bottom arm) of humans and all fly lines via t-distributed Stochastic Neighbor Embedding (t-SNE). With cosine distance metric.
Figures: Fig. 4G: flies_tSNE_TPI[DOMAIN].fig |
drosophila_probEvenTransition.m |
Quantifying local lateral tendencies via midline- crossings and pEven. Computes trial #midline- crossing in each maze region, typicaly post cul-de- sac, and the corresponding fractions of even #crossings, pEven. Plots #Crossings and pEven histogram and boxplots, comparison with Poisson predictions, pEven-based TPIs, and probability density kernal estimates of time spent in each maze region.
Output: flies_pEvenTrans.mat. Figures: Figs. 2C, 3C, 3D: flies_pEvenTrans_hists_[DATASET].fig; Figs. 2D, S3D, S11B: flies_pEvenTrans_extrmTPI_[DATASET].fig; Figs. S6D (S9A), S13D: flies_pEvenTrans_comp[COMPNAME]PEven.fig; Figs. 4C (S9B), S13C: flies_pEvenTrans_comp[COMPNAME]PEven2.fig; Figs. S6C, S13E: flies_pEvenTrans_comp[COMPNAME]Trans_ [REGIONNAME].fig; Fig. S15C: flies_pEvenTransPoisson.fig; Fig. S1B: flies_histAvgTransBottomArm_Short.fig; Figs. S3A, S6B: flies_pEvenTrans_TimeInRegion.fig; |
drosophila_wallFollowing.m |
Quantifying global lateral tendencies using MAD scores. Computes flies' Median Absolute Deviation (MAD) around the horizontal (x) center during upward and/or downward motion in bottom arm. Plots MAD (x|up the arm)-based comparison of TPI(y) and MAD datasets comparison.
Output: output_drosophila_MADs.mat; output_drosophila_MADs_order.mat Figures: Figs. 2E (S2A), S3E, S11C: flies_MAD[DATASET]_BasedTPI_ [DATATYPE(10:end-2)]_upArmWalk.fig; Fig. 4B: flies_MADcenter_allShortsCompShortBox_upArmWalk.fig; Fig. S13B: flies_MADcenter_allShortsCompModelBox_upArmWalk.fig |
drosophila_wallFollowingByNumTrans.m |
Quantifying short maze crossings-dependent global lateral tendencies and spatial TPI. Computes and plots MAD around the center as a function of #midline-crossings post-cul-de-sac. Computes and plots spatial TPI and estimates for TPI increase for trials with non-zero post-cul-de-sac crossings.
Output: flies_TPIs_noZero.mat Figures: Fig. 4B: flies_MAD_byTranNum_shortComp_upArmWalk.fig; Fig. S9C: fliesAll_ShortComp_TPIY_noZeroTrans.fig; Fig. S9D: fliesAll_ShortComp_slopeTPIY_noZeroTrans.fig |
drosophila_longMazeTransAndSims.m |
Long maze post cul-de-sac #midline-crossings and their simulations. Simulates the expected #crossings in shorter mazes or plots #crossings for example flies in the long maze.
Output: simTransByItiDistY.mat Figures: Fig. S5B-C: flies_bootTransByLongTrasIntervals.fig; Fig. S5D: flies_bootTransByLongCONSECUTIVETrasIntervals.fig; Fig. S5E: fliesLong_indivTransDist.fig |
drosophila_quiverAvgs.m |
Dataset average quiver plots and heatmaps. Computes and plots average quiver plots across flies in each fly dataset within the cul-de-sac, separately for left and right turns and motion towards or away from the cul-de-sac. Also computes and plot average quivers exclusively for zero post cul-de-sac midline- crossing trials for each fly dataset. Computes and plots average heatmaps across decision-makers, separately for left and right turns and the corresponding difference.
Output: output_drosophila_Quivers.mat Figures: Figs. 2A, 4D, S3F, S7: flies[DATA_NAME]_avgQuiver.fig; Figs. 2B, S15D: flies[DATA_NAME]_avgHeat.fig; Fig. S10: flies[DATA_NAME]_avgQuiverZeroTrans.fig |
drosophila_quiverIndivs.m |
Individual quiver plot demomnstration. Computes and plots a quiver plots of an individual example fly, for upward motion within the cul-de-sac, separately for left and right turns, alongside with trajectories from most visited 2D bin.
Output: output_drosophila_main_[DATASET_NAME(10:END)].mat; saved_exampleFlyLoc.mat |
GODM_TPI.m |
GODM_TPI.m
External dataset: Spatial TPI of flies in a circular arena. Computes and plots the trajectories and spatial TPI (Turn Predictiveness Index) of flies in the study of Sridhar and colleagues. TPIs are computed across all trials of all flies, separately for two conditions (with 2 targets each).
Reference: Sridhar, V. H., Li, L., Gorbonos, D., Nagy, M., Schell, B. R., Sorochkin, T., Gov, N. S., & Couzin, I. D. (2021). The geometry of decision-making in individuals and collectives. Proceedings of the National Academy of Sciences of the United States of America, 118(50), e2102157118. https://doi.org/10.1073/pnas.2102157118 Figures: Fig. S12: GODM_trajectoriesAndTpis_byTarAngles.fig |
Custom MATLAB functions |
|
ySpeed.m | Kinematics by spatial and temporal bins in the short WT dataset. Plots average speed, distance and relative time by y-bins and relative time-bins for all flies in the short WT dataset. |
TPI.m | Computes the TPI - Turn Predictiveness Index - over spatial (Y) or temporal bins (T) for an individual decision-maker. Used for trajectory data that is not centered around the horizontal midline. |
TPI1.m | Computes the TPI - Turn Predictiveness Index - over spatial (Y) or temporal bins (T) for an individual decision-maker. Used for trajectory data that is centered around the horizontal midline. |
quiverGivenTurns.m | Computes a density-based quiver of a single fly, for a region of interest given by 2D grid. |
myBinomTest.m |
External function. Performs a binomial test of the number of successes given a total number of outcomes and a probability of success.
Reference: Matthew Nelson (2015). https://www.mathworks.com/matlabcentral/fileexchange/24813-mybinomtest-s-n-p-sided MATLAB Central File Exchange. Retrieved February 9, 2016. |
patchline.m |
External function. Efficiently plots lines as patches.
Reference: Reference: Brett Shoelson (2023). https://www.mathworks.com/matlabcentral/fileexchange/36953-patchline MATLAB Central File Exchange. Retrieved September 18, 2023. |
circfit.m |
External function. Fits a circle in x,y plane.
Reference: Izhak bucher (1991). https://www.mathworks.com/matlabcentral/fileexchange/5557-circle-fit MATLAB Central File Exchange. Retrieved November 14, 2022. |
p_poly_dist.m |
External function. Computes distance from point to polygon.
Reference: Michael Yoshpe (2008). https://www.mathworks.com/matlabcentral/fileexchange/12744-distance-from-points-to-polyline-or-polygon MATLAB Central File Exchange. Retrieved November 8, 2022. |
Figures |
|
Figures | Folder containing graphs found in paper figure panels. Graphs are generated from behavioral data scripts using preprocessed data. |
Agent-based modeling |
|
ABM-Drosophila_Main.py |
Python script containing functions to run agent-based simulation of fruit fly locomotion in arbitrary arena shapes. See file comments for dependencies.
GitHub repository: https://github.com/tomalisch/ABM-Drosophila |
Ymaze.png | Y-maze arena shape used in agent-based simulations. |