Skip to contents

Computes a pairwise distance matrix based on the year embedded in sequence names. Supported methods are `"absolute"` (symmetric), `"forward"` (x - y), and `"backward"` (y - x).

Usage

dist_temporal(seqs, temp_dir = "absolute")

Arguments

seqs

A named character vector. The names must contain 4-digit years.

temp_dir

The method used for computing temporal distance. One of `"absolute"` (default), `"forward"`, or `"backward"`.

Value

A square numeric matrix of pairwise temporal distances.

Details

This function extracts years from the names of `seqs` using a regular expression, then computes pairwise temporal distances using the specified method.

Which distance is "backwards" or "forwards" is semantic and depends on the order of your strain names. They are both provided for convenience.

Examples

seqs <- c(
  "A/H1N1/South Carolina/1/1918" = "mktiialsyifclvlgqdfpgndnstatlclgh",
  "A/H3N2/Darwin/9/2021" = "mktiialsnilclvfaqkipgndnstat",
  "B/Sichuan/379/1999" = "drictgitssnsphvvktatqgevnvtgai"
)