## Abstract

Time is perceived to be unidirectional and continuous in the philosophy of science. This continuity can play a crucial role in time series analysis as events are generally seen as an outcome of *the past*, or subject to events that occurred previously in time. In this study, we describe an ordinal approach to perceiving ecological time series – one that relies on pattern formation with both antecedent and future events. Our approach defines a limited set of structural shapes that can occur for past, present, and future time points. Such a library of all possible shapes can then be used for novel approaches to data visualization and time series analysis. We applied this method to simple ecological models and then to natural time series data for measles cases in London and the phytoplankter *Pseudo-nitzschia spp*. in Narragansett Bay, Rhode Island. Alternative perspectives on time series representation can strengthen our ability to identify important patterns in dynamics and effectively discriminate between similar time series. When used in conjunction with conventional line-plots, barcodes can be tailored to demonstrate the presence or absence of specific structural patterns or features. Our results show that data exploration without the assumption of time series continuity can yield important and novel insight into the behavior of ecological systems.

## Introduction

The ability to perceive quantitative information is an important component of scientific analysis. Graphical methods are typically used to visually encode and present information (Cleveland and McGill 1985) and the method of choice can impact inference on the underlying data. In ecology and other fields, time series representation relies on graphical approaches that present time in a continuous sense. The continuous perception of time has provided an abundance of techniques that can graphically represent time series data (Javed et al. 2010); however, modern frameworks present many alternative approaches to visual time series representation (Aigner et al. 2007; Weiß 2008).

One approach is to describe time in an ordinal sense – every time point is considered independent and has exactly one previous time point and one future time point. Ordinal pattern analysis has been previously used to compute the permutation entropy of time series (Bandt and Pompe 2002; Unakafova and Keller 2013) and has found utility in the analysis of EEG data (Cao et al. 2004; Ouyang et al. 2010), heart rate variability (Parlitz et al. 2012; Graff et al. 2013) and more recently, understanding stock market dynamics (Peng and Shang 2022). Visualization techniques for representing ordinal patterns have introduced rate evolution graphs and Iterated Function System (IFS) circle transformations (Weiß 2008).

Despite recent development and endorsement of ordinal pattern analysis (Bandt 2019), the use of such approaches has been limited in exploring ecological change. Conventional time series analysis in ecology relies on identifying correlations (Carr et al. 2019), statistical modeling (Tredennick et al. 2021) and, the visual identification of patterns across line graphs (Friedman 2021). Graphical alternatives that can allow for effective discrimination across multiple time series and quickly identify patterns in complex data are in high demand. Novel techniques of data exploration could allow for a deeper understanding of ecological systems (Fox and Hendler 2011).

In this paper, we apply modified ordinal patterns to define a set of shapes that can form in model and natural ecological time series. We visualize these modified ordinal patterns with a novel technique called ‘barcoding’ to represent change across time and aid in ecological data exploration. Broadly, we ask the questions, (1) Do the structural features of time series reflect underlying dynamics? and (2) Can we identify patterns of ecological change with *dynamical barcoding*? Our goal is to evaluate the feasibility of ordinal pattern analysis in ecological studies and describe some potential methods of data exploration that could identify previously unrecognized dynamics, as well as inspire the creation of new hypotheses.

## Materials and Methods

Ecological time series are typically seen as curves on a time-axis (Figure 1), where changes in the value of dependent variables (such as abundance or similar proxies) serve to demonstrate changes in population dynamics. This approach can then allow for the creation of mathematical functions that fully describe the system (in an ideal scenario) and thus, be used to forecast beyond the existing dataset to future time-points.

We propose an alternative approach that relies on viewing time series as an ordered set of system-states (i.e. known values of a variable such as abundance). In this view, each time point is independent, with an associated time point preceding and following it in the time axis (Figure 2). The key difference in this perspective is that values in the past are not assumed to affect the values in the present or the future. As such, the time series can be divided up into ordinal sets with no presumed connection between them.

### Connecting shapes through time

