Introduction to Cyclical Ecological Trajectory Analysis

Nicolas Djeghri, Anthony Sturbois, Miquel De Cáceres

LEMAR, EMF-CREAF-CSIC

Outline

  1. Aims and rationale of CETA
  2. CETA-specific conceptual and geometric elements
  3. Characterizing and comparing CETA trajectories
  4. Cyclical shifts

M.C. Escher - Dragon, 1952

1. Introduction

About Cyclical Ecological Trajectory Analysis

Aims and domain of application

Cyclical Ecological Trajectory Analysis (CETA) is an extension of the ETA framework to analyze cyclical ecological dynamics (seasons, day/night cycles…) described in Djeghri et al (2026)1

Rationale and general approach

  • CETA proceeds by sub-setting trajectories presenting cyclical dynamics into sub-trajectories of interest (Cycles, and fixed date trajectories).

  • CETA trajectories can then be described and compared as is done for other, non-CETA, trajectories.

  • Cycles specific geometries sometimes necessitate using dedicated metrics.

  • CETA also allows computing Cyclical Shifts, a multidimensional equivalent of the notion of phenological advances and delays.

Software

CETA is readily implemented within the ecotraj package (from version 1.0.0)

Package call

library(ecotraj)

2. CETA-specific conceptual and geometric elements

Conceptual and geometric elements

The most important elements of CETA are:

Element Notation Description
Cyclical trajectory \(T\) A cyclical trajectory is a trajectory presenting (or expected to present) cyclical dynamics.
Time \(t\) The position of a given ecological observation in a linear temporal axis (i.e. ‘when’ the assessment act occurred).
Date \(đ\) The position of a given ecological observation in a cyclical (or recurrent) temporal axis (e.g. a day of the year).
Cycle duration \(DUR_C\) The ecological entity whose dynamics are of interest. It can be an individual, a population, a community or an entire ecosystem

Together these elements allow defining CETA-specific trajectories:

Trajectory Notation Description
Cycles \(C\) A Cycle is a special-case of trajectory section obtained from \(T\) of duration \(DUR_C\).
Fixed date trajectories \(fdT\) Fixed date trajectories are the trajectories joining the ecological state of the same date \(đ\) in a given cyclical trajectory.

Defining some toy CETA trajectories

Start by defining one cyclical trajectory with three cycles:

times <- 0:30 #The sampling times of the time series
DurC <- 10 #The duration of the cycles (i.e. the periodicity of the time series)
dates <- times%%DurC #The dates associated to each times
site <- rep(c("A"),length(times)) #The sites associated to each times (only one)
trend <- 0.05 #A trend that will be applied to the cycles to make it more interesting
noise <- 0.05 #A noise term to make things less perfect

#Make cyclical data
x <- sin((times*2*pi)/DurC)+trend*times+rnorm(length(times),mean=0,sd=noise)
y <- cos((times*2*pi)/DurC)+rnorm(length(times),mean=0,sd=noise)
mat <- cbind(x,y)

#Express it as a distance matrix
dmat <- dist(mat)

#Finally make it a trajectory object:
x <- defineTrajectories(dmat, sites = site, times = times)

Visualization of the cylical trajectory

trajectoryPCoA(x,lwd = 2,length = 0.2)

Extracting and visualizing the cycles…

Extraction of cycles…

cycle <- extractCycles(x,cycleDuration = DurC)

…and visualization

cyclePCoA(cycle,lwd = 2,length = 0.2)

…and the fixed date trajectories

Extraction of fixed date trajectories…

fdtraj <- extractFixedDateTrajectories(x,
                                       cycleDuration = DurC,
                                       namesFixedDate = paste0("Date_",1:10))

…and visualization

fixedDateTrajectoryPCoA(fdtraj,lwd = 2,length = 0.2)

Object structure

Note that the structure of the ecotraj/CETA objects is very similar to what you already know.

names(cycle)
[1] "d"        "metadata"
names(fdtraj)
[1] "d"        "metadata"

But cycles have some specificities

head(cycle$metadata)
  sites cycles surveys times dates internal
1     A   A_C1       1     0     0     TRUE
2     A   A_C1       2     1     1     TRUE
3     A   A_C1       3     2     2     TRUE
4     A   A_C1       4     3     3     TRUE
5     A   A_C1       5     4     4     TRUE
6     A   A_C1       6     5     5     TRUE
head(fdtraj$metadata)
  sites          fdT surveys times dates
