% abc_bayenv2_sim_autos simulate Bayenv values. % abc_bayenv2_sim_autos % % Simulate Bayenv2 values (BayesFactors) from 10 best demographic simulations. % % Inputs: % Matlab file abc_reject_autos.mat contains demographic parameter of best fitting % the observed data. % % Outputs: % Matlab file abc_bayenv2_sim_autos.mat contains Bayes factors simuated from best fitting neutral % abc_bayenv2_sim_autos.m % Written by Andreas Wollstein, Ludwig Maximilians University of Munich. % Copyright (c) 2015 % % This file is part of a set of Matlab scripts published with: % Bozicevic et al. 2015 Molecular Ecology % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program. If not, see . clear; load abc_reject_chrX.mat; [s idx] = sort(sims.dist); Nsam = 1000; BFSIM = []; p1 = 1:8; p2 = 9:19; p3 = 20:45; p4 = 46:66; popids = ones(1,66); popids(p2) = 2; popids(p3) = 3; popids(p4) = 4; matrixfile = '~/Dropbox/online_projects/multi_locus_model/bayenv2_covmatrix_chrX.txt'; envfile = '~/Dropbox/vedran_share/matlab/bayenv2_env_variables_standardized_final.txt'; for i=1:Nsam % use only the 10 best try fprintf('run %d / %d\n',i,Nsam); j = mod(i,10); H = abc_runms(sims.params(idx(j),:)); haplo = []; for k=1:length(H) if ~isempty(H{k}) haplo = [haplo H{k}]; end end %% todo check if pop order is same as in matrix file BF = bayenv2_wrapper(haplo,matrixfile,envfile, popids); BFSIM = [BFSIM ; BF]; save('abc_bayenv2_sim_chrX_new.mat','BFSIM') catch end end