As each time series can be divided into disconnected sets of values, moving across time from past values to future values can be achieved by taking a stepwise approach. Starting from the beginning of the time series, we can move one time-point at a time. For example, for a time series of 10 sequential measurements of *x*, we can define the sets as {*x*_{t−10}, *x*_{t−9}, *x*_{t−8}}, { *x*_{t−9}, *x*_{t−8}, *x*_{t−7}}, {*x*_{t−8}, *x*_{t−7}, *x*_{t−6}} … {*x*_{t−2}, *x*_{t−1}, *x*_{t}}. Within each set, we can use defined relations (such as >,= and <) between the elements to categorize each set. The categories of these ordinal sets are hereafter termed as “shapes”.

For any time series of a variable, this means that there can be a limited number of all possible dynamical shapes in time. In the simple case, where each set only contains two elements with three possible relations (>,= and <), the total number of shapes is 3 (Figure 3).

Similarly, in the case where each set can contain three elements with three possible relations, the total number of possible shapes is 3 × 3 = 9 (Figure 4). Ordinal patterns of order *d* = 2 have been shown to have 13 possibilities (Unakafova and Keller 2013); however, our relationship-based definitions allows us to condense the library to 9 shapes. In our library, the magnitude of change does not feature as heavily as the direction of change.

Any time series that can be described as a sequence of ordinal sets can be visually represented using a library of shapes (such as Figure 4). For each structural shape, we can “color” or code the time series to represent the presence or absence of a particular shape. It is also possible to assign a single color to a group of shapes or create a coloration scheme based on the dynamics of interest. Here, we assigned a unique color to every shape and left white the shapes where any of the data points are missing. All the barcodes were created using the R package “ggplot2” (R Core Team 2021; Wickham 2016; R version 4.1.2). Although we used a simple plotting package combined with high resolution data, effective visualization will depend on the magnification of the plot and the size of the screen. In some cases, it might be appropriate to divide the time series into shorter segments or to aggregate data for plotting.

### Temporal patterns

The reconstruction of a time series allows for the identification of ecological change through time. We first created model systems based on (a) a simple sine curve (Equation 1), (b) Lotka-Volterra dynamics (Lotka 1920; Equations 2 and 3) and (c) a Lorenz system of equations (Lorenz 1963; Equations 4, 5 and 6). For each of these systems, we created barcodes to visualize temporal patterns. Table 1 lists all the parameters and their values for the model systems.
where *a*_{t} is the abundance of a population *a* at time *t* and *ω* is the frequency of oscillation of the population dynamics.
where *x* is the abundance of the prey species and *y* is the abundance of a predator, *α* is the growth rate of the prey, *β* is the grazing rate of the predator, *γ* is the natural mortality rate of the predator and *δ* is the growth rate of the predator.
Where *p, q* and *r* are the log abundance of three different interacting species and *ε, θ* and *φ* are the cumulative interaction coefficients for each population.

### Noise and stochasticity

As there can be varying amounts of noise and stochasticity in natural time series, we created thresholds to allow for keying into dynamics of interest. For every relation (>,= and <) between two time points, we defined a minimum level of change required for the relation to be considered significant (Figure 6). For real life applications, thresholds can be set to identify specific changes in a time series, or systematically tuned to account for expected noise and measurement error during sampling.

### Natural time series data - Measles

Childhood infectious diseases such as measles have provided an excellent testbed for the testing and study of dynamical systems. As a classic natural example of oscillatory dynamics (Olsen et al. 1988), the prevalence of measles in London’s population has been documented to be nonlinear and subject to external perturbations (Becker et al. 2019). Measles epidemics have pronounced seasonality (Mantilla-Beniers et al. 2010), sensitivity to chaos (Dalziel et al. 2016) and travel in waves across both time and space (Grenfell et al. 2001). To illustrate the utility of our approach on real time series data, we used an aggregated monthly time series of measles cases in London from 1940 – 1994 (Becker et al. 2019). First, we utilized the entire 9-shape color scheme without thresholds to understand which features in the time series were most abundant. Second, we set a threshold for a specific shape , meant to identify sudden outbreaks in cases. The threshold was determined using the median of the entire time series (∼80 cases per month). Third, we used the same threshold to look for the points in the time series where new cases dropped within a month . By applying our approach for the identification of specific features, we wanted to assess the possibility of using ordinal patterns in natural data exploration.

### Natural time series data - Phytoplankton

