fit_permutations_and_graphs: Fit lots of graphs to data.

Description Usage Arguments Value See Also Examples

View source: R/propose.R

Description

Combines a list of (population) permutations and a list of graph topologies to a big list of graphs, then fits those graphs to given data using parallel computation. This function needs doParallel, foreach and parallel installed.

Usage

1
fit_permutations_and_graphs(data, permutations, graphs, cores)

Arguments

data

The data table.

permutations

List of population permutations.

graphs

List of functions for producing graphs.

cores

Number of cores used.

Value

A list of fast_fit results.

See Also

make_permutations

four_leaves_graphs

five_leaves_graphs

six_leaves_graphs

seven_leaves_graphs

eight_leaves_trees

fit_graph_list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Let's experiment by fitting all the graphs with five leaves and at most one admixture
# event to a five population subset of the bear data. Note that with three data rows only
# we do wisely by not concluding too much about the actual bear family tree; this is to
# illustrate the function usage only!

data(bears)
data <- bears[16:18, ]
print(data)
permutations <- make_permutations(c("PB", "BLK", "Sweden", "Denali", "Kenai"))
graphs <- five_leaves_graphs

# We go with one core only as I don't know what kind of machine you are using.

fitted_graphs <- fit_permutations_and_graphs(data, permutations, graphs, 1)

# Now sort the fitted objects by best_error and see how the best graph looks like.

errors <- sapply(fitted_graphs, function(x) x$best_error)
best_graphs <- fitted_graphs[order(errors)]
plot(best_graphs[[1]]$graph, color = "goldenrod", title = best_graphs[[1]]$best_error)

# The same value for best_error actually occurs in the list 152 times because of our
# unsufficient data.

mailund/admixture_graph documentation built on April 3, 2018, 9:28 p.m.