‹‹ Back to SVS Home

Plotting Hardy Weinberg

15.1 Plotting Hardy Weinberg


[Picture]
Figure 15.1: Tree view, Opening Hardy Weinberg Equilibrium plot

Left-clicking on the node brings up a context menu. Click on Visualize Genetics->Hardy Weinberg Equilibrium Plot in the context menu to open a graph of the Hardy Weinberg Equilibrium of the markers with respect to the subset of the data at the node. Figure 15.1 shows the window and menus.

Alternatively, from a spreadsheet view, the menus Genetics->Hardy Weinberg Equilibrium Plot will graph the Hardy Weinberg Equilibrium of the markers for the currently selected subset of the spreadsheet.

15.1.1 Hardy Weinberg Equilibrium Plot


[Picture]
Figure 15.2: Hardy Weinberg plot

There are 200 markers in the data set shown in Fig. 15.2. By clicking in a location, a table appears at the lower left showing the number of alleles the marker has, the P Value for the HWE Correlation, the negative log of the P value, and the HWE correlation, R. Clicking on any other point updates the table. (The table is shown in Fig. 16.6).

The button functions are as follows:

15.1.2 Reset View

Pressing the Reset View button restores the plot to the original (unzoomed) view.

15.1.3 Copy to Clipboard

This button copies the table appearing at bottom left to the clipboard so it can be pasted into other applications.

15.1.4 Axis Selector


[Picture]
Figure 15.3: Close-up of Axis selector drop down menu

Use the drop down menu (Fig. 15.3 to choose between plotting HWE Correlation R, or –log10P.

15.1.5 Zooming into the Graph


[Picture]
Figure 15.4: You can zoom the plot by Right-Clicking and dragging a rectangular region


[Picture]
Figure 15.5: Window showing the result of the drag and zoom

utlined in 16.6HT Zoomed in HWE plot

15.1.6 File Menu


[Picture]
Figure 15.6: File menu for the Hardy Weinberg Equilibrium plot

Figure 15.6 shows the File menu that allows you to create a bitmap, print an image of the plot, or export three comma-separated-value (CSV) outputs of the Hardy-Weinberg Equilibrium plot. All of these apply to the entire range (x-axis) of the plot, as currently showing with any zoom in effect.

The menu options are as follows:

15.1.7 Create Bitmap

The menu choices File->Create Bitmap opens a Save As file dialog (Fig. 15.7) to navigate and save the plot as a bitmap file for incorporation into other documents.


[Picture]
Figure 15.7: Typical Save As window


[Picture]
Figure 15.8: A saved bitmapped image. Note that all window controls such as buttons, pull downs and menus are removed.

15.1.8 Print Image


[Picture]
Figure 15.9: Menu choices File->Print Image opens a print dialog window

15.1.9 Summarize All Data to CSV File

To save the summary of the data as a CSV file, Click the menus File-> Summarize All Data to bring up the data in a spreadsheet as shown in Fig. 15.10.


[Picture]
Figure 15.10: Hardy Weinberg Equilibrium plot summarized in a spreadsheet view

The fields for this output are as follows:


Field Value
Marker Name of the x-coordinate marker
Chi Squared Total Over all observations
p Value From the Chi squared total
Neg Log p Logarithm base 10
HWE Correlation R Hardy-Weinberg correlation/disequilibrium

Then click File-> Save As... to finalize saving the summary of the data.

15.1.10 Output All Allele Tables to CSV File


[Picture]
Figure 15.11: Spreadsheet view of allele table from Hardy Weinberg Equilibrium plot

To save the summary of the Allele Tables as a CSV file, click the menus File-> View All Allele Tables to bring up the data in a spreadsheet as shown in Fig. 15.11.

The fields for this output are as follows:


Field Value
Marker The name of the x-coordinate marker
Allele An allele from this marker
Allele Count The number of occurrences of this allele at this marker
Allele Freq The frequency of this allele at this marker

To export the Allele Table, click File-> Save As.... This opens the Export Data window. Fill in the file name and format or Click the Browse button to open the File Save window and chose a file and format. Clicking Save saves the exported data and returns you to the Export Data window. Check the Delimiter window if you wish to change the file from Comma separated to Space or Other->. If Other-> is chosen, enter the delimiter in the box.

Similarly, check the Allele delimiter to choose between Underscore, Comma, Space or Other->.

15.1.11 Output All Genotype Tables to CSV File


[Picture]
Figure 15.12: Spreadsheet view of genotype table from Hardy Weinberg Equilibrium plot

To save the Genotype Tables as a CSV file, click the menus File-> View All Genotype Tables to bring up the data in a spreadsheet as shown in Fig. 15.12. To export the table, follow the same steps as in Section 15.1.10.

This helps answers the question “How does the actual probability of finding any genotype differ from the probability based on its constituent alleles”?

The fields for this output are as follows:


Field Value
Marker The name of the x-coordinate marker
Genotype A genotype at this marker
Count The number of occurrences of this genotype at this marker
Freq The frequency of this genotype at this marker
Dij The difference between the actual and expected genotype probabilities
Chi Square Contribution The contribution from this genotype to the marker’s entire Chi squared value

15.1.12 Hardy-Weinberg Equilibrium computation

Suppose we have a marker with alleles 1,…,k having frequencies p1,…,pk. We may write the genotype count for alleles i and j as nij. Due to phase ambiguity, if ij, we count occurances of allele i on the first chromosome and allele j on the second chromosome along with occurances of allele j on the first chromosome and allele i on the second chromosome in both the notations nij and nji.

Thus, we may write the count for allele i as ni = 2nii + j=1,jiknij. We may also express the genotype frequency for allele i occurring homozygously as pii = n
-ini, and the genotype frequency for heterozygous alleles i and j as pij = nij
n--, where n is the population count. The frequency of allele i may be expressed as

                  k
p = -ni= p  + 1  ∑   p  .
 i  2n    ii  2j=1,j⁄=i ij

We wish to check the agreement of pii with pi2 and the agreement of pij , where ij, with 2pipj. We multiply by two because of how we deal with the phase ambiguity (see above).

Thus, we will define the Hardy-Weinberg equilibrium coefficient Dii or Dij for alleles i and j such that

pii = p2i + Dii
pij = 2pipj - 2Dij (fori ⁄= j).

(It may be shown that for a biallelic marker, D11 = D12 = D22.)

We then have a chi-squared distribution with k(k-1)/2 degrees of freedom,

X2  =   n∑ki=1 (pii-p22i)2 +n ∑ki=-11∑kj=i+1 (pij-2p2pippj)2
        ∑k   (nii-pnip2i)2  ∑k -1∑k     (nij-2nipipjj)2
    =     i=1   np2i   +   i=1  j=i+1   2npipj  .

From this, we obtain the distribution’s p-value p = chisqr(X2,k(k - 1)2), and the correlation, R, from the inverse distribution for one degree of freedom, which is

    ∘---1---
R =   F--(p).
        n