

SNP_vector=[87,176];
vfrac_vector=[0.45,0.4,0.35,0.3,0.25,0.2,0.15,0.1,0.05];
successful_run=zeros(3,length(vfrac_vector));
successful_freq=zeros(3,length(vfrac_vector));
successful_freqpval=zeros(3,length(vfrac_vector));
successful_freq(1,:)=vfrac_vector;
successful_run(1,:)=vfrac_vector;
successful_freqpval(1,:)=vfrac_vector;
successful_run2=successful_run;
successful_freq2=successful_freq;
successful_freqpval2=successful_freq;
filename11='cc_SNP_';
filenameand='_and_';
filename22='_variance_fraction_';
filename33='_trial_';
load_count=0;
triallength=40;


for k=1:1
    
    SNP1=SNP_vector(1);
    SNP_name1=num2str(SNP1);
    SNP2=SNP_vector(2);
    SNP_name2=num2str(SNP2);
    
    for i =1:length(vfrac_vector)
        smcmc=0;
        sfreq=0;
        sfreqpval=0;
        vfrac=vfrac_vector(i);
        vfrac_name1=num2str(vfrac*100);
        filename4 = [filename11 SNP_name1 filenameand SNP_name2 filename22 vfrac_name1 filename33];
        [smcmc,sfreqpval]= MCMCplotter(SNP1,SNP2, triallength, filename4 );
        successful_freq(k+1,i)=successful_freq(k+1,i)+sfreq;
        successful_run(k+1,i)=successful_run(k+1,i)+smcmc;
        successful_freqpval(k+1,i)=successful_freqpval(k+1,i)+sfreqpval;
       
    end
end

lc=40;


for n=1:1
    for m=1:length(vfrac_vector)
        successful_run2(n+1,m)=successful_run(n+1,m)/lc;
        successful_freq2(n+1,m)=successful_freq(n+1,m)/lc;
        successful_freqpval2(n+1,m)=successful_freqpval(n+1,m)/lc;
       
    end
end



% plot colours (c, m, y, k, r, g, b, w)[1,5,10,40,100]

plot( successful_run(1,:), successful_run2(2,:), 'red');
xlabel (' Variance fraction explained ');
ylabel ( ' Probability that simulated snp is found');
title ( 'A plot showing the probability that simuated marker is found using MCMC method (redline) and glmcoeffs(blue)');
hold on
plot( successful_run(1,:), successful_freq2(2,:), 'blue');
hold off

saveas(gcf,'cc_sim_plot_total_coeffs','pdf'); 
saveas(gcf,'cc_sim_plot_total_coeffs','fig'); 

plot( successful_run(1,:), successful_run2(2,:), 'red');
xlabel (' Variance fraction explained ');
ylabel ( ' Probability that simulated snp is found');
title ( 'A plot showing the probability that simuated marker is found using MCMC method (redline) and glmpval(blue)');
hold on
plot( successful_run(1,:), successful_freqpval2(2,:), 'blue');
hold off

saveas(gcf,'cc_sim_plot_total_pval','pdf'); 
saveas(gcf,'cc_sim_plot_total_pval','fig'); 

newfile='ccplot';
save(newfile)
