User:Ragausi/sandbox

Example
Three population of eacht ten individuals with two possible alleles A and a per locus. Population 1: AA,Aa,AA,aa,aA,AA,AA,aA,AA,Aa
 * $$ p_1=0.7$$ (allele A)
 * $$ p_2=0.3$$ (allele a)

Population 2: AA,Aa,AA,aa,aA,AA,AA,aA,AA,AA (varies only in one locus)
 * $$ p_1=0.75$$ (allele A)
 * $$ p_2=0.25$$ (allele a)

Population 3: aa,aA,Aa,aa,aA,aa,Aa,aA,AA,Aa
 * $$ p_1=0.4$$ (allele A)
 * $$ p_2=0.6$$ (allele a)


 * {| class="toccolours collapsible collapsed" width="60%" style="text-align:left"

!Allele frequencies can be calculated as following: Population 1:
 * $$ p_1=\frac{2+1+2+0+1+2+2+1+2+1}{2*10}=\frac{14}{20}=0.7$$ (frequency for allele A)
 * $$ p_2=\frac{0+1+0+2+1+0+0+1+0+1}{2*10}=\frac{}{20}=0.3$$ (frequency for allele a)

Population 2:
 * $$ p_1=\frac{2+1+2+0+1+2+2+1+2+2}{2*10}=\frac{}{20}=0.75$$ (frequency for allele A)
 * $$ p_2=\frac{0+1+0+2+1+0+0+1+0+0}{2*10}=\frac{}{20}=0.25$$ (frequency for allele a)

Population 3:
 * $$ p_1=\frac{0+1+1+0+1+0+1+1+2+1}{2*10}=\frac{}{20}=0.4$$ (frequency for allele A)
 * $$ p_2=\frac{2+1+1+2+1+2+1+1+0+1}{2*10}=\frac{}{20}=0.6$$ (frequency for allele a)


 * }

Euclidean Distance $$ D_{EU}$$

 * $$\begin{align}

D_{EU12}=0.0707 \end{align} $$


 * $$\begin{align}

D_{EU13}=0.424 \end{align} $$


 * $$\begin{align}

D_{EU23}=0.495 \end{align} $$


 * {| class="toccolours collapsible collapsed" width="60%" style="text-align:left"

!calculation of euclidean distance $$ D_{EU}$$
 * $$\begin{align}
 * $$\begin{align}
 * $$\begin{align}

D_{EU12}=\sqrt{\sum \limits_{i=1}^2(p_i-p_i')^2}=\sqrt{(0.7-0.75)^2+(0.3-0.25)^2}=0.0707 \end{align} $$


 * $$\begin{align}

D_{EU13}=\sqrt{\sum \limits_{i=1}^2(p_i-p_i')^2}=\sqrt{(0.7-0.4)^2+(0.3-0.6)^2}=0.424 \end{align} $$


 * $$\begin{align}

D_{EU23}=\sqrt{\sum \limits_{i=1}^2(p_i-p_i')^2}=\sqrt{(0.75-0.4)^2+(0.25-0.6)^2}=0.495 \end{align} $$
 * }

Cavalli-Sforza and Edwards 1967 $$ D_{CH}$$

 * $$\begin{align}

D_{CH12}=0.146 \end{align} $$
 * $$\begin{align}

D_{CH13}=0.194 \end{align} $$
 * $$\begin{align}

D_{CH13}=0.229 \end{align} $$


 * {| class="toccolours collapsible collapsed" width="60%" style="text-align:left"

!calculation of Cavalli-Sforza and Edwards 1967 $$ D_{CH}$$
 * $$\begin{align}
 * $$\begin{align}
 * $$\begin{align}

cos\Theta_{12}=\sum \limits_{i=1}^2 \sqrt{p_ip_i'}=\sqrt{0.7*0.75}+\sqrt{0.3*0.25}=0.974 \end{align} $$


 * $$\begin{align}

D_{CH12}=\frac{2}{\pi}\sqrt{2(1-\cos\Theta_{12})}==\frac{2}{\pi}\sqrt{2(1-0.974)}=0.146 \end{align} $$


 * $$\begin{align}

cos\Theta_{13}=\sum \limits_{i=1}^2 \sqrt{p_ip_i'}=\sqrt{0.7*0.4}+\sqrt{0.3*0.6}=0.953 \end{align} $$


 * $$\begin{align}

D_{CH13}=\frac{2}{\pi}\sqrt{2(1-\cos\Theta_{13})}==\frac{2}{\pi}\sqrt{2(1-0.953)}=0.194 \end{align} $$


 * $$\begin{align}

cos\Theta_{23}=\sum \limits_{i=1}^2 \sqrt{p_ip_i'}=\sqrt{0.75*0.4}+\sqrt{0.25*0.6}=0.935 \end{align} $$


 * $$\begin{align}

D_{CH23}=\frac{2}{\pi}\sqrt{2(1-\cos\Theta_{23})}==\frac{2}{\pi}\sqrt{2(1-0.935)}=0.229 \end{align} $$
 * }