This function tests which qpadm models should be valid for an admixture graph and a target population. By default, all models returned by qpadm_models are tested. For large graphs this will be too slow, and you may want test only some models by providing the models argument, or only a single model by providing the left and right arguments.

graph_to_qpadm(
  graph,
  target,
  left = NULL,
  right = NULL,
  models = NULL,
  weights = TRUE,
  f4dat = NULL,
  allpops = TRUE,
  more_right = TRUE,
  return_f4 = FALSE,
  eps = 1e-10
)

Arguments

graph

An admixture graph

target

Name of the target population.

left

Left populations (provide this optionally if you want to test only a single qpadm model)

right

Right populations (provide this optionally if you want to test only a single qpadm model)

models

A two column nested data frame with models to be evaluated, one model per row. The first column, l, should contain the left populations, the second column, r, should contain the right populations. The target population is provided separately in the target argument.

weights

Set this to FALSE to return only information on the ranks, not the weights, of each qpadm model. The ranks should depend only on the graph topology, while the weights and weight-validity (all weights for left populations between 0 and 1) can depend on the branch lengths of the graph. By default f4-statistics are based on equal branch lengths and admixture weights of 0.5. This can be overridden by providing f4dat.

f4dat

A data frame of f4-statistics which can be provided to override the default branch lengths.

allpops

Evaluate only models which use all populations in the admixture graph. See qpadm_models

return_f4

Include f4 statistic matrices in the results (default FALSE)

eps

Epsilon value close to zero which is used for determining which f4 matrix elements should be considered non-zero, and which weights are strictly between 0 and 1.

Value

A data frame with one qpadm model per row and columns valid_rank and valid_weights indicating whether a model should be valid under the graph.

Details

Two validity criteria are tested for each qpadm model: Rank validity and weight validity. Rank validity means that the rank of the f4 statistic matrix for only left and right populations is the same as the rank of the f4 statistic matrix that includes the target population among the left populations. Weight validity means that the estimated admixture weights for all left populations are between 0 and 1.

Note

An earlier version of this function tried to use the graph topology for identifying valid qpadm models, but this didn't work reliably. Christian Huber had the idea of using the ranks of expected f4 statistic matrices instead.

Examples

if (FALSE) {
graph2 = example_igraph %>% simplify_graph() %>%
  delete_admix('N3N0', 'N3N4') %>% delete_admix('N3N1', 'N3N8')
graph_to_qpadm(graph2, 'Mbuti.DG') %>% filter(valid_rank, valid_weights)
}