T = readtable('variant.pheno.maf.chisq.p.txt','TreatAsEmpty','NA');

set(gcf,'paperunits','inches','papersize',[8 3.5],'renderer','painters','position',[0 600 800 350])
set(0,'defaultaxesfontsize',10)
clf

markersize = 5;
abcdx = -0.2; abcdy = 1.05;

for plot_ind = 1:2
    subplot(1,2,plot_ind)
    hold on
    scatter(T.CHISQ_WESimp,T.CHISQ_WES_200K,markersize)
    plot([0 7000],[0 7000],'color',0.8*[1 1 1])
    xlabel('\chi^2, genotypes imputed from {\it{N}}=50K WES into {\it{N}}=200K')
    ylabel('\chi^2, genotypes from {\it{N}}=200K WES')
    if plot_ind==2
        axis([0 100 0 100])
        plot([0 100],29.7168*[1 1],'r')
        text(70,35,'{\it{P}} < 5 x 10^{-8}','color','r')
        title('Association test consistency (zoom-in)')
    else
        title('Association test statistic consistency')
    end
    axis square
    text(abcdx,abcdy,char('a'+(plot_ind-1)),'fontweight','bold','units','normalized')
end

print('chisq_WES_200K_vs_WESimp.png','-dpng')
