generates new graphs from basegraph as follows:

  1. generates all possible trees using addpops (which are not in basegraph)

  2. attaches trees to connection_edge, which is defined by two nodes in basegraph

  3. adds edges originating above each edge in source_node, to each node above addpops

graphmod_pavel(basegraph, addpops, connection_edge, source_nodes)

Arguments

basegraph

an admixture graph as igraph object. (convert from edge list using igraph::graph_from_edgelist)

addpops

a vector of population labels which are not in basegraph. These populations should form a clade. All possible trees will be generated and those trees will be attached to basegraph.

connection_edge

edge in basegraph where the tree made from addpops should be attached

source_nodes

nodes in basegraph. edges above these nodes will be added and attached to all terminal edges leading to addpops

Examples

if (FALSE) {
graphlist = graphmod_pavel(example_igraph, addpops = c('pop1', 'pop2', 'pop3'),
                           connection_edge = c('N2N0', 'N1N'),
                           source_nodes = c('Denisova.DG', 'N2N2'))
results = tibble(graph = graphlist) %>%
  mutate(res = map(graph, ~qpgraph(example_f2_blocks, .))) %>%
  unnest_wider(res) %>%
  mutate(worstz = map_dbl(f3, ~max(abs(.$z))))
}