Measuring the repertoire of age-related behavioral changes in Drosophila melanogaster

Aging affects almost all aspects of an organism -- its morphology, its physiology, its behavior. Isolating which biological mechanisms are regulating these changes, however, has proven difficult, potentially due to our inability to characterize the full repertoire of an animal's behavior across the lifespan. Using data from fruit flies (D. melanogaster) we measure the full repertoire of behaviors as a function of age. We observe a sexually dimorphic pattern of changes in the behavioral repertoire during aging. Although the stereotypy of the behaviors and the complexity of the repertoire overall remains relatively unchanged, we find evidence that the observed alterations in behavior can be explained by changing the fly's overall energy budget, suggesting potential connections between metabolism, aging, and behavior.


INTRODUCTION
Aging is a biological process that affects nearly all organisms, resulting in profound changes to their morphology, physiology, and behavior [1][2][3]. While there exists variability in the precise form and timing of these alterations, stereotyped patterns of aging-related change are commonly observed at scales ranging from molecules to tissues to the entire organism [4]. However, we lack a comprehensive framework for predicting how the multifarious age-related changes at the molecular and neuronal level directly lead to behavioral changes.
While many age-related changes in behavior are due to direct reductions in an animal's capacity for movement (e.g., arthritis in humans or wing damage in flies), another commonly posited hypothesis is that aging effects in behavior can be partially understood as an alteration in an animal's energy budget [5,6]. In other words, while the organism may still be able to physically perform most activities within its repertoire, its reduced metabolic efficiency might impose constraints on an animal's total amount of energy to expend, leading to agerelated changes in its behavioral repertoire. This idea, that the available energy an animal possesses would have systemic effects on its chosen actions, is reminiscent of the "hydraulic" theory of action selection that was popularized by Lorenz and others [7] and might be related to molecular models of metabolic decline such as insulin pathway modifications [8][9][10].
Testing the hypothesis that age-related alterations can be understood through alterations in energy budgets, however, has proven difficult, partially due to the limitations in our ability to accurately measure full repertoires of behavior across time. Aging is a complex, dynamical process that cannot be measured at a single timepoint, but, rather, it must be characterized as a trajec- * gordon.berman@emory.edu tory across a lifetime. Accordingly, to measure how animals' behavioral repertoires and their usage alter with age, we need to have not only a framework to measure repertoires at the timescale of single stereotyped movement (order of tens of milliseconds to seconds), but also new analysis methods to isolate the between-age-group variability from the within-age-group variability in these behaviors, finding combinations of behaviors that best describe the dynamics of aging.
In this paper, we study the age-related changes in the behavioral dynamics of the fruit fly Drosophila melanogaster, a common model system for the study of aging and behavior [11][12][13][14]. We measure the full repertoire of behaviors that flies of varying ages perform. While previous research on aging and behavior in flies focus on how only a small number of behaviors change with age, here, by quantifying the full repertoire of behaviors that the animals exhibit in our experimental conditions, we can observe how behavioral performance, in terms of both usage frequency and context-dependent usage (e.g., transition probabilities), changes with age. To measure the animals' behavior, we use an unsupervised method that identifies the stereotyped behaviors that the fly performs without a priori behavioral definitions -behavioral mapping [15]. Our results show that (1) large changes and a sexual dimorphism in how the behavioral repertoire changes with age; (2) despite these changes, the overall complexity of the flies' behavior remains unchanged; (3) as the fruit flies age, their behavioral repertoires alter, but the behaviors are still performed with similar stereotypy; (4) we can explain most of the inter-age-group behavioral variability that we observe by using an estimation of average power consumption. Thus, we provide evidence that the energy budget that an animal has available may be a key factor in regulating its behavior with age. This result encourages further investigation into the physiological basis of aging, lending credence to hypotheses that link metabolic decline to age-related behavioral changes in animals.

