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 1 1 2 1 2 2 1 0 1 0 0 1 1 2 1 0 0 1 0 2 1 1 0 1 1 1 2 0 2 2 0 0 1 0 1 1 0 2 1 1 1 1 2 0 0 0 1 1 2 0 2 9 1 2 1 2 1 2 2 1 0 0 0 0 2 2 2 1 0 1 2 1 2 1 2 2 2 0 1 2 1 2 1 1 1 2 2 2 0 9 1 1 0 1 9 0 9 9 0 1 2 0 0 0 2 2 2 2 1 1 0 0 0 1 1 0 1 1 0 1 0 1 1 1 9 9 0 9 2 0 2 0 0 1 1 0 0 1 0 1 1 1 1 1 1 1 1 2 0 2 0 0 0 2 2 1 1 0 1 1 0 1 0 2 1 0 1 1 1 1 0 0 0 1 0 1 2 1 9 0 0 0 9 0 1 1 1 1 0 0 2 1 1 0 0 1 1 1 0 9 0 0 1 9 9 9 9 1 0 1 1 0 1 0 0 1 0 2 0 1 0 0 2 2 2 0 2 2 1 0 0 2 2 1 1 2 0 2 1 0 2 1 0 1 1 1 1 1 0 2 2 2 2 1 1 1 2 1 2 1 0 1 1 1 2 2 1 0 0 2 2 0 1 0 1 1 0 2 2 0 0 0 1 2 9 0 2 1 0 1 1 1 1 1 0 0 1 1 1 0 1 1 2 0 0 0 1 1 2 1 1 2 0 2 1 1 1 0 9 0 0 1 0 2 2 0 0 0 2 1 1 1 1 1 2 1 2 1 2 1 9 2 1 1 1 1 0 0 2 2 0 0 0 0 1 1 2 1 1 1 2 2 1 1 2 2 1 2 1 2 1 1 1 1 1 1 0 1 1 2 1 1 1 2 1 0 2 1 1 0 1 2 1 0 1 0 0 2 1 1 0 2 1 0 9 9 0 0  1 %D2MIT25    D2Mit25    D2Mit25    
];
mrkname=[      'D2MIT362'
      'D2MIT72 '
      'D2Mit205'
      'D2Mit38 '
      'D2Mit93 '
      'D2MIT389'
      'D2Mit17 '
      'D2MIT260'
      'D2Mit25 '];
res34=[];
for i=1:8
   n22=length(find(x(i,7:540)==2 & x(i+1,7:540)==2));
   n21=length(find(x(i,7:540)==2 & x(i+1,7:540)==1));
   n20=length(find(x(i,7:540)==2 & x(i+1,7:540)==0));
   n12=length(find(x(i,7:540)==1 & x(i+1,7:540)==2));
   n11=length(find(x(i,7:540)==1 & x(i+1,7:540)==1));
   n10=length(find(x(i,7:540)==1 & x(i+1,7:540)==0));
   n02=length(find(x(i,7:540)==0 & x(i+1,7:540)==2));
   n01=length(find(x(i,7:540)==0 & x(i+1,7:540)==1));
   n00=length(find(x(i,7:540)==0 & x(i+1,7:540)==0));
   NN=[n22,n21,n20,n12,n11,n10,n02,n01,n00];
   N=sum(NN);
   
   [r, details]=rEstF2(n22,n21,n20,n12,n11,n10,n02,n01,n00);
   LOD=calcLOD_F2(r,n22,n21,n20,n12,n11,n10,n02,n01,n00);
   LR=calcLR_F2(r,n22,n21,n20,n12,n11,n10,n02,n01,n00);
   v=(1-2*r)/(2*r*N*(1-r)*(2+r));
   n2R=n20+n02; n1R=n12+n21+n01+n10; n0R=n22+n00;
   LB=r-2*sqrt(v); UB=r+2*sqrt(v);
   pLR=chi2pdf(LR,1);
   
   EN=N*[1/16 1/8 1/16 1/8 1/4 1/8 1/16 1/8 1/16];
   chi=sum((NN-EN).^2./EN);
   pchi=chi2pdf(chi,1);
   
   sprintf('%8.5f %8.6f\n', details');
   
   dat=[n2R n1R n0R n11 r sqrt(v) LR LOD chi pLR];
    res34=[res34 sprintf([mrkname(i,:) '--' mrkname(i+1,:) ' ']) sprintf('%d %d %d %d %6.2f %6.2f %5.1f %5.1f %5.1f %6.3f\n',dat)];   
end

function LOD=calcLOD_F2(r,n22,n21,n20,n12,n11,n10,n02,n01,n00)
%%log likelihood under H1
LOD=(n22+n00)*log10((1-r)^2/4)...
   +(n20+n02)*log10(r^2/4)...
   +(n21+n12+n10+n01)*log10(r*(1-r)/2)...
   +n11*log10((1-r)^2/2+r^2/2);
%%log likelihood under H0
r=0.5;
LOD0=(n22+n00)*log10((1-r)^2/4)...
   +(n20+n02)*log10(r^2/4)...
   +(n21+n12+n10+n01)*log10(r*(1-r)/2)...
   +n11*log10((1-r)^2/2+r^2/2);
LOD=LOD-LOD0;

function LR=calcLR_F2(r,n22,n21,n20,n12,n11,n10,n02,n01,n00)
%%log likelihood under H1
L=(n22+n00)*log((1-r)^2/4)...
   +(n20+n02)*log(r^2/4)...
   +(n21+n12+n10+n01)*log(r*(1-r)/2)...
   +n11*log((1-r)^2/2+r^2/2);
%%log likelihood under H0
r=0.5;
L0=(n22+n00)*log((1-r)^2/4)...
   +(n20+n02)*log(r^2/4)...
   +(n21+n12+n10+n01)*log(r*(1-r)/2)...
   +n11*log((1-r)^2/2+r^2/2);
LR=2*(L-L0);


function [r, details]=rEstF2(n22,n21,n20,n12,n11,n10,n02,n01,n00)
%estimate recombination rate r for F2
n=n22+n21+n20+n12+n11+n10+n02+n01+n00;
r=0.1; r1=-1;    
details=[];
while (abs(r1-r)>1.e-8)
       
   r1=r;
       
   %E-step
   phi=r^2/((1-r)^2+r^2);

   %M step
   r=1/(2*n)*(2*(n20+n02)+(n21+n12+n10+n01)+2*phi*n11);
    details=[details; [phi r]];
end
