

Scale_vector=[25,37,46,60];
vfrac_vector=[0.45,0.4,0.35,0.3,0.25,0.2,0.15,0.1,0.05];
successful_run=zeros(6,length(vfrac_vector));
successful_freq=zeros(6,length(vfrac_vector));
successful_freq(1,:)=vfrac_vector;
successful_run(1,:)=vfrac_vector;
successful_runa=successful_run;
successful_freqa=successful_freq;
successful_run2=successful_run;
successful_freq2=successful_freq;
successful_runb=successful_run;
successful_freqb=successful_freq;
filename11='mousesnp_';
filename22='_variance_fraction_';
filename33='_trial_';
load_count=0;
triallength=20;


for k=1:length(Scale_vector)
    
    %SNP=60;
    SNP=Scale_vector(k);
    Scale_name1=num2str(SNP);
    
    for i =1:length(vfrac_vector)
        smcmc=0;
        sfreq=0;
        smcmc2=0;
        sfreq2=0;
        vfrac=vfrac_vector(i);
        vfrac_name1=num2str(vfrac*100);
        filename4 = [filename11 Scale_name1  filename22 vfrac_name1 filename33];
        [smcmc,sfreq,smcmc2,sfreq2]= MCMCplotter(SNP, 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_freq2(k+1,i)=successful_freq2(k+1,i)+sfreq+sfreq2;
        %successful_run2(k+1,i)=successful_run2(k+1,i)+smcmc+smcmc2;
       
    end
end

lc=20;


for n=1:length(Scale_vector)
    for m=1:9
        successful_runa(n+1,m)=successful_run(n+1,m)/lc;
        successful_freqa(n+1,m)=successful_freq(n+1,m)/lc;
        %successful_runb(n+1,m)=successful_run2(n+1,m)/lc;
        %successful_freqb(n+1,m)=successful_freq2(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_runa(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 with scale 1(red line) 5(blue) 10(g) 40(m) 100(y)');
hold on
plot( successful_run(1,:), successful_runa(3,:), 'blue');
plot( successful_run(1,:), successful_runa(4,:), 'g');
plot( successful_run(1,:), successful_runa(5,:), 'black');
hold off

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