Experiments and behavioral densities
In order to characterize how flies' behavioral repertoires changes with age, we imaged flies (Drosophila melanogaster ) in a largely featureless environment (see Materials and Methods for details). In total, we imaged 304 flies (155 male and 159 female), each aged between 0 and 70 days old. To measure the flies' behavioral repertoires, we use the behavioral mapping approach originally described in Berman (2014) [15]. In brief, this method uses image compression techniques to measure a time series of the fly's postural dynamics, computes a continuous wavelet transform to isolate the dynamical properties of these time series (i.e., finding which parts of the body are moving at what speeds), and uses t-Distributed Stochastic Neighbor Embedding (t-SNE) to perform dimensionality reduction on the amplitudes of this transform, creating a 2-dimensional probability density function over the space of postural dynamics. We refer to the arrangement of peaks within this probability density function as our behavioral space.
Each peak within this density represents a distinct stereotyped behavior (e.g., grooming, running, idle, etc.). Thus, the relative probabilities of observing a fly within each peak in the density is a measure of the animal's behavioral repertoire, seen in Figure 1A. Following the procedure described in Cande (2018) [16], all fliesincluding all males and all females of all ages -were embedded into the same space in order to facilitate comparisons between individuals, sexes, and ages. We isolate the individual peaks by applying a watershed transform [17] to segment the density into 122 discrete states, with near-by regions corresponding to similar behaviors (Figure 1B). The density for all the males can be seen in Figure 1C, and the density for all the females in Figure  1D. These behavioral densities provide the foundation for our analysis, as we use them to quantify how behavioral repertoires change with age.

Quantifying behavioral changes with age
Dividing the males and females each into two-weekinterval age groups (Figure 2), we observe a sexual dimorphism in how their behaviors change with age. Specifically, the younger male flies mostly perform idle behaviors. In mid-life, they perform more active behaviors before again becoming lethargic in later life. Conversely, the females perform active behaviors when young, and gradually begin to perform more idle behaviors as they increase in age (excepting the last age group, which is likely under-sampled). While these results could have been found with center-of-mass tracking or other less computationally intensive methods than behavioral mapping, that our method replicates previously observed experimental results [12], provides additional confidence in the analyses to follow.
While the data plotted in Figure 2 displays how flies' mean behavioral profile alters with age, there also exist significant variance and co-variance within sex and age groups [18][19][20]. Thus, we need to isolate the variance in our data that is associated with changing age, rather than from inter-age-group variability. To quantify the inter-group behavioral variance structure, we measured the behavioral covariance matrix across all sex/ages, providing a quantification of the behaviors that are shifting together with age, and the latter quantifies the withingroup variability.
Our analyses here use the discretized version of the behavioral densities, using the watershed-transformderived regions shown in Figure 1B. P P P (i) is a vector of probabilities, where, P (i) j is the the time-averaged probability that fly i performs behavior j during the one hour filming epoch -we call this vector our behavioral vector. Given these values, we can then calculate the average behavioral density for all individuals within each sex/age group. We define this group-specific mean behavioral vector to be µ µ µ (z) k , where z ∈ {male, female} and k is the age group. From these means, we can then compute the covariance matrix of the set of mean behavioral vectors, M ≡ µ µ µ This covariance matrix (C (M ) ≡ Cov(M )), shown in Figure 3A, quantifies which behaviors are likely to increase or decrease with respect to each other across sex/age groups. To further quantify the structure within C (M ) , we calculate its eigenvectors and eigenvalues . Because the covariance matrix is, by definition, real-valued and symmetric, all of its eigenvalues must be greater or equal to zero. We focus here on only the modes corresponding to the two largest eigenvalues, as only these two modes have eigenvalues that are significantly larger or similar in value to those from a covariance matrix derived from independently shuffling each of the columns in M . Although there is not a clear interpretation of these two eigenvectors (v 1 andv 2 ), both appear to capture the relative performance of idle and locomotory behaviors, and the first also appears to capture the relative usage of slow vs. fast locomotion. By plotting the projection of each fly's behavioral vector as a function of age and finding Gaussian-smoothed average curves (see Materials and Methods), we see how this low-dimensional space of behaviors alters as the flies age ( Figure 3D). There is a clear sexual dimorphism in the projections onto the first eigenmode, with the male flies exhibiting non-monotonic dynamics with age, whereas the female's average curve is largely monotonically decreasing. A similar dynamic can be observed in the second eigenmode but with a more subtle shift, as well as a sign flip. These results agree with the visual intuition from Figure 2 and provide a quantification of the most important changes in the flies' behavioral repertoire with age.