1     A A_fdT_Date_1       1     0     0
2     A A_fdT_Date_2       1     1     1
3     A A_fdT_Date_3       1     2     2
4     A A_fdT_Date_4       1     3     3
5     A A_fdT_Date_5       1     4     4
6     A A_fdT_Date_6       1     5     5

We won’t get into the detail now but you can check the CETA vignette for more details.

3. Characterizing and comparing CETA trajectories

Metrics for cycles

Cycle have particular geometries (they loop back on themselves) implying that some classical ETA metrics are not adapted and must be changed.

Directionality is replaced by convexity expressed as: \(CONV(C) = 360/\Sigma \theta\) with \(\theta\) the turning angle at each ecological state of cycle \(C\).

Note that \(\theta\) can be defined by ecological states outside the cycle of interest. This is why the ecotraj implementation uses the cyclical trajectory instead of the cycles:

cycleConvexity(x,DurC)#Note: the function takes x instead of cycle as input
    A_C1     A_C2     A_C3 
      NA 1.005992 1.032759 

Note

The function for the first cycle returns \(NA\), this is expected but can you find why?

ecotraj has a function dedicated to obtain multiple summary metrics for cycles:

cycleMetrics(x,DurC)#Again, the function takes x instead of cycle as input
  cycle site  n t_start t_end   length mean_speed mean_angle convexity
1  A_C1    A 10       0    10 6.214404  0.6214404         NA        NA
2  A_C2    A 10      10    20 6.372982  0.6372982   36.21572  1.005992
3  A_C3    A 10      20    30 6.177658  0.6177658   37.17932  1.032759
  internal_ss internal_variance
1    8.659312         0.9621458
2    8.862202         0.9846891
3    8.871173         0.9856858

Metrics for fixed date trajectories

Fixed trajectories are regular trajectories and can be studied with classical ecotraj functions:

trajectoryMetrics(fdtraj)
      trajectory site n t_start t_end duration    length mean_speed mean_angle
1   A_fdT_Date_1    A 4       0    30       30 1.4219768 0.04739923 11.9427232
2   A_fdT_Date_2    A 3       1    21       20 1.0522923 0.05261461  3.9979415
3   A_fdT_Date_3    A 3       2    22       20 0.9449031 0.04724515 30.5916366
4   A_fdT_Date_4    A 3       3    23       20 0.9233193 0.04616597 12.7170129
5   A_fdT_Date_5    A 3       4    24       20 0.9600601 0.04800300  2.6616065
6   A_fdT_Date_6    A 3       5    25       20 1.0092839 0.05046420  5.1985247
7   A_fdT_Date_7    A 3       6    26       20 0.9798304 0.04899152  0.6156576
8   A_fdT_Date_8    A 3       7    27       20 1.0538702 0.05269351  2.3243051
9   A_fdT_Date_9    A 3       8    28       20 1.0297198 0.05148599 16.9024663
10 A_fdT_Date_10    A 3       9    29       20 0.9561856 0.04780928  8.7812183
   directionality internal_ss internal_variance
1       0.9137003   1.1446725         0.3815575
2       0.9777892   0.5532127         0.2766064
3       0.8300465   0.4339795         0.2169898
4       0.9293499   0.4228767         0.2114383
5       0.9852133   0.4647916         0.2323958
6       0.9711193   0.5088856         0.2544428
7       0.9965797   0.4804547         0.2402274
8       0.9870872   0.5568761         0.2784381
9       0.9060974   0.5225367         0.2612684
10      0.9512155   0.4571235         0.2285618

4. Cyclical shifts

Computing cyclical shifts

A last, and perhaps important aspect of CETA are cyclical shifts. They can be understood as multidimensional analogues of the phenological concept of advances and delays.

The function cycleShifts will compute by default all possible cyclical shifts in a given cyclical trajectory:

cycleShifts(x,DurC)#Note that, again, we give x as input.
   sites dateCS timeCS timeRef timeScale cyclicalShift
1      A      0     20      10        10    0.07130581
2      A      1     21      11        10    0.00000000
3      A      2     22      12        10    0.14672320
4      A      3     23      13        10    0.09618573
5      A      4     24      14        10   -0.10431083
6      A      5     15       5        10    0.00000000
7      A      5     25       5        20    0.00000000
8      A      5     25      15        10    0.00000000
9      A      6     16       6        10   -0.06053881
10     A      7     17       7        10   -0.03697409
11     A      8     18       8        10    0.08223974
12     A      9     19       9        10    0.00000000

Summary of the CETA workflow

M.C. Escher - Dragon, 1952