We thank D. Pimentel for electrophysiology advice and C. Chintaluri and M. Murphy for discussions. N. Bonini, B. Dickson, B. Ganetzky, J. Hall, T. Holmes, K. Ito, H. Jacobs, L. Luo, J. Ng, J. Phillips, F. Rouyer, G. Rubin, R. Stocker, P. Taghert, Z. Yan, the Bloomington Stock Center, and the Vienna Drosophila Resource Center provided flies. This work was supported by grants (to G.M.) from the Wellcome Trust and the Gatsby Charitable Foundation. A.K. held postdoctoral fellowships from the Swiss National Science Foundation and EMBO; S.M.S. was a Commonwealth Scholar.

Reviewer information

Nature thanks James Hodge, Yasuo Mori, Michael Palladino and the other anonymous reviewer(s) for their contribution to the peer review of this work.