Estimated Energy Consumption Alters with Age
As stated in the introduction, a potential mechanism for the flies' observed changes in behavior could be an overall reduction in the flies' energy budget with age. While it was not possible to directly measure the power consumption from the animals in our experiments, we can instead estimate the metabolic cost of the observed behaviors with a biomechanical model.
Given that the flies are constrained to move within a two-dimensional environment, we focus our modeling efforts on estimating the cost of legged locomotion within the arena (making the assumption that non-locomotion behaviors like grooming are negligible in energetic cost compared to locomotion, see Materials and Methods for further justification). Our model of the power consumption during locomotion largely follows that of Nishi (2006) [21], which estimates the heat dissipation and work done during each swing and stance phase of locomotion at a given velocity using a biomechanical model of force production during legged locomotion (see Materials and Methods for details). While this model has several free parameters related to the fly morphology and how gait dynamics alter with speed, we use morphological and scaling data from the literature on legged locomotion [22,23] to set these parameters. More precisely, we wish to calculate R(v), the specific power (mechanical power per unit mass) required for the fly to move at a speed v.
From tracking the center-of-mass of each fly, we are able to measure p i (v), the probability density function for speed for fly i, for each animal. Given this distribution and our expression for R(v), we can calculate the average specific power consumption,R i for each animal through numerically integratinḡ where v max is the largest observed speed for the flies.
To make this calculation more tractable, we find that for biologically realistic range of locomotion speeds (0- 17m/s 2 , and c = .0002m 2 /s 3 ), as shown in Figure  4A.
The results of this calculation for each individual animal are shown in Figure 4B as a function of age. While there is significant scatter in the data (likely due to variance in the internal activity state of the flies [18,24]), when we compute a smoothed average of the data, a clearer portrait emerges. Specifically, we observe that these curves are reminiscent of the sexual dimorphism we observed in the inter-group eigenvector projections in Figure 3. More quantitatively, we see that when plotting the eigenvector projections versus the group-average specific power ( Figure 4C), we see a high degree of correlation for each of these values. As seen in the figure, we can explain at least 72% of the aging-specific behavioral   3C (bottom)). Note that at over 70% of the mean aging-specific variation can be explained using the first two eigenmodes. variation can be explained using a linear fit to the estimated specific power consumption. Thus, these analyses imply that most of the age-related changes we observe in the animal's behavior are correlated with changes in the average energy expenditures of the flies.

Complexity of the Behavioral Repertoire
Although we show that most age-related changes in fly behavior are correlated with energy consumption, it still may be possible that other factors such as the complexity of the behavioral repertoire or the degradation of stereotyped behaviors might also be observed as the animals age [25,26]. We test the former of these hypotheses by calculating the entropy of the behavioral space, using this metric as a proxy for the overall repertoire complexity.
Specifically, we measure the entropy, H i , of each individual fly's behavioral density according to where ρ(x, y) is the probability distribution over the twodimensional behavioral space. Plotting H i as a function of the flies' ages ( Figure 5), we see no discernible trend in entropy vs. age, with the best fit slopes showing a value of −0.00 ± 0.03 for the male flies and −0.01 ± 0.03 for the female flies. Thus, even though the behavioral densities are dramatically changing with age, the overall complexity remains largely unaltered, and thus we cannot conclude that the complexity of the repertoire degrades with age.

