All strains used in this study were maintained under standard nematode culture conditions . Unless mentioned otherwise all animals assayed were of the hermaphrodite sex. The strains and the number of worms analyzed in the calculation of various behavioral metrics are depicted in Additional file 5, Table S2. The data and the images generated for analyses of the avoidance behavior for the mutant strains are available from the authors upon request.
Unless otherwise mentioned mid to late L4 stage worms were picked on 6 cm standard nematode growth media (NGM) plates with agar approximately 24 h before the assay. Assay plate preparation: 10 cm plates containing 10 ml of agar medium (17 g of agar (Difco, Detroit, MI, USA), 2.7 g of Bactopeptone (Difco), 0.55 g of Tris base (Sigma, St. Louis, MO, USA), 500 μl of 1(M) Tris HCl (Sigma), 2.0 g of NaCl (Fisher Scientific, Pittsburgh, PA, USA), and 1 ml of ethanol containing 5 mg/ml cholesterol (Sigma), per l H2O). Plates were stored at 4°C and used within 2 weeks. A total of 100 μl of Escherichia coli (op50) approximately 0.6 to 0.8 OD was spread evenly on the agar plates at least 16 h prior to the assay. On the day of the assay single worms were transferred to the agar plates seeded with bacteria and kept at 20°C for at least 10 minutes. The worms were then subjected to thermal stimulus as described below.
Thermal stimulus assay
Worms were imaged using a Leica MZ16APO stereomicroscope and a Basler firewire CMOS camera (A602fm; Basler, Ahrensburg, Germany). A collimated beam with a 1/e diameter of 1.50 mm from a 1,440 nm diode laser (FOL1404QQM; Fitel, Peachtree City, GA, USA) was positioned to heat the area covering the worm. The diode laser was driven with a commercial power supply and controller (LDC 210B and TED 200C; Thorlabs, Newton, NJ, USA). A custom program written in LabVIEW (National Instruments, Austin, TX, USA) was used to control the firing, power, and duration of the infrared (IR) laser, while simultaneously recording images of the crawling worm for 15 s at 14 or 28 Hz. Images were processed offline using custom programs written in LabVIEW and MATLAB (Mathworks, Natick, MA, USA). A thermal camera (ICI 7320, Infrared Camera Inc., Beaumont, TX, USA) was used to measure the temperature of the agar when heated by the IR laser. We were able to generate thermal pulses with a temperature change ranging from ΔT = 0.4°C to 9.1°C with ramp rates ranging from 0.8°C/s to 18°C/s respectively. These ΔT were measured from the baseline temperature (or room temperature), which was typically approximately 20°C.
The behavior of the worms upon response to a thermal stimulus was quantified in multiple ways. Speed profile of each worm over time was generated by a custom written program in MATLAB and LabVIEW that monitored the position of the Center of Mass (COM) of the worm image. The behavioral states of the worm were identified using programs to automatically and semiautomatically identify stereotyped worm behaviors from sequence of captured images. All analysis described below was performed separately on the 14 fps and 28 fps data. Once processing was complete, the 14 fps data was upsampled, converted from frames to time (in seconds) and combined with the 28 fps data to produce the final results.
The images were run though a skeletonization algorithm written in MATLAB to find the endpoints of the worm in each frame. The curvature of the perimeter was used to identify the head and tail, since the maximum curvature is found at the tail. The endpoints and centroid were tracked frame by frame for each dataset, and the automatic detection of events in each frame is outlined below.
It is assumed that the worm is going FORWARD at the moment the thermal stimulus is applied. All frames at the beginning of the behavioral quantification are marked as FORWARD, unless they meet the criteria of another behavioral marker, namely an OMEGA TURN, a REVERSAL, or a PAUSE.
Criteria for an OMEGA TURN
(a) When the head to tail distance is less than half of the maximum head to tail distance, the frame is tentatively flagged as the start of an omega turn. (b) If the frame flagged in (a) also corresponds to a COM speed of < 1 pixel/frame, this frame is flagged as the start of an omega turn. (c) The end of the omega turn is flagged when the head to tail distance is greater than half of the maximum head to tail distance. (d) All frames between the start and end frames are flagged as OMEGA TURN.
Criteria for a REVERSAL: first case
The dataset contains an omega turn. In this case, (a) for frame number 1 to the start of the omega turn, the centroid trajectory is sampled at every 2 frames. If the turning angle is greater than 120 degrees, the frame is flagged as the start of a reversal. (b) The end of the reversal is the start of the omega turn.
Criteria for a REVERSAL: second case
The dataset does not contain an automatically detected omega turn. In this case, (a) for all frames in the data set, the centroid trajectory is sampled at every 2 frames. If the turning angle is greater than 120 degrees, the frame is flagged as the start of a reversal. (b) The end of the reversal is flagged as when there is another turning event greater than 120 degrees in some frame after the frame flagged in (a). All frames between these two frames are marked as the worm is in a reversal. The reversal detection then repeats to see if there are any other reversals after the first detected reversal.
Criteria for a PAUSE
If the COM speed is less than 7 μm per frame, the head to tail distance is concurrently at least three-quarters of the maximum, and these conditions are both met for three consecutive frames, the worm is said to be in a pause state until the COM speed becomes greater than 7 μm per frame.
The aforementioned thresholds for the behavioral flags were determined using N2 data. For strains with severe locomotory defects, thresholds were adjusted on a case-by-case basis. The user verified the automatic flagging of these behavioral states and changed any erroneous/missed flags by eye.
Statistical analyses were performed in the R programming language  using the following add-on libraries: ClassDiscovery , Lattice , RColorBrewer , and ggplot2 .
Generation of behavioral barcodes
We generated behavioral profiles of 48 strains in response to thermal pulses corresponding to ΔT = 0.4°C, 1.0°C, 4.8°C and 9.1°C. Initially we characterized behavioral responses of the reference strain N2 at these stimuli. There were five features that consistently changed as a function of increasing amplitude of the thermal pulse and thus we used these for further analysis. We quantified four additional behavioral responses of a forward moving worm when presented with a thermal pulse by calculating the transition probabilities FF, FR, FO, and FP (that is, forward to forward, reversal, omega turn, and pause respectively). FF captures worms not responding to the thermal stimulus, that is, continuing their forward motion. Any three of these features would distinguish worms not reacting to the thermal stimuli from ones that do react. We extracted 8 features (Figure 3I) from escape responses of the 47 additional strains. Thus at each ΔT we generated a matrix of 48 strains by 8 features. As these features, f, were measured in different units we normalized them across all strains to a Z-score, Z = [f - mean (f)]/SD(f), where SD is the standard deviation of a given feature. We generated four such matrices shown in Figure 3I, where each column corresponds to a feature with mean = 0 and SD = 1.
Hierarchical clustering to identify strains behaving differently from N2
To identify strains that behaved differently from the reference strain N2 at each ΔT, we used agglomerative hierarchical clustering. We used the Euclidean distance to define the proximity of strains to one another, and used Ward's method to define the distance between two clusters, which determines the cluster structure by minimizing the sum of squares when two clusters are joined. Finally we presented the results of the clustering as a dendrogram as shown in Figure 4. The add-on package Lattice in the R statistical language platform was used to generate the dendrograms. Hierarchical clustering procedures such as the ones we have used will always generate clusters from any given dataset. To determine the robustness of the clusters generated by the method above, we used a bootstrapping method  where we repeatedly resampled the 48 strains with replacement and obtained the number of times each pair of samples ended up in the same branch of the dendrogram. We performed 10,000 bootstrap clustering generating 4 clusters for each round of bootstrapping. Next we determined the fraction of time each strain belonged to the same cluster as N2. Finally, we assigned strains that remained outside the N2 cluster in 90% of the 10,000 bootstrap clusters as different from N2 in their behavioral barcode. These operations were performed using the R add-on package ClassDiscovery. We performed the above clustering procedure separately on the four matrices shown in Figure 3I. The results of the bootstrapping are depicted in Figure 4.
Principal components analysis to identify strains behaving differently from N2
The behavioral metrics we used in our analysis are subjectively defined and hence may be correlated with each other. To use independent uncorrelated behavioral metrics in identifying strains different from N2 we used PCA to reduce the dimensionality of the behavioral features. We found that at each ΔT, ≥ 95% of the variance in behavioral metrics could be explained by the first six principal components (Additional file 3, Table S1). We effectively transformed our raw behavioral metrics into a set of six principal components that defined the behavior of the strains in response to the thermal pulses. Next we projected the proximity relationships among 48 strains in this 6-dimensional feature space onto 2 dimensions by using classical multidimensional scaling (MDS). MDS is a procedure for mapping between high dimensional and low dimensional space and helps visualization of the relationships in a lower dimensional space. Essentially it finds a configuration of data points in a low dimensional space (two dimensions in our case) that best captures the proximity of points in a higher dimensional space (six dimensional in our case). After generating a scatterplot by MDS (Figure 5A) we calculated the distance of each of the 48 strains from the reference strain N2. This also allowed us to compare the results with that of hierarchical clustering (red and blue dots in Figure 5A). To select a criteria for strains different than N2, a distance d_0 was chosen that separated the three strains shown to be different than N2 at ΔT = 9.1°C using hierarchical clustering and ANOVA. Then we assigned any strain that was ≥ d_0 away from N2 as behaving differently from N2 at all ΔT. The distances that we measured and plotted in Figure 5B were thus a quantification of the visualizations in Figure 5A.
The above two methods of predicting strains that behave differently from N2 at a given ΔT uses the mean of behavioral features and hence does not take into account the underlying distribution of the data. To verify the strains predicted to be different from N2 at each ΔT by the above two methods, we performed Kruskal-Wallis test followed by Dunn's multiple comparison test  for each of the behavioral metrics. We considered two strains to be significantly different at a confidence level of P ≤ 0.01 for at least one of the behavioral metrics we analyzed.
The speed profiles we present in the Figures 6, 7 & 8 are a global summary of the parameters we used for the analyses to determine the significance of difference between two strains. The significance of the differences in behavioral metrics (quantified from the speed profiles) of a mutant strain from N2 was determined by Kruskal-Wallis test followed by Dunn's multiple comparison. We have referred to mutant strains as 'significantly' different from N2 in the Results section, if at least one of the metrics derived from the speed profiles differed significantly from N2 at a confidence level of P < 0.01.