This function returns TRUE if and only if the admixture graph is compatible with all event orders listed in eventorder

satisfies_eventorder(graph, eventorder, strict = TRUE)

Arguments

graph

An admixture graph

eventorder

A data frame with columns earlier1, earlier2, later1, later2, optionally type

strict

What to do in case some events are not determined by the graph. If strict = TRUE (the default), the function will only return TRUE if there are no ambiguous constraints. Otherwise, TRUE will be returned as long as no constraint is directly contradicted.

Value

TRUE if all constraints are satisfied, else FALSE

Details

Each row in eventorder represents a constraint that earlier1 and earlier2 split earlier than later1 and later2. If later2 is NA, later2 will be set to the parent node of later1. By default (type = 1), a constraint will be satisfied as long as there is any lineage in which a split between earlier1 and earlier2 is ancestral to a split between later1 and later2. type = 2 is stricter and requires that the earlier1, earlier2 split is ancestral to the later1, later2 split in all lineages. In graphs with multiple admixture events there can be multiple splits between earlier1, earlier2 and later1, later2, and many ways in which these splits can relate to each other. The current implementation only covers some of the many possible topological relationships.

Examples

if (FALSE) {
# Test whether the split between A and B is earlier than the split between C and D,
#   and whether the split between C and D is earlier than the terminal branch leading to E
constrain_events = tribble(
  ~earlier1, ~earlier2, ~later1, ~later2,
  'A', 'B', 'C', 'D',
  'C', 'D', 'E', NA)
satisfies_eventorder(random_admixturegraph(5, 0), eventorder = constrain_events)
}