Long Time Scales and Hierarchical Structure in Behavior with Age
While the complexity of the behavioral repertoire remains unchanged, the complexity of how the animals traverse through this space over time might still show significant deviations. Prior investigations into the complexity of fly behavioral sequences have shown that these dynamics of transitions between stereotyped behaviors exhibit long time scales and hierarchical organization [18,24]. A hypothesis for aging-related behavioral change is that the structure of the behavioral repertoire becomes less complex with age [25,26], and with the detailed measurements of behavior described here, we can test this idea, potentially gaining insight into changes occurring to the internal programs that may generate these patterns.
First, to assess the overall timescale structure of the flies' behavioral patterns, we measure the transition matrix at different time scales, where i and j as two stereotyped behaviors, S(n) is the behavioral state of a system at transition n (note: to decouple waiting time in a state from complexity in the order of pattern of transitions between states, we measure time in units of transitions, following the methods in [24]). We can decompose each of these matrices via where u µ i and v µ j are the i th right and j th left eigenvectors of the matrix, respectively, and λ µ is the eigenvalue with the µ th largest modulus. Because the columns of each of these matrices must sum to one, λ 1 (τ ) = 1 for all values of τ , and |λ µ>1 (τ )| < 1 by the Perron-Frobenius Theorem. While for a Markov Model, the eigenvalues should decay exponentially with τ , we find that flies in all sex and age groups exhibit super-Markovian time scales ( Figure 6 shows the results for the second-largest eigenvalues in each transition matrix). With the exception of the > 56 day-old females (for which we had fewer individuals in our sample), however, we found no significant difference between the time scales across age groups.
While the complexity of the repertoire or the overall timescale might not be changing with age, the underlying structure of the behavioral transitions might still be altering. To test for this possibility, we applied a predictive clustering analysis to the space to identify groupings of behaviors that best preserve information about the long timescale structure in our data. More precisely, we would like to find a partition of our behavioral space, Z, such that this representation has a simple of a representation as possible, while still maintaining information about the future behavioral states of the animal. Here, we achieve this using the Deterministic Information Bottleneck (DIB) approach [27,28], which minimizes the functional where Z is our partition, H(Z) is the entropy of the partition, and β is a Lagrange multiplier that modulates the relative importance of simplicity and predictability. We perform this optimization for several values of τ for each age group, in all cases varying β and the number of initial clusters in Z to create a full curve of values (see Materials and Methods for details). The resulting clusterings for τ =100 with five clusters can be seen in Figure 7. As with the eigenvalues in the previous plot, the clusters obtained via this approach remain nearly constant with varying age, with only smallprobability behaviors flipping between regions. Thus, we lack evidence of significant alterations of the temporal complexity of the flies' behavior with age.

Stereotypy
Lastly, while we observe no significant changes to the flies' repertoire or temporal complexity, we still can measure if there is deterioration in how the behaviors are performed, potentially implying that the flies are undergoing a physical deterioration or some other inability to consistently perform behaviors while aging. To assess changes in how stereotyped behaviors are performed, we measure how much the performance of individual behaviors are altered with age, quantifying a decreased stereotypy with an increase in the variance of the postural trajectories underlying the performance of these actions.
We divide the data into age groups of two week intervals, with a one week overlap (0-14 days, 8-21 days, 15-28 days, etc.), finding the postural trajectories associated with the performance of each behavior. While the details of this can be found in Materials and Methods, broadly, we use a phase-reconstruction method (based on Revzen (2008) [29]) across all of the postural modes for each time a behavior is performed. We measure the mean postural dynamics across all individuals in a given sex/age group and assess the stereotypy of each behavior (b) in each age group (κ) with our Stereotypy Index, χ b,κ , which is the fraction variance explained by the mean trajectory for that behavior. Thus χ b,κ → 1 implies that each time the behavior is performed, its postural trajectories are exactly the same (maximally stereotyped), and χ b,κ → 0 implies that the postural trajectories are different each time the behavior is performed (minimally stereotyped).
The values of χ b,κ for each behavior and three different age groups are displayed in Figure 8A. By eye, we can see only minimal changes across the age groups (and no statistically-significant changes when accounting for multiple hypothesis corrections). Note that a few behaviors, while stereotyped, were not performed enough to get a good estimate of their synchronization parameters so those behaviors are listed as having a synchronization parameter of 0.
To quantify this lack of change across the whole behavioral repertoire, we calculated the average stereotypy for each age group, where G κ is the set of all flies in age group κ, N κ is the number of flies in the group, and P is the fraction of time that fly i performs behavior b. We then measured the difference in the average stereotypy the youngest age group and each of the subsequent age groups for each sex (χ κ −χ 0 ). Figure 8B shows the results of this calculation for both the males and females. Although we do observe some changes between the age group, they are within 1.5 standard deviations. Thus, although the probability of choosing a behavior changes with age, each behavior, when performed, is, on average, no less stereotyped.

