Estimating the optimal number of migration edges from Treemix
This package uses results from the population software ‘Treemix’ by Pickrell and Pritchard (2012) DOI:10.1371/journal.pgen.1002967 to estimate the optimal number of migrations edges to add to the tree. Furthermore, it has also been updated to work with the output of OrientAGraph (see Molloy et al. 2021), a more advanced admixture graph representation software built on top of the ‘Treemix’ engine. In Treemix, it was customary to stop adding migration edges when 99.8% of variation in the data was explained, but optM automates this process using an ad hoc statistic based on the second order rate of change in the log likelihood. OptM has added functionality for various threshold modeling to compare with the ad hoc statistic. The various methods are:
install.packages("SiZer")
install.packages("OptM")
library(OptM)
To run OptM, you will need a folder of output files produced by Treemix v1.13 or OrientAGraph. The function optM will automatically search the folder for the stem.llik, stem.modelcov.gz, and stem.cov.gz files; where “stem” is that provided to the -o parameter of treemix. It is recommended, but not required, to use stem in the format stem.i.M; where
In order for optM to function properly, you must run:
NOTE: There will be an error check to see if there is variation across iterations for each M. In other words, if the data are very robust, you may get the same likelihood across all runs, thus the standard deviation across runs is zero and the ad hoc statistic is undefined. In this case, try making larger variations in the dataset (subsetting the SNPs, varying -k in treemix, or other method of permutation/bootstrap).
for m in {1..10}
do
for i in {1..5}
do
treemix \
-i test.treemix.gz \
-o test.${i}.${m} \
-global \
-m ${m} \
-k 1000
done
done
folder <- system.file("extdata", package = "OptM")
test.optM = optM(folder)
plot_optM(test.optM, method = "Evanno")
folder <- system.file("extdata", package = "OptM")
test.linear = optM(folder, method = "linear")
plot_optM(test.linear, method = "linear")
folder <- system.file("extdata", package = "OptM")
test.sizer = optM(folder, method = "SiZer")
plot_optM(test.sizer, method = "SiZer")
plot_optM
, changed the plotting color to have an alpha (semi-transparent) fill and Y-axis labels for ΔmFitak, R. R. (2021) OptM: estimating the optimal number of migration edges on population trees using Treemix. Biology Methods and Protocols. 6(1):bpab017.
citation("OptM")
into your R consoleRobert Fitak
Department of Biology
University of Central Florida
USA
rfitak9@gmail.com