

SNP_vector=[25,37,46,60];
vfrac_vector1=[0.3,0.25,0.2,0.15,0.1,0.09,0.08,0.07,0.06,0.05,0.04,0.03,0.02,0.01];
vfrac_vector2=[0.3,0.25,0.2,0.15,0.1,0.09,0.08,0.07,0.06,0.05,0.04,0.03,0.02,0.01];
successful_run=zeros(3,length(vfrac_vector1));

successful_run(1,:)=vfrac_vector1;
successful_run(2,:)=vfrac_vector2;




filename11='mouse_multi_eq_';
filename11i='_and_';
filename22='_variance_fraction_';
filename33='_trial_';
fileend='.mat';


for k=1:1
    
    SNP1=37;
    SNP2=46;
    SNP_name1=num2str(SNP1);
    SNP_name2=num2str(SNP2);
    
    for i =1:length(vfrac_vector1)
        
        vfrac=vfrac_vector1(i);
        vfrac_name1=num2str(vfrac*100);
        
        for j =1:25
            
            trial_name1= num2str(j);
            new_filename1 = [filename11 SNP_name1 filename11i  SNP_name2 filename22 vfrac_name1 filename33 trial_name1 fileend];
            
            load (new_filename1)
            
            sorted_TIM= sort(times_in_model,'descend');
            success_count=0;
            
            if ( times_in_model(SNP1)==sorted_TIM(1) || times_in_model(SNP1)==sorted_TIM(2) || times_in_model(SNP1)==sorted_TIM(3) || times_in_model(SNP1)==sorted_TIM(4) || times_in_model(SNP1)==sorted_TIM(5) || times_in_model(SNP1)==sorted_TIM(6) || times_in_model(SNP1)==sorted_TIM(7) ||times_in_model(SNP1)==sorted_TIM(8) || times_in_model(SNP1)==sorted_TIM(9) || times_in_model(SNP1)==sorted_TIM(10) )
                
                success_count=success_count+1;
                
            end
            
            if ( times_in_model(SNP2)==sorted_TIM(1) || times_in_model(SNP2)==sorted_TIM(2) || times_in_model(SNP2)==sorted_TIM(3) || times_in_model(SNP2)==sorted_TIM(4) || times_in_model(SNP2)==sorted_TIM(5) || times_in_model(SNP2)==sorted_TIM(6) || times_in_model(SNP2)==sorted_TIM(7) ||times_in_model(SNP2)==sorted_TIM(8) || times_in_model(SNP2)==sorted_TIM(9) || times_in_model(SNP2)==sorted_TIM(10) )
                
                success_count=success_count+1;
                
            end
            
            if success_count==2
            successful_run(3,i)= successful_run(3,i)+1;
            end
            
        end
    end
end

successful_run(4,:)=successful_run(3,:)/25;


% plot colours (c, m, y, k, r, g, b, w)

plot3( successful_run(1,:), successful_run(2,:), successful_run(4,:),'blue');
xlabel (' Variance fraction explained for SNP 37');
ylabel (' Variance fraction explained for SNP 46 ');
zlabel ( ' Probability that  both simulated snps are found');
title ( 'A plot showing the probability that simuated markers are found using MCMC method');


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