DISCUSSION
In this paper, we measured the behavior of fruit flies (D. melanogaster ) at many points along their lifespan, aiming to isolate patterns of behavioral change with age and to make predictions about the physiological basis of these changes. Consistent with previous studies, we found a sexual dimorphism in changes in the animals' overall activity level, but we also identified subtler patterns of change with age by measuring the largest eigenvalues, and their corresponding eigenvectors, of the interage-group covariance matrix. Despite observing no significant changes in the repertoire complexity or stereotypy with age, we find that most of the age-specific behavioral alterations can be explained by a model of energy consumption, implying that energy budget may play an overarching role in regulating aging behavior.
This observation that energy may play a key role in aging-specific changes in behavior is in accordance with results from long-lived mutants in a variety of species, many of which have changes in gene regulation pathways that affect energy availability [30]. For example, mutations in the insulin/IGF-1 receptors or homologs, which promote food storage and cell replication, have been shown to extend lifespan in flies [31,32], nematodes [10,33], and rodents [34]. In addition, another long-lived fly mutant, the E(z) histone methyltransferase heterozygous mutation, is associated with large alterations in a variety of metabolic regulation pathways [35]. In addition, these changes were found to exhibit sex-dependent effects, similar to our results as well.
In future efforts where behavioral repertoire and metabolic state could be simultaneously assayed (through, for example, proteomic or transcriptomic measurements), we would expect to find correlations between position along the the curves seen in Fig. 3D and key metabolic regulators. Through this methodology, it may be also possible to provide an effective age for each individual in a heterogeneously aging population, providing a phenotyping tool for identifying new molecules involved in increased and decreased longevity, as well as for the study of evolutionary aging dynamics.
While the analysis framework detailed in this paper should be generalizable to other data sets, including other species [36,37] and neuroimaging data [38], the data used in this study present several limitations that need to be studied in future work. First, despite the wide range of behaviors we observed in our assay, many natural behaviors, including courtship and flying, were not measured here. Flight in particular is likely a large source of oxidative stress and potential injury for the animals, likely creating more opportunities for decreased stereotypy and the degradation of behavioral performance. Additionally, due to technical constraints in our experimental set-up, we only imaged flies for one hour during their life. Future studies would benefit from having longer recording epochs -up to the animal's full lifetime -that could capture the influence of circadian rhythms and could more ably measure inter-vs. intraindividual variability across the lifespan.
Despite these limitations, this study points a way forward for using full repertoires of behavior to study aging and its physiological underpinnings. Although many of our energy budget-related analyses here could have been performed using center-of-mass tracking alone, by studying multiple actions simultaneously, it becomes not only possible to identify the age-relevant behavioral changes (here, primarily related to locomotion and slow/idle behaviors), but also to control for other possibilities such as the complexity of the animal's usage of its behavioral repertoire or behavioral degradation and to isolate covariances between and within age groups. These measurements allows us to better predict how genetic or neural manipulations may affect aging across individuals and across the lifespan, as well as to make more specific predictions as to what types of physiological factors might play a role in these changes.

Data
The data consist of 304 flies (D. melanogaster), 150 of which are male and 154 of which are female, with ages ranging from 0 to 70 days of age. Each fly was imaged from above for an hour while contained in a featureless dish with sloped sides to prevent aerial movements, following the approach detailed in [15]. Flies were placed into the arena using aspiration and provided 5 minutes to adapt to their environment before data collection. To reduce the effect of circadian rhythms, all recordings occurred between 09:00 and 13:00. The temperature was kept constant at 25 • ±1 • C.

