Figures
Abstract
Biological processes involve movements across all measurable scales. Similarity measures can be applied to compare and analyze these movements but differ in how differences in movement are aggregated across space and time. The present study reviews frequently-used similarity measures, such as the Hausdorff distance, Fréchet distance, Dynamic Time Warping, and Longest Common Subsequence, jointly with several measures less used in biological applications (Wasserstein distance, weak Fréchet distance, and Kullback-Leibler divergence), and provides computational tools for each of them that may be used in computational biology. We illustrate the use of the selected similarity measures in diagnosing differences within two extremely contrasting sets of biological data, which, remarkably, may both be relevant for magnetic field perception by migratory birds. Specifically, we assess and discuss cryptochrome protein conformational dynamics and extreme migratory trajectories of songbirds between Alaska and Africa. We highlight how similarity measures contrast regarding computational complexity and discuss those which can be useful in noise elimination or, conversely, are sensitive to spatiotemporal scales.
Citation: Schuhmann F, Ryvkin L, McLaren JD, Gerhards L, Solov’yov IA (2023) Across atoms to crossing continents: Application of similarity measures to biological location data. PLoS ONE 18(5): e0284736. https://doi.org/10.1371/journal.pone.0284736
Editor: Abel C.H. Chen, Chunghwa Telecom Co. Ltd., TAIWAN
Received: July 5, 2022; Accepted: April 6, 2023; Published: May 15, 2023
Copyright: © 2023 Schuhmann et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.
Data Availability: All program files are available at gitlab.uni-oldenburg.de/quantbiolab/simbols.
Funding: This study was funded by the Volkswagen Foundation in the form of a Lichtenberg Professorship to IAS, by the DFG, German Research Foundation in the form of funds to IAS [GRK1885 - Molecular Basis of Sensory Biology; SFB 1372 – Magnetoreception and Navigation in Vertebrates], and by the Ministry for Science and Culture of Lower Saxony in the form of funds to IAS [SMART; DyNano].
Competing interests: The authors have declared that no competing interests exist.
1 Introduction
With the advent of big data in biological systems spanning nanoscale to global networks, recent advances in heuristic, statistical, and machine learning approaches offer a variety of tools and methods to assess spatiotemporal patterns in biological applications [1–3]. An ongoing challenge is to quantify and compare sequential spatiotemporal processes, which can involve confounding environmental and individual-based factors, as well as be affected by the frequency, accuracy, and precision of measurement [4]. Various measures of data similarity have been applied to classify and compare individual movement trajectories in both anthropogenic and ecological applications [5–7], and submolecular-scale movements of proteins [8, 9].
Biological data sets inevitably contain noise, for example, through limits in measurement precision and accuracy, but also through actual movement not relevant to the questions of interest. For example, atoms in a protein may undergo Brownian motion at the nanometer scale, while migrating birds can forage and relocate up to hundreds of km during extended stopover periods, independently of their long-distance migratory orientation and navigation process per se. [10, 11]. It is, therefore, natural to expect that the similarity measures of biological data will behave differently at different spatial and temporal scales.
The present study discusses known similarity measures that are potentially useful in life science applications and conveniently bundles them together in a newly developed python package SiMBols (Similarity Measures for Biological Systems). The similarity measures provide tools to compare two data sets (trajectories), where difference in similiarity may reflect an effect of a perturbation, deviation or variation in the studied system. For example, reduced magnitudes in similarity may reflect a conformational change of a protein or variability in flight schedules and trajectories of migratory birds. More generally, the similarity measures allow the quantification and assessment of the similarity or difference between two entities in both time and space.
The basic principle of a similarity measure is to compare two data sets that correspond to spatial or temporal variation. For example, these variations can describe the changing position of a residue in a protein or provide location information of a bird as it migrates across continents. Recent studies have highlighted the broad usability of similarity measures to distinguish among known contrasting synthetically simulated and measured trajectories [5, 6].
To demonstrate how SiMBols and its similarity measures can be used in life sciences, we have applied the similarity measures listed in Table 1 to two distinct but related examples. The measures were applied to biological data related to magnetic field sensing in migratory birds [12–16]. At the microscopic level, the cryptochrome 4 protein [17] was suggested to be a specific receptor inside migratory birds to endow them with a magnetic compass sense [18]. Upon its biological activation, the protein is expected to change its conformation, which leads to a distinct biological function [13]. The change in cryptochrome dynamics upon activation calls for similarity measure analyses [9]. On the macroscopic level, the migratory orientation and movement of birds are also influenced by the Earth’s magnetic field [15, 16], and can also be assessed using similarity measures [5, 6]. Differences between their individual flight trajectories can additionally be important in assessing ecological hazards, conservation concerns and anthropogenic impacts [19, 20]. For example, the migratory songbird Northern Wheatear (Oenanthe oenanthe) undertakes twice-yearly cross-continental journeys between Alaska and Africa [21]. In the present paper, we apply the different similarity measures to the data sets available for both examples to showcase that such an analysis can produce either a noise-filtering or signal-inhibiting effect. For this, we have developed a python-based program package that provides straightforward usability of several similarity measures and data sets. We show that the results depend on the peculiarities of a specific example and lead to enhancing or inhibiting certain features of the analyzed data. With the performed analyses, we argue that similarity measures can serve as a powerful tool to quantify and understand spatiotemporal variability for many dynamic biological processes.
The table shows the different studied similarity measures and the corresponding abbreviations. Additional information on the similarity measure is also provided and explained further in the text.
2 Methods
Similarity measures quantify the difference between two spatiotemporal datasets, called trajectories. A trajectory can be defined as an ordered sequence of locations. A single location within a trajectory is called an element. In the present study, all locations are considered to be in three-dimensional space. In some cases, a trajectory needs to be reduced to three probability distributions with each distribution containing information from a single spatial dimension of the three-dimensional trajectory.
Here, we introduce each studied similarity measure heuristically. Rigorous definitions, algorithmic implementations, characteristic runtimes, and detailed specific properties are given in the supporting information, S1 File. In general, the similarity measures considered can be described as being either aggregated or bottleneck measures. Attributes for each measure are listed in Table 1. An aggregated measure is influenced by every single element of each compared trajectory. In contrast, bottleneck measures determine a worst-case scenario to calculate the similarity, i.e., the elements from compared trajectories which exhibit the biggest difference determine the similarity. Bottleneck measures can often be identified by their use of maxima. A second attribute of all similarity measures is their dependence on the order of the location elements within the compared trajectories. Biophysical or biological spatiotemporal trajectories will naturally be ordered by design; the distinction, however, originates from the question of whether the similarity measure disregards the given order. The order-independent similarity measures interpret the trajectories as distributions or merely as an unordered set of elements.
The discrete Fréchet distance (DFD) measures the smallest distance between two element pairs belonging to the two trajectories. The trajectories are traversed in order and all elements in both trajectories have to be considered. DFD seeks to determine the largest of the smallest distances calculated, which is then called the similarity between the two trajectories. DFD is a bottleneck, order-dependent measure.
Similarly to DFD, the discrete weak Fréchet distance (DWFD) couples pairs of elements between trajectories, but, in order to minimize the largest distances, allows successive elements to traverse backward (i.e., in reverse order). This addition allows DWFD to react to outliers or evaluate trajectories that merely zigzag around each other as more similar. DWFD is a bottleneck, order-dependent measure.
Dynamic Time Warping (DTW) is a measure that was first used in speech recognition [22]. Given two trajectories, DTW can be used to construct pairs of elements that maintain a consistent order within each trajectory. The collection of such pairs is called coupling, while the goal of the DTW is to minimize the sum of distances between paired elements to establish the optimal coupling. DTW is an aggregated, order-dependent measure.
The Hausdorff distance (HD) defines the similarity measure of two trajectories through the closest neighbor of elements between the two different trajectories. The maximum of all closest neighbor distances is the resulting Hausdorff distance. HD is a bottleneck, order-independent measure.
The longest common subsequence measure (LCSS) returns the number of consecutive elements that the two compared trajectories have in common. To quantify commonality, LCSS requires both a distance threshold (ε) and a time threshold (δ). Two elements in the studied trajectories are defined as common if they are found within the distance and the time threshold of one another. LCSS determines the largest number of consecutive common elements as a measure of the similarity between the two trajectories. LCSS is not a classical distance measure, as it quantifies commonness rather than the distance between two trajectories. LCSS is an aggregated, order-dependent measure.
Differing to all the other similarity measures introduced above, the difference distance matrix (DDM) approach does not compare a pair of trajectories but rather compares structures. Given a structure encapsulating a number of locations, the pairwise distance between all these locations can be calculated and sorted in a symmetric matrix. Once the location data appears to be time-dependent, DDM calculates the time average of the pairwise distances between the locations and sorts the results into a matrix. The same distance matrix can be calculated for a second structure of equal size. At this stage, two matrices describing the distances between all elements in the two structures have been calculated. Considering the element-wise difference of the matrices quantifies the change in displacement from one set to the other. Averaging over all columns of the final matrix yields a comparable result to the other similarity measures. As DDM requires two comparable structures (sets) of trajectories, its application is more limited. The approach was, however, successfully used in earlier studies [9, 23]. DDM is an aggregated, order-independent measure.
The Wasserstein distance (WD) is a similarity measure used for comparing probability distributions. The distribution can be extracted from spatiotemporal trajectories as described above. The WD measure is the sum of distances between the two distributions. It is also known as the earth mover’s distance [24, 25]. WD is an aggregated, order-independent measure.
The Kullback-Leibler divergence (KLD) is also applied to probability distributions. It is also called relative entropy [26] and is commonly used in machine learning [27]. Intuitively, it quantifies how well one can distinguish between two given distributions by summing over the scaled ratio between two corresponding elements of the two distributions. KLD is an aggregated, order-independent measure.
3 Implementation
To calculate and assess similarity measures, we have developed a python package SiMBols, and made it available at https://gitlab.uni-oldenburg.de/quantbiolab/simbols or in the Python Package Index (PyPI). The WD, the HD, and the KLD are already available within the scipy package [28]. DTW has been made available in the dtaidistance package [29]. The preexisting measures were incorporated into the framework such that the same form of input data can be used for all similarity measures. We have implemented DFD, DWFD, DDM, and LCSS directly into the SiMBols package. Our implementation of DFD is optimized for memory enabling comparisons among trajectories comprised of significant amounts of elements. The implementation of DWFD employs graph algorithms supplied by the networkx package [30].
Preprocessing routines are supplied to transfer arbitrary sequences of three-dimensional Euclidean locations into an input format understood by each measure. DTW, KLD, DWFD, DFD, and LCSS have built-in parallelization, allowing for faster computation utilizing multiple CPUs. The python package numpy [31] was used for all described methods.
The computation time for calculating the different similarity measures can differ significantly. An account of the mathematical complexity is given in the S1 File. In order to supply an intuition of the required computation time, all similarity measures were used to compare two sets of 497 trajectories which contained 200 elements each. Table 2 shows the benchmark times to finalize each measurement computed on a single core on Intel(R) Xeon(R) Gold 5218 CPU at 2.30 GHz.
The similarity measures are sorted by the utilized computation time from the fastest to the slowest.
The SiMBols package was originally developed to analyse protein trajectories, before we generalized it to accept arbitrary trajectories. Therefore, SiMBols includes the possibility to read in protein simulation data and not only reduce it to the necessary geometric properties but also align and superimpose two structures of the same length [9] which is necessary for a sensible interpretation of the similarities between protein structure simulations. The reading of protein simulation files is done using the mdtraj package [32], while the structural alignment employs the Kabsch Algorithm [33] as implemented in the rmsd package [34]. An example workflow, including the protein preprocessing tasks, is included in S3 File.
4 Similarity measures in protein conformational dynamics
Investigations of protein activation often focus on motion and dynamical traits. For instance, activation of a protein can induce structural changes that might initiate subsequent biophysical processes which lead to two natural questions: What are the most versatile regions within a protein structure? How is the motion influenced by external perturbations?
Similarity measures provide a tool to answer the raised questions. In earlier studies, DFD and HD have been applied to assess interprotein motions [8]. More recently, developments and increased feasibility of all-atom molecular dynamics (MD) simulations have significantly enhanced understanding of the fundamental molecular biophysical processes [35, 36]. Evaluation of MD results often relies on the analysis of the evolution of a molecular structure and comparison of its temporal trajectory to a single reference structure through the established technique of the root mean square deviation (RMSD) analysis. Alternatively, a comparison of fluctuations within a protein structure may be performed through the root mean square fluctuation (RMSF) approach [37]. Both of these strategies are, however, inadequate when comparing two dynamic trajectories of a protein qualitatively as both approaches only involve a comparison of structures to a reference one and not a dynamic protein trajectory.
Based on an earlier study [9], similarity measures have been applied to address the questions mentioned above. Specifically, the crystal structure of pigeon cryptochrome 4 (ClCry4) [17] was simulated dynamically in two different biological states, characterized through the redox states of the flavin-adenine-dinucleotide (FAD) cofactor and a tryptophan residue (Trp369 = TrpD) [12, 13]. The redox change of these two compounds facilitates a dynamical process within the protein, leading to a structural rearrangement. This rearrangement is thought to initiate a neurological signal transfer that may be linked with the proposed role of cryptochrome in night-migratory songbirds’ magnetoreception [38–40]. The two simulated states of ClCry4 resemble an inactive dark state (DS) and a light-activated radical pair state (RPD) specific to the redox states of the aforementioned FAD cofactor and the TrpD residue.
To investigate short term effects on ClCry4 deactivation and to test for its reversion to the ground state, we simulated the protein with a fully oxidized FAD configuration and an initial conformation taken from the end of the RPD simulation discussed in an earlier study [9]. While this may not accurately reflect the long-term dynamics of the protein reoxidization procedure which involves intermediate states of the FAD over the time course of about 100 μs [41], it allows to assess the similarity of the two different trajectories and illustrate the application of SiMBols for studies relevant to protein conformational changes. We have performed MD simulations, where at the very beginning of the simulation the RPD conformation of ClCry4 assumed the redox states of the FAD and TrpD cofactor as exhibited in the inactive DS. In total, two replica simulations to describe the RPD → DS transition were conducted, denoted as Reverted1 and Reverted2. Additionally, two separate DS and RPD simulations were performed to establish a basis for the similarity comparison measures. A detailed description of the simulation parameters can be found in S2 File.
Employing the different similarity measures, the internal conformational changes associated with the RPD → DS change in ClCry4 were probed to establish whether the rearrangements that were originally observed in the DS→RPD transition revert if the activated protein is assumed inactive.
In order to apply similarity measures, one needs to consider all temporal snapshots for each atom in the protein’s trajectory. Fig 1 illustrates how a trajectory for one atom is perceived. Every amino acid residue in a protein consists of a backbone and a sidechain. Fig 1 features an exemplary Alanine, namely the Ala230 residue from ClCry4. The backbone is the same for all residues and consists of a nitrogen atom, two carbon atoms, and an oxygen atom. The side chain is chemically attached to the carbon atom, which has a bond to the nitrogen (Fig 1B). This carbon atom, denoted as Cα, is thus, consistently placed at the core of each amino acid residue. Therefore, it is favorable to consider the Cα atom as a reference position for each residue in a protein as a well-suited focal point. Hence, the trajectory for a given residue is a sequence of a single location per time instance and should not be confused with the trajectory of the entire protein, which contains the location for all atoms in the protein.
The approach for defining a simulation trajectory used as a measurable instance for similarity measures is visualized. Every residue, in this example alanine 230 of ClCry4, is individually analyzed (A). The trajectory is then considered for the respective Cα atom of the selected residue (B). Over time, the atom moves, yielding an ordered sequence of spatial locations. These locations then form the considered trajectory (C).
The resulting residue trajectories, extracted from the ClCry4 MD simulations, were compared using the similarity measures. Each similarity measure was computed for the respective pairs of ClCry4 states: (DS, Reverted1), (DS, Reverted2), (RPD, Reverted1), and (RPD, Reverted2).
The ClCry4 structure consists of 497 amino acid residues. Following the scheme outlined in Fig 1, 497 individual residue trajectories were created describing the positions of each residue for all timesteps of the performed MD simulations. Every single residue trajectory has its counterpart in the to-be-compared protein simulation. Since the residues are bound to their neighbors, it is natural to expect that once a certain residue experiences a noticeable difference in the similarity measure, its neighboring residues experience some movement as well. This dependency between the individual residue trajectory pairs allows the visualization of the results for all residue trajectories simultaneously, as shown in Fig 2. The figure shows the similarity measures computed for the comparisons of the Reverted1 simulation with both the DS (red) and the RPD (blue) state. The analysis of comparisons for the Reverted2 simulation is shown in S2 File.
Comparison of the residue trajectories for two trajectories (RPD, Reverted1), shown in blue, and (DS, Reverted1), shown in red. The color scale hints towards the location of each residue in the protein structure, mapped onto its cartoon representation. Each similarity measure is computed for a trajectory of the Cα atoms in each residue’s backbone. The graphs show the calculated similarity per residue. A visual comparison reveals a common peak at residues 220–240 (known as the phosphate-binding loop), which was shown to exhibit versatility in movement [9]. The most notable differences in similarity measures can be seen in the non-prominent changes. For instance, a second peak can be observed at residues 40–50, which is hardly visible in the DFD as it becomes less significant among the noise and other fluctuations in the proteins. On the other hand, DTW distinguishes differently between noise and signal, resulting in a better distinguishable peak at residues 40–50. The results for the replica simulations comparison are shown in S2 File.
All similarity measures reveal that the Reverted1 and RPD (blue) trajectories are very similar, with a notable dissimilarity between residue 220–240. These residues form the so-called phosphate-binding loop where the radical pair between FAD and TrpD is formed. On the other hand, for the comparison between Reverted1 and DS (red), more significant dissimilarities have in general been observed. Here, the dissimilarity for residue 220–240 is much greater for all employed methods. Additionally, a notable dissimilarity arises for the residues 40–50 for the majority of similarity measures. The results obtained with HD, DFD, and DWFD exhibit sensitivity to noise and vibrations within a residue (Fig 2, red & blue). The sensitivity to noise, which results in increased fluctuations in comparison to KLD, can be explained by the fact that all three methods (HD, DFD, DWFD) are bottleneck measures. The KLD measure almost ignores small vibrations (noise) in each residue entirely but does not find the second smaller peak around residues 40–50 (Fig 2, red), which is well shown in the plots computed using the WD or DDM measures. The result of the WD calculation exhibits a remarkably similar result to the plots obtained using the DFD and HD measures, suggesting that it might be a computationally efficient alternative to DFD and HD for resolving more pronounced motions. Furthermore, WD might be of particular interest for the analysis of equilibiurm MD simulations, along with the other order-independent measures DDM and KLD, which fits the notion that in equilibrium the order of simulation snapshots should not matter and instead distributions should be considered. The LCSS plot exhibited extremes with the chosen spatial threshold ε = 0.5 and reveal that the phosphate-binding loop, which is near the active site cofactors FAD/TrpD, moves differently compared to other similarity measures plots. The region around residues 40–50 and the C-terminal are also significantly different compared to the other plots shown in Fig 2. Caution needs to be exercised when working with the LCSS measure, as the spatial threshold ε has to be chosen manually, and the magnitude of the threshold is highly dependent on the data used. LCSS is thus highly sensitive to the choice of the parameter ε. Fig 3 visualizes the severe change in the similarity measurement results depending on different ε value. Unfortunately, there is no general guideline to determine the spatial threshold for arbitrary datasets, which is a major drawback of the LCSS similarity measure in the absence of predetermined scales of interest. During an MD simulation, a residue might not move significantly and just experience vibrations and no conformational change. In such a scenario, the start and the endpoint of the temporal trajectory are virtually similar. This peculiarity exhibited by protein trajectories results in an increased sensitivity induced by the choice of the spatial threshold ε because a small threshold will mark the whole trajectory as similar for an immobile residue.
The LCSS similarity for the residue trajectory comparisons for different spatial distance thresholds ε indicate the importance and difficulty in choosing the right ε threshold for LCSS, especially in protein structures, in which some trajectories might merely vibrate.
The protein structures were also analyzed employing the RMSF measure to identify its versatile regions. The results are shown in S2 File. The RMSF analysis reveals, that all protein structure simulations have a versatile region that includes residues 220- 240 and around residues 180–205. The C-terminal is also revealed to be highly versatile. Interestingly, the versatile region around residues 180–205 does is not recognized by the similarity measures.
In biophysical terms, all similarity measure results show a distinct peak at the phosphate-binding loop when comparing the Reverted1 to the DS trajectory. In contrast to this, no such peak is observed for the comparison of Reverted1 with the RPD. Interpreting these differences in similarity in the phosphate-binding loop by employing results from an earlier study [9] suggests that the conformational rearrangements observed during the activation of ClCry4 do not revert for the redox states of the FAD and TrpD cofactors and the ClCry4 structure remains locked in the established RPD conformation. A possible explanation for this behavior might be given by the solvent that was now able to reach the FAD after the phosphate-binding loop moved out of the way and is now blocking the way back, hindering the reverting motion. The effect of the solvent on the FAD might also initiate some further downstream processes or reactions, forcing the ClCry4 protein into an intermediate state.
5 Similarity measures in bird flight trajectories
Macroscopic studies of migratory bird navigation behavior are confronted with a myriad of underlying factors and processes [42], some relating to magnetoreception [15, 16, 43]. Some of these processes may be diagnosable using a selection of the different similarity measures. In this case, the following questions may arise: How similar are the migration routes (trajectories) of two individually traveling birds? Do birds from one specific population or age cohort have similar stopover locations and duration while migrating?
Based on location data from an earlier study [21], we examined the autumnal migration of eight Northern Wheatears (Oenanthe oenanthe, wheatear hereafter) using similarity measures. The measures are compared regarding the birds to showcase which question can potentially be answered with which similarity measure. The wheatear is a night-migrant which travels twice-yearly between the Northern latitudes (Europe, Asia and North America) and Africa. Methods like GPS are not yet suitable for tracking light-bodied songbirds such as the wheatear (< 25 g) across their entire migratory routes. Light-level geolocation is a viable tracking method for doing so, though it only reveals twice-daily location estimates, and is less accurate than GPS [44]. Birds are first captured, typically near the breeding grounds, equipped with geolocators and subsequently released. Once a bird is recaptured and tag recovered, geolocator data yields two locations a day, one in the morning and one in the evening. Since wheatears are night-migratory, the two locations generally do not differ a lot during the day. We, therefore, averaged the two daily locations to form one point in the flight path trajectory. However, the noise due to the geolocation method increases significantly if birds are traveling during the equinox or are close to the equator. In general, the precision of geolocation estimates is in the range of ∼ 100 − 200 km but much less precise (∼ 400 km) in the latitudinal direction when daylength becomes nearly uniform across latitudes, i.e. during periods close to the spring and autumnal equinox and near the equator [45].
More generally, the variability in migratory schedules among individual birds creates deviations that infer problems in the comparison among flight paths. Long-distance migratory birds typically undertake sequences of nightly flights interspersed by extended multi-day stopovers to replenish energy reserves. For the wheatears, autumn stopovers were typically clustered in Kazakhstan and last 5–20 days [21]. Furthermore, individual birds might not only start their journey on different days but also vary in their stopover duration.
Fig 4 illustrates location estimates during autumn migration for three of the eight individual wheatears labeled 7902, 7920, and B070 [21]. The solid lines describe the mean migration trajectories. The colored symbols depict random daily sampled locations of each individual based on the mean and standard (normal) errors in latitude and longitude.
(A-C): Estimated (mean) daily locations (solid lines) with randomly sampled daily location estimates (colored circles) based on geolocator tracking data of three Northern Wheatears (Oenanthe oenanthe) migrating between Alaska and East Africa, with tag labels 7902 (green, A), 7910 (yellow, B) and B070 (pink, C); see [21]). Randomly sampled locations of all three individuals between (D) capture in Alaska and migration across East Siberia and (E) the Arabian Desert and arrival in East Africa. The maps are made with Natural Earth.
While the data in Fig 4A and 4B are visually similar, the location data of individual B070 (Fig 4C) deviates. More precisely, B070 apparently detoured via Mongolia, while the other two individuals remained further North. Additionally, individuals 7910 and B070 exhibit closer spatiotemporal similarity in stopovers during the travel between Alaska and East Siberia (Fig 4D) and across the Arabian Desert to East Africa (Fig 4E) as seen by the more densely placed symbols. Trajectories of the other five recaptured wheatears are found in S2 File.
For the calculation of the different similarity measures, each individual bird’s trajectory was paired with all trajectories of the remaining seven birds. For clarity, we will term these comparisons as similarity between individuals. Thus, 28 distinct pairs of birds’ trajectories were considered. To account for possible effects of geolocator noise on estimated similarity among trajectories of individual birds, we simulated 1,000 trajectories for each individual by sampling the daily locations including estimated deviation (for longitude and latitude) according to a normal distribution [21]. In this way, 28,000 sampled pairs were used to assess similarity measures and a total of 8,000 pairs within an individual’s sampled trajectories. The sampling methodology and motivation are schematically illustrated in Fig 5. While larger samples and more advanced analysis techniques for geolocation data exist and would further reduce estimated noise [44], our simple approach based on standard deviation in daily locations serves to highlight potential effects of noise on estimated similarity among measures, and is further sufficient for comparison among individual birds.
Based on location data containing error (A), trajectories are sampled for each tracked individual (B, E) according to the underlying (here, normal) distribution. Comparison between pairs of sampled trajectories from the same tracked individual (C) yields a distribution in similarity (D) to estimate noise. By comparing pairs of sampled trajectories from different tracked individuals (F), the actual similarity between two migratory trajectories can be assessed (G). A total of 28,000 comparisons were conducted. The maps are made with Natural Earth.
An intuitive comparison among measures regarding their sensitivity to deviations among trajectories can be seen in the frequency histograms of the estimated similarity among the sampled trajectory pairs (depicted in blue in Fig 6). Note that a higher similarity value (x-axes in Fig 6) corresponds to a greater difference between two trajectories. It is not feasible, however, to compare the absolute magnitudes of two similarity measures, as they might already differ based on their mathematical framework. To gauge how the range in sensitivity for each measure compares to its the sensitivity of noise, frequency histograms of similarity between sampled trajectories from within the same individual’s sample (8,000 pairs) are plotted in red. For comparison with the between-individual similarity (blue histograms), the within-individual values describing the noise were normalized to make the magnitudes comparable. Additionally, the LCSS measure was computed four times using different threshold values of ε (50 km, 100 km, 200 km, 400 km), which allows a more complete analysis while accounting for ranges within and beyond non-migratory movements during stopover periods [10, 11].
Frequency count histograms for each measure are constructed (see Fig 5) based on all 28 distinct pairs of tracked individual wheatears. Additionally, the similarity of the trajectory of one bird to itself (noise) is illustrated after being subjected to sampling (red). The red histograms, therefore, visualize the noise in the data as interpreted by the different similarity measures, while the blue histograms actually show the similarity of different trajectories. The noise histograms are normalized to make them comparable with the between-individual histograms. The greater the difference between the red and blue histograms, the better noise can be distinguished from the actual comparison. Note that HD, DFD, and DWFD have the greatest overlap between noise and similarity measure, which can be attributed to the measures being so-called bottleneck measures. DTW separates the noise and similarity measure better. KLD and WD are both insensitive to noise and therefore exhibit very narrow red histograms. LCSS reveal significant deviations for different distance threshold values (50, 100, 200, 400 km). The values for the scales were omitted for clarity, as the similarity measures return results in different scales and are therefore numerically not comparable. The values are compared by the relative breadth and uniformity of their distributions, which is visualized by the different histograms.
In all cases, the distribution in similarity of the noise (red in Fig 6) is distinguishably narrower than that between different individuals (blue in Fig 6). The measures also differ in the width and shape of these distributions. Expectedly, the distributions in similarity regarding noise and between individuals overlap most closely for the three bottleneck measures (HD, DFD and WDFD), and also for LCSS with smaller spatial threshold values (ε = 50). Somewhat surprisingly, the asymmetric (bimodal-like) distribution among bottleneck measures is similar for the aggregated method KLD, which more clearly distinguished between noise (red) and between-individual (blue) distributions. KLD and the other non-ordered aggregated distribution, WD, produce the broadest distributions in similarity, similar to the LCSS with a broad spatial threshold (400 km).
As with the protein analysis (Fig 3), estimated similarity among the wheatear trajectories using LCSS is highly dependent on the choice of parameters. Four different spatial threshold values ε were employed (50 km, 100 km, 200 km, and 400 km) to demonstrate the different LCSS sensitivities. It can be observed that a higher spatial threshold leads to a higher similarity between trajectories, as can be observed in the four LCSS frequency distributions. Therefore, a meaningful choice of threshold has to be conducted carefully. For instance, a threshold of 50 km will not be sufficient to characterize whether two birds follow a similar migration route at a continental scale [5], but it could be a reasonable threshold to compare foraging flights within a population at a regional scale [5]. Calculating the LCSS for several values could conceivably facilitate differentiation between local and long-distance movements, e.g. stopover and foraging flight and directed flight.
However, to illustrate how the measures constrast in interpreting similarity among trajectories, we here focus on the three trajectories depicted in Fig 4. As with the histrogram plots to facilitate comparison, we normalized each measure to its most different trajectory pair. As in Fig 6, KLD and WD show different results even though both measures can be categorized with similar attributes (aggregated and unordered). According to the KLD measure, the trajectories of the birds tagged 7910 and B070 are least similar among the three pairs, while WD indicates that the trajectories of the birds 7902 and B070 are least similar (Fig 7). Aggregated methods are dependent with respect to every element along the trajectories and thus more sensitive to small deviations along two different trajectories. Since KLD compares distributions, whereas WD compares aggregated distances, KLD will weight the frequent proximity of 7910 and B070 relatively more strongly and WD the large distance of the deviation of B070 more strongly. This deviation leads to the significant difference of the two aggregated and order-independent measures (KLD, WD). As with the distribution plots in Fig 6, DTW, DFD, WDFD, and HD measures are in agreement and indicate that trajectory B070 differs the most when compared together with trajectories 7902 and 7910. Even though the measures differ in their type and attributes (Table 1), similar trends are observed. For this scenario, the order-dependency of DTW leads to a significant difference compared to the other two discussed aggregated measures (KLD, WD). From an intuitive perspective, the results of the DTW, DFD, WDFD and HD measures are expected when visually comparing Panels A to C in Fig 4. Thus, to answer the the questions regarding similarity of migration routes or analyzing stopover locations of birds from the same age cohort, it might be more sufficient to use more than one similarity measure in order to interpret the used data set.
To highlight differences among similarity measures, we focused on the three tracked individual wheatear migrants depicted in Fig 4. To facilitate this comparison, we scaled each measure to its highest dissimilarity. The symbol Γ indicates the height at which two trajectories are half as dissimilar as the most dissimilar trajectory pair. LCSS and WD both identify the trajectories of birds 7902 and B070 to be least similar, as well as WD. On the other hand, All measures except for WD indicate that individuals 7902 and 7910 followed the most similar migratory trajectory. After normalization by the maximum difference, the values realized on the y-axis range from zero to one. As the units differ from measure to measure, the numerical values on the axes have been omitted for clarity.
6 Conclusion
In this work, we present a software package SiMBols that permits computing similarity measures for different biological systems at microscopic and macroscopic levels. SiMBols calculates the similarity measures independent of their scale, which has been demonstrated through two exemplary case studies discussing the motion of atoms in a protein and of birds migrating across continents. Spatio-temporal data of any length scale in between can also be analyzed using the package, allowing for multiscale analyses. SiMBols combines eight different similarity measures, which include bottleneck as well as aggregated measures. They are also distinguishable in their treatment of ordered or unordered sequences of data. Additionally, SiMBols provides a variety of preprocessing routines, which allows a versatile utilization of the package in life sciences.
We have demonstrated that SiMBols can be utilized efficiently for diverse biological problems. The extremes in the scales of the showcased case studies demonstrate that the package provides a generalized framework which can be applied to a wide variety of arbitrary spatiotemporal studies, which, for example, may include the comparison of protein complex behavior upon being subjected to mutations, the analyses of activated chromophores bound in structures.
The similarity measures implemented in SiMBols were classified based on two major attributes, namely bottleneck or aggregated measures were discussed, while the datasets were considered as either ordered or unordered. Choice of measures will naturally depend on the attributes and scales relevant to the research question, and possibly also on any limits regarding computation time and resources. For example, to assess equilibrium MD simulations using the computationally-rich protein data, WD stood out in regarding both sensitivity to overall movement and computational efficiency. In general, we have demonstrated that SiMBols provides a manifold of different techniques to approach the analyses of spatiotemporal data. Even though SiMBols provides such a variety of different similarity measures, the measures for every specific study should be chosen thoughtfully. For instance, LCSS was shown to be highly dependent on the scale of the problem of interest. The magnitude of noise in the dataset was another important factor for the choice of similarity measures. It was shown that, e.g., KLD is very insensitive to noise, but might also miss smaller but yet significant differences between two trajectories, e.g., compared with WD in the bird trajectory analysis (Figs 4 and 7). However, a generalized statement as to whether any one similarity measure is the most suitable cannot be made and will always need to be chosen depending on the research question. A combination of measures might yield the most thorough results.
In summary, using similarity measures provides a quantitative tool to compare and classify biological movement across scales and processes. The python package SiMBols available at https://gitlab.uni-oldenburg.de/quantbiolab/simbols provides a versatile computational tool to calculate different similarity measures within one unified framework.
Supporting information
S1 File. Similarity measures.
Introduction and mathematical definitions and concepts for the employed similarity measures.
https://doi.org/10.1371/journal.pone.0284736.s001
(PDF)
S2 File. Additional case study information.
Additional data and graphs are provided to complement the two case studies.
https://doi.org/10.1371/journal.pone.0284736.s002
(PDF)
Acknowledgments
The authors would like to thank Jérôme Urhausen and Georg Manthey for providing valuable feedback on computation methods, coding and debugging.
Computational resources were provided by the CARL Cluster at the Carl-von-Ossietzky University Oldenburg. The authors gratefully acknowledge the computing time granted by the Resource Allocation Board and provided on the supercomputer Lise and Emmy at NHR@ZIB and NHR@Göttingen as part of the NHR infrastructure. The calculations for this research were conducted with computing resources under the project nip00058.
References
- 1. Auger-Méthé M, Newman K, Cole D, Empacher F, Gryba R, King AA, et al. A guide to state–space modeling of ecological time series. Ecological Monographs. 2021;91(4):e01470.
- 2. Nathan R, Monk CT, Arlinghaus R, Adam T, Alós J, Assaf M, et al. Big-data approaches lead to an increased understanding of the ecology of animal movement. Science. 2022;375(6582):eabg1780. pmid:35175823
- 3. Kays R, Crofoot MC, Jetz W, Wikelski M. Terrestrial animal tracking as an eye on life and planet. Science. 2015;348(6240):aaa2478. pmid:26068858
- 4. Laube P, Purves RS. How fast is a cow? Cross-Scale Analysis of Movement Data. Trans GIS. 2011;15(3):401–418.
- 5. Cleasby IR, Wakefield ED, Morrissey BJ, Bodey TW, Votier SC, Bearhop S, et al. Using time-series similarity measures to compare animal movement trajectories in ecology. Behav Ecol Sociobiol. 2019;73(11):151.
- 6. Tao Y, Both A, Silveira RI, Buchin K, Sijben S, Purves R, et al. A comparative analysis of trajectory similarity measures. GIScience & Remote Sensing. 2021;58:643–669.
- 7.
Magdy N, Sakr MA, Mostafa T, El-Bahnasy K. Review on trajectory similarity measures. 2015 IEEE 7th Int Conf Intell Comput Inf Syst ICICIS 2015. 2015:613–619.
- 8. Seyler SL, Kumar A, Thorpe MF, Beckstein O. Path Similarity Analysis: A Method for Quantifying Macromolecular Pathways. PLoS Comput Biol. 2015;11(10):e1007136. pmid:26488417
- 9. Schuhmann F, Kattnig DR, Solov’yov IA. Exploring Post-activation Conformational Changes in Pigeon Cryptochrome 4. J Phys Chem B. 2021;125(34):9652–9659. pmid:34327996
- 10. Mills AM, Thurber BG, MacKenzie SA, Taylor PD. Passerines use nocturnal flights for landscape-scale movements during migration stopover. Condor. 2011;113(3):597–607.
- 11. Taylor PD, Mackenzie SA, Thurber BG, Calvert AM, Mills AM, McGuire LP, et al. Landscape movements of migratory birds and bats reveal an expanded scale of stopover. PLoS One. 2011;6(11):27054. pmid:22073253
- 12. Wong SY, Frederiksen A, Hani M, Schuhmann F, Grüning G, Hore PJ. Navigation of migratory songbirds : a quantum magnetic compass sensor. Neuroforum. 2021;3.
- 13. Xu J, Jarocha LE, Zollitsch T, Konowalczyk M, Henbest KB, Richert S, et al. Magnetic sensitivity of cryptochrome 4 from a migratory songbird. Nature. 2021;594(7864):535–540. pmid:34163056
- 14.
Solov’yov IA, Ritz T, Schulten K, Hore PJ. A chemical compass for bird navigation. In Mohseni M., Omar Y., Engel G., & M. Plenio (Eds.), Quantum Effects in Biology. Cambridge: Cambridge University Press; 2014. pp. 218–236
- 15. Mouritsen H. Long-distance navigation and magnetoreception in migratory animals. Nature. 2018;558:50–59 pmid:29875486
- 16. McLaren J, Schmaljohann H, Blasius B. Predicting performance of naïve migratory animals, from many wrongs to self-correction. Commun. Biol. 2022;5:1058. pmid:36195660
- 17. Zoltowski BD, Chelliah Y, Wickramaratne A, Jarocha L, Karki N, Xu W, et al. Chemical and Structural Analysis of a Photoactive Vertebrate Cryptochrome from Pigeon. Proc Natl Acad Sci USA. 2019;116(39):19449–19457. pmid:31484780
- 18. Ritz T, Adem S, Schulten K. A model for photoreceptor-based magnetoreception in birds. Biophys J. 2000;78(2):707–718. pmid:10653784
- 19. Bauer S, Hoye BJ. Migratory animals couple biodiversity and ecosystem functioning worldwide. Science. 2014;4(344):1242552. pmid:24700862
- 20. McLaren JD, Buler JJ, Schreckengost T, Smolinsky JA, Boone M, van Loon E, et al.. Artificial light at night confounds broad-scale habitat use by migrating birds; 2018.
- 21. Schmaljohann H, Lisovski S, Bairlein F. Flexible reaction norms to environmental variables along the migration route and the significance of stopover duration for total speed of migration in a songbird migrant. Front Zool. 2017;14(1). pmid:28344630
- 22. Sakoe H, Chiba S. Dynamic programming algorithm optimization for spoken word recognition. IEEE Transactions on Acoustics, Speech, and Signal Processing. 1978;26(1):43–49.
- 23. Kattnig DR, Nielsen C, Solov’yov IA. Molecular Dynamics Simulations Disclose Early Stages of the Photo-Activation of Cryptochrome 4. New J Phys. 2018;20(8):083018.
- 24.
Levina E, Bickel P. The Earth Mover’s distance is the Mallows distance: some insights from statistics. Proceedings Eighth IEEE International Conference on Computer Vision. ICCV 2001. 2001;2:251–256.
- 25. Potts JR, Auger-Méthé M, Mokross K, Lewis MA. A generalized residual technique for analysing complex movement models using earth mover’s distance. Methods in Ecology and Evolution. 2014;5(10):1012–1022.
- 26.
MacKay DJC. Information Theory, Inference, and Learning Algorithms. Cambridge: Cambridge University Press; 2003.
- 27. Clim A, Zota RD, TinicĂ G. The Kullback-Leibler Divergence Used in Machine Learning Algorithms for Health Care Applications and Hypertension Prediction: A Literature Review. Procedia Computer Science. 2018;141:448–453.
- 28. Virtanen P, Gommers R, Oliphant TE, Haberland M, Reddy T, Cournapeau D, et al. SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nature Methods. 2020;17:261–272. pmid:32015543
- 29.
Wannesm, Khendrickx, Yurtman A, Robberechts P, Vohl D, Ma E, et al. wannesm/dtaidistance: v2.3.4. 2021; [Cited 2022 November 21].
- 30.
Hagberg AA, Schult DA, Swart PJ. Exploring Network Structure, Dynamics, and Function using NetworkX. In: Varoquaux G, Vaught T, Millman J, editors. Proceedings of the 7th Python in Science Conference. Pasadena, CA USA; 2008. p. 11–15.
- 31. Harris CR, Millman KJ, van der Walt SJ, Gommers R, Virtanen P, Cournapeau D, et al. Array programming with NumPy. Nature. 2020;585(7825):357–362. pmid:32939066
- 32. McGibbon RT, Beauchamp KA, Harrigan MP, Klein C, Swails JM, Hernández CX, et al. MDTraj: A Modern Open Library for the Analysis of Molecular Dynamics Trajectories. Biophys J. 2015;109(8):1528–1532. pmid:26488642
- 33. Kabsch W. A discussion of the solution for the best rotation to relate two sets of vectors. Acta Crystallogr Sect A. 1978;34(5):827–828.
- 34.
Kromann JC. Calculate Root-mean-square deviation (RMSD) of Two Molecules Using Rotation. [Cited 2022 November 21] Available from: http://github.com/charnley/rmsd.
- 35. Lazim R, Suh D, Choi S. Advances in molecular dynamics simulations and enhanced sampling methods for the study of protein systems. Int. J. Mol. Sci. 2020;21(17):6339 pmid:32882859
- 36. Singharoy A, Maffeo C, Delgado-Magnero KH, Swainsbury DJK, Sener M, Kleinekathöfer U, et al. Atoms to Phenotypes: Molecular Design Principles of Cellular Energy Metabolism. Cell. 2019;179(5):1098–1111.e23. pmid:31730852
- 37. Hanić M, Schuhmann F, Frederiksen A, Langebrake C, Manthey G, Liedvogel M, et al. Computational Reconstruction and Analysis of Structural Models of Avian Cryptochrome 4. Journal of Physical Chemistry B. 2022;126(25):4623–4635 pmid:35704801
- 38. Wong SY, Wei Y, Mouritsen H, Solov’Yov IA, Hore PJ. Cryptochrome magnetoreception: Four tryptophans could be better than three. J R Soc Interface. 2021;18(184):20210601. pmid:34753309
- 39. Wu H, Scholten A, Einwich A, Mouritsen H, Koch KW. Protein-protein interaction of the putative magnetoreceptor cryptochrome 4 expressed in the avian retina. Sci Rep. 2020;10:7364. pmid:32355203
- 40. Solov’yov IA, Schulten K. Reaction Kinetics and Mechanism of Magnetic Field Effects in Cryptochrome. J Phys Chem B. 2012;116(3):1089–1099. pmid:22171949
- 41. Solov’yov IA, Schulten K. Magnetoreception through Cryptochrome may involve superoxide BJ. 2009;96:4804–4813
- 42. Hansson LA, Åkesson S, Brönmark C, Chapman BB, Hedenström A, Hollander J, et al. A synthesis of animal movement across scales. In: Anim. Mov. Across Scales; 2014. p. 259–268.
- 43. Wynn J, Padget O, Mouritsen H, Morford J, Jaggers P, Guilford T. Magnetic stop signs signal a European songbird’s arrival at the breeding site after migration.; Science 2022;375(6579):446–449. pmid:35084979
- 44. Lisovski S, Bauer S, Briedis M, Davidson SC, Dhanjal-Adams KL, Hallworth MT, et al. Light-level geolocator analyses: A user’s guide. Journal of Animal Ecology. 2020;89(1):221–236. pmid:31190329
- 45. Halpin LR, Ross JD, Ramos R, Mott R, Carlile N, Golding N, et al. Double-tagging scores of seabirds reveals that light-level geolocator accuracy is limited by species idiosyncrasies and equatorial solar profiles. Methods in Ecology and Evolution. 2021;12(11):2243–2255.