bestK: Determine a suitable K value from multiple Structure runs

Description Usage Arguments Details Value Examples

Description

Determine a suitable K value from multiple Structure runs

Usage

1
bestK(x, method, plot = TRUE)

Arguments

x

a structList or admixList object.

method

the method used to calculate the best K either 'evanno' or 'structure', not required for admixList objects.

plot

whether of not to generate diagnostic plots

Details

If the K values are not ordered or there an even numbers of runs per K the 'structure' method will be implemented and the 'evanno' method to compute delta K will not be returned in the output.

Value

a data.frame containing with columns containing the L_k, AIC, BIC, DIC and deltaK for structList. If an admixList was given a data.frame returning the log information will be supplied. If plot = TRUE a ggplot object is printed for the method of interest.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
multi_K <- exampleStructure("multiple_runs")
# Run the evanno method and display diagnostic plots.
evanno_results <- bestK(multi_K, method = "evanno")
# Run the default structure method and display diagnostic plots
structure_results <- bestK(multi_K, "structure")
# find 'best' K according to results
deltaK <- evanno_results$variable == 'delta K'
max_deltaK <- which(evanno_results$value == max(evanno_results$value[deltaK], na.rm = TRUE))
evanno_results[max_deltaK, ]
lK <- structure_results$variable == 'L(K)'
max_Lk <- which(structure_results$value == max(structure_results$value[lK], na.rm = TRUE))
structure_results[max_Lk,]
# admixture example
multi_K_admix <- exampleAdmixture()
bestK(multi_K_admix)

Example output

Creating diagnostic plots for structure runs.
Creating diagnostic plots for structure runs.
   K variable   value sd
16 4  delta K 104.815 NA
    K variable   value       sd
5.1 5     L(K) -1410.7 2.687006
Creating diagnositc plots for admixture runs
  K     logL CVerror
1 1 -4169323 0.55248
2 2 -3835365 0.48190
3 3 -3799887 0.47835
4 4 -3789059 0.48236
5 5 -3778956 0.49001

starmie documentation built on May 1, 2019, 8:01 p.m.