Behavioral Densities
We created our behavioral densities following the data pipeline outlined in [15]. This approach begins with image analysis (segmentation and alignment), projecting images onto postural eigenmodes, Morlet wavelet transforms [39], and a dimensionally reduced embedding via tdistributed Stochastic Neighbor Embedding [40]. We applied a watershed transform [17] to a Gaussian-smoothed density of the resulting points to isolate the individual peaks. We defined behavioral epochs as lengths of time lasting at least 0.05s with low speeds in the behavioral densities, again following the approach of [15].

Gaussian-smoothed Average Curves
For Figure 3D, we applied a Gaussian-smoothed average according to the following equation: Here, t is age, X is the original value of the eigenvector projections, y is the smoothed value of X, N is the number of flies, and σ corresponds to the standard deviation of the projections. For example, Figure 3D is a plot of y vs. t. Error bars for these plots are generated through a bootstrapping procedure.
Specifically, the data ({t i , X i }) are sampled with replacement, and (7) is now applied to this re-sampled data set. This procedure is repeated 1, 000 times (each independently sampled), and the error bars are the standard deviations of these resampled curves at each point in time.

Synchronization Parameter
By treating the fruit flies' postural modes as a phaselocked oscillator, we use the Phaser algorithm [29] to estimate the behaviors' phases, providing a measure of stereotypy. For each behavior, we use the algorithm to map the individual behavioral bouts to a phase variable between 0 and 2π, providing us with a phase reconstruction of our data that we can compare to the original trajectories (the methodology is the same as in [15]). To ensure the phase-averaged orbits are aligned between individuals and bouts, we calculate the maximum crosscorrelation value between orbits for every postural mode separately, which gives our phase offset. After determining which modes contribute to each behavior (we use only modes that have mode-specific synchronization parameters of greater that 0.1), we calculate the synchronization parameter for age group κ for each behavior b across all postural modes γ according to: where y(γ) b,κ (φ) contains the postural projection time series from every bout of behavior b, µ(γ) b,κ (φ) is the phase-averaged orbits for the projection data in is the number of postural modes used, and σ 2 (x) is the variance in x.
By taking the maximum value across the modes, we quantify our stereotypy for each behavior. This value ranges from 0 to 1, where 0 signifies no stereotypy and 1 signifies full stereotypy. This algorithm requires many bouts of each behavior in order to make the calculation.

Deterministic Information Bottleneck
The deterministic information bottleneck algorithm is an iterative algorithm that obeys a set of self-consistent equations: q(t|x) = 1 Z(x, α, β) exp 1 α (logq(t) − βD KL [p(y|x)q(y|t)]) (9) q(t) = x p(x)q(t|x) (10) q(y|t) = 1 q(t) x q(t|x)p(x, y) Here, x ∈ S(n), y ∈ S(n + τ ), t ∈ Z, Z is a normalizing function, and D KL is the Kullback-Leibler divergence between two probability distributions. For a given |Z| = K number of clusters, inverse temperature β, and random initialization of q(t|x), the equations are iterated until (F t − F t+1 )/F t < 10 −6 is satisfied. We performed 24 replicates of the solution using a range of β ∈ [0.01, 500] spaced exponentially, K ∈ [2,30], and τ ∈ [1,4096]. The optimization is done for each value of β until the convergence criterion is satisfied. The resulting solution is then used as the initial condition for the next value of β.
Here, H st is the heat dissipation during the stance phase, and H sw is the heat dissipation during the swing phase. Similarly, W st and W sw denote the mechanical work done during the stance and swing phase, respectively. In these equations, n is the number of legs, γ represents the ratio of heat dissipation to mechanical work, and α is the amplitude of the torque required to maintain a bent leg posture. The rest of the parameters are defined in Table I where T is the gait cycle period.
Using this model, we can estimate the relative mechanical cost of grooming compared to locomotion by the quantity e sw h +e sw w e st h +e st w , since the animal is moving its legs but is no longer having to expend excess energy to propel itself forward during the stance phase. Across all speeds, this ration is ≈ 10 −7 , justifying our treatment of all zero-velocity epochs as having the same energetic cost.