Natural phytoplankton populations exhibit chaotic dynamics (Benincá et al. 2008). Understanding the changes in phytoplankton populations is crucial for the prediction of harmful algal blooms (McGillicuddy, 2010), even though finding patterns and trends in a phytoplankton time series can be difficult for taxa that are not always present. Current approaches rely on statistical or process-based modeling (Ralston and Moore 2020), which are sensitive to time series stationarity and require large amounts of data to return meaningful results. We wanted to test the ability of barcoding in finding broad-scale patterns for a natural phytoplankton time series.

To test our approach, we used a daily time series of a harmful-algal-bloom forming taxa (*Pseudo-nitzschia spp*.) in Narragansett Bay, Rhode Island (https://ifcb-dashboard.gso.uri.edu). The phytoplankton time series was created by training an automatic classifier on data from an Imaging FlowCytobot (IFCB). *Pseudo-nitzschia spp*. was accurately identified in about 89.6% of all classified images. In the first case, we created a barcode for this time series based on our library of dynamical shapes (Figures 4 and 5). Second, we set a threshold of 3 images per mL (i.e. about the 25% quantile of the time series) to find the prevalence of specific shape . For the third case, we repeated the analysis for shape with a threshold of 11 images per mL (around the median of the time series). Both the second and third cases were meant to identify the days of sampling where there was little change in the day-to-day numbers of *Pseudo-nitzschia spp*. in Narragansett Bay.

## Results and Discussion

### Model systems

#### Sine curve

For a simplistic function such as a sine curve, both time series and barcodes have periodicity in dynamics (Figure 7). Based on the same color-coding scheme we defined for Figure 5, we found that the majority of the curve is smoothly increasing/decreasing (purple/pink) through time. This agrees with the continuous time series representation as similar stepwise changes are categorized within the same class of dynamical shape. Similarly, maxima or minima in the sine curve are marked as abrupt color boundaries on the barcode. For practical applications, a barcode representation of dynamics for a simple model could be used to identify specific shapes through time by tailoring color schemes to key in on dynamical patterns of interest.

#### Lotka-Volterra dynamics

Ecological cycles in nature often have more than one interacting variable and Lotka-Volterra predator-prey dynamics represent a well-recognized ecological system (Lotka 1920) with two interacting populations (Eq. 2 and 3). When graphed as a continuous curve (Figure 8; top row), both variables show peaks in abundance followed by slow increases or decreases over time. Dynamical barcodes for the system capture these repeating cycles and the periodic colors indicate smooth and consistent changes over time (Figure 8; bottom row). The barcodes also highlighted some important differences and the timescales of change for both the variables. The prey abundance *x* had a slow rise to the population peak (purple) whereas predator abundance *y* had a slow decrease after the population peak (pink). The slow decrease in predator abundance had longer timescales than the increases in prey population numbers. Dynamical barcodes might be an effective technique for drawing comparisons between two similar time series that appear to share common features and dynamics.

#### Lorenz attractor

The Lorenz equations represent a chaotic system with little to no long-term predictability in dynamics (Lorenz 1963). For the time series of the three interacting variables of this attractor, both the continuous time curves and the barcodes show smooth changes through time (Figure 9). Similar to the sine curve and Lotka-Volterra model, smooth changes for each variable are indicated by the solid blocks of color on the barcode. Even though time series for variables *p* and *q* show highly similar dynamics, the barcodes capture some key changes between the time series. There are additional periods of smooth increase (purple) or decrease (pink) for variable *q* when compared to variable *p*. This suggests that the use of barcoding could be a potential asset in situations where crucial small differences might be missed between time series that look nearly identical. The barcode for variable *r* captures some level of periodicity for the changes within the time series, even though the magnitude of change might differ through time. In such cases, barcodes may be used to broadly classify periods of similar change and provide insight into the behavior of time series that might not be apparent in a continuous time perspective.

#### Application to natural time series

##### Measles in London

We tested the utility of a dynamical barcode for the time series of measles cases in London and tried to understand how natural systems with missing data, measurement error and stochasticity could be represented as a barcode. We found that barcodes in highly dynamic natural systems can be limited in explaining large-scale patterns due to the sheer diversity of possible shapes that are observed (Figure 10B). However, in such cases, keying in on one or two shapes might provide interesting observations on the overall character of the time series. Figure 10C shows the same barcode as in Figure 10B except the color scheme has been changed to show only one specific shape . When evaluated with a threshold (>80 cases per month), it seems that the vast majority of sudden outbreaks occurred prior to 1975. This is an interesting result as the measles vaccination program in London started in the mid-1960s (Becker et al. 2019), which suggests that the vaccination program was successful in curbing future measles outbreaks. Figure 10D highlights the presence of a month-to-month decrease of >80 cases for the same time series . It seems that the prevalence of this feature lingered for far longer than the feature tracking measles outbreaks (Figure 10C). The lack of this feature beyond the 1980s also indicates that the dynamics of the measles epidemic fundamentally changed after this period, possibly due to lower overall caseloads across London.

For a natural time series like the measles epidemic in London, we found that our method could identify interesting features in the dynamics that would have been unavailable in a continuous time perspective. Barcoding could be an effective tool for exploring the dynamics of a range of deterministic systems and motivate new hypotheses based on the presence or absence of specific features.

##### Phytoplankton population dynamics

We applied a dynamical barcoding approach to a daily resolution time series of images of *Pseudo-nitzschia spp*. in Narragansett Bay, Rhode Island to check if we could make ecological inference that is not immediately accessible from a continuous time perspective. First, we created a barcode for all the possible shapes (Figure 5) to try and identify broad-scale patterns. We found that the time series *Pseudo-nitzschia spp*. has many missing data points and show no clear trends over time (Figure 11B). If we were to consider all change to be significant, the barcode of Pseudo-nitzschia spp. showed dynamics that rapidly change over timescales of days (Figure 11B). To further evaluate this hypothesis, we created additional barcodes with different thresholds for significant change in an attempt to understand the frequency and timing of only one specific feature .

After altering the color scheme to show only one feature, we found there are clear differences in the frequency of change over time (Figures 11C and 11D). It would appear that the time series of *Pseudo-nitzschia spp*. rarely has major shifts in detection numbers and most day-to-day changes are <11 (Figure 11D). Interestingly, when the threshold is <3, we found that the feature still has a high rate of prevalence throughout the time series (Figure 11C). These results suggest that most of the time series of *Pseudo-nitzschia spp*. has very low numbers of detected images mL^{-1}, even though the continuous time series might indicate high volatility and a maximum abundance of ∼2000 images mL^{-1}.

A visual approach for time series analysis, such as dynamical barcoding, could highlight structural differences in phytoplankton dynamics through time. By tailoring thresholds to search for specific shapes, the use of dynamical barcoding could be a potential asset for ecological data exploration and analysis with minimal assumptions.

## Conclusions

Time series can be presented in many graphical forms and most current approaches rely on a continuous perception of time to describe ecological dynamics. We developed a novel technique that treats every measurement for a time series as independent and uses a library of 3-point dynamical shapes to describe ecological change through time. Such a method provides a unique perspective on time series behavior and can be used to tailor analyses to identify specific features in ecological dynamics. A graphical approach termed *dynamical barcoding* can then be used for a new form of data visualization and time series representation.

We tested this approach for simple model systems such as a sine curve, Lotka-Volterra predator-prey dynamics and a Lorenz system of equations. Barcodes can be used to identify periods of time where change is uniform and draw out differences in nearly identical time series. Similarly, it is easier to identify periodicity in dynamical shapes than it is for continuous time series curves. Dynamical barcodes of natural time series data, such as the number of measles cases in London or *Pseudo-nitzschia spp*. detection numbers in Narragansett Bay, are affected by noise and stochasticity in dynamics; however, our approach is useful for identifying the frequency and timing of specific features in the historical record. In such cases, dynamical barcodes can be an effective tool in describing ecological change through time and be used to find patterns that might be missed with conventional line plots. The structural features of time series, when viewed from an ordinal perspective, could lead to the creation of novel tools for ecological prediction and pattern recognition.

## Footnotes

cmouw{at}uri.edu

**Data availability statement**The data that support the findings of this study are openly available in Zenodo at https://doi.org/10.5281/zenodo.6190181. The code required for the analysis is in the supplementary material of this article.