University of Michigan Center for Statistical 
Genetics
Search
 
 

 
 

FORTRAN version of SNP-HWE

The FORTRAN version of SNP-HWE can be downloaded by following the link below and right clicking on the source code. Once this function has been incorporated into your program, it can be called by passing observed counts for each of the three SNP genotypes (heterozygote, homozygote_1, and homozygote_2) as function arguments. The code snippet below illustrates a typical calling sequence to read in genotype counts listed in a column delimited text file ("genotype_counts_f.txt") and perform the exact test of Hardy-Weinberg on each marker:

genotype_counts_f.txt:

            100              3              5
             57             14             50
             31             32             51
             47              3              5
            150             32             55
            122              7             32
             99              3             14
            146             13             54
            177            100             57
            184             57            155
            178             33             22


MAIN from run_marker_tests.f:

C ******************** TEST CODE FOR FUNCTION SNPHWE  ***********************
C
C NOTE: MAXHET SETS THE MAXIMUM POSSIBLE NUMBER OF HETEROZYGOTES PER SAMPLE. 
C       IF YOUR DATA SET INCLUDES MORE THAN THE DEFAULT NUMBER OF
C       MINOR ALLELE COPIES AT ANY SINGLE MARKER LOCUS, MAXHET SHOULD BE 
C       INCREMENTED ACCORDINGLY.
C
C ***************************************************************************
C
      PROGRAM MAIN
C
         PARAMETER (MAXHET=5000)
C
         IMPLICIT  REAL*8(A-H, O-Z)
         INTEGER   HETS(MAXHET), HOMS1(MAXHET), HOMS2(MAXHET)
         REAL*8    PVS(MAXHET)
C
         DATA KTEST/1/
         OPEN(KTEST,FILE='genotype_counts_f.txt',STATUS='OLD')
C
         DO 10 I=1, 10
            READ(KTEST, 101)HETS(I), HOMS1(I), HOMS2(I)
 101        FORMAT(I15, I15, I15)
 10      CONTINUE
C
         DO 20 I=1, 10
           PVS(I) = SNPHWE(HETS(I), HOMS1(I), HOMS2(I), MAXHET)
           WRITE(KOUT, 103)'P_VALUE = ' , PVS(I)
 103       FORMAT(A10, G15.10)
 20      CONTINUE
C
         STOP
      END

Source distribution

    SNP-HWE (FORTRAN) 

 
 

University of Michigan | School of Public Health