pal.popgen
Class LinkageDisequilibrium

java.lang.Object
  extended by java.lang.Thread
      extended by pal.popgen.LinkageDisequilibrium
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable, TableReport

public class LinkageDisequilibrium
extends java.lang.Thread
implements java.io.Serializable, TableReport

This class calculates D' and r^2 estimates of linkage disequilibrium. It also calculates the significance of the LD by either Fisher Exact or the multinomial permutation test. This class can work with either normal alignments of annotated alignments. The alignments should be stripped of invariable sites. 2 state estimates of D' and r^2 can be found reviewed and discussed in Weir 1996 multi-state loci (>=3) require an averaging approach. These should not be used for popgen parameter estimates, unless you know specifically that it works for multistate loci. The estimate of D' is the approach used by Farnir 2000 Genome Research 10:220-227 that follows Hedrick 1987. r^2 was estimated in a similar way.

Version:
$Id: LinkageDisequilibrium.java,v 1
Author:
Ed Buckler
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  Alignment theAlignment
           
protected  AnnotationAlignment theAnnotationAlignment
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LinkageDisequilibrium(Alignment alignment)
          compute LD based on an alignment.
LinkageDisequilibrium(Alignment alignment, boolean rapidPermute, int numberOfPermutations)
          compute LD based on an alignment
 
Method Summary
 AnnotationAlignment getAnnotatedAlignment()
          Returns an annotated aligment if one was used for this LD this could be used to access information of locus position
 double getDPrime(int r, int c)
          Returns D' estimate for a given pair of sites
 int getN(int r, int c)
          Get number of gametes included in LD calculations (after missing data was excluded)
 double getP(int r, int c)
          Returns P-value estimate for a given pair of sites.
 double getRSqr(int r, int c)
          Returns r^2 estimate for a given pair of sites
 int getSiteCount()
          Returns the counts of the sites in the alignment
 java.lang.Object[] getTableColumnNames()
          get the names of the columns
 java.lang.Object[][] getTableData()
          get the data elements
 java.lang.String getTableTitle()
          get the title of the table
 void print(LinkageDisequilibrium ld, java.io.PrintWriter out)
          print the LD to the PrintWrite
 void run()
          starts the thread to calculate LD
 java.lang.String toString()
          returns representation of the LD results as a string
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

theAlignment

protected Alignment theAlignment

theAnnotationAlignment

protected AnnotationAlignment theAnnotationAlignment
Constructor Detail

LinkageDisequilibrium

public LinkageDisequilibrium(Alignment alignment)
compute LD based on an alignment. The default is to used used rapid permutations that provides slightly biased P-values, and 1000 permutations to evaluate P-values.

Parameters:
alignment - Alignment or AnnotationAlignment (this should only contain polymorphic sites)

LinkageDisequilibrium

public LinkageDisequilibrium(Alignment alignment,
                             boolean rapidPermute,
                             int numberOfPermutations)
compute LD based on an alignment

Parameters:
alignment - Alignment or AnnotationAlignment (this should only contain polymorphic sites)
rapidPermute - Use a rapid approach to P-value estimation (see Contigency Table)
numberOfPermutations - The number of permutations to determine P values
Method Detail

run

public void run()
starts the thread to calculate LD

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getP

public double getP(int r,
                   int c)
Returns P-value estimate for a given pair of sites. If there were only 2 alleles at each locus, then the Fisher Exact P-value (one-tail) is returned. If more states then the permutaed Monte Carlo test is used.

Parameters:
r - is site 1
c - is site 2
Returns:
P-value

getN

public int getN(int r,
                int c)
Get number of gametes included in LD calculations (after missing data was excluded)

Parameters:
r - is site 1
c - is site 2
Returns:
number of gametes

getDPrime

public double getDPrime(int r,
                        int c)
Returns D' estimate for a given pair of sites

Parameters:
r - is site 1
c - is site 2
Returns:
D'

getRSqr

public double getRSqr(int r,
                      int c)
Returns r^2 estimate for a given pair of sites

Parameters:
r - is site 1
c - is site 2
Returns:
D'

getSiteCount

public int getSiteCount()
Returns the counts of the sites in the alignment


getAnnotatedAlignment

public AnnotationAlignment getAnnotatedAlignment()
Returns an annotated aligment if one was used for this LD this could be used to access information of locus position


toString

public java.lang.String toString()
returns representation of the LD results as a string

Overrides:
toString in class java.lang.Thread

print

public void print(LinkageDisequilibrium ld,
                  java.io.PrintWriter out)
print the LD to the PrintWrite


getTableColumnNames

public java.lang.Object[] getTableColumnNames()
Description copied from interface: TableReport
get the names of the columns

Specified by:
getTableColumnNames in interface TableReport
Returns:
column names for the table

getTableData

public java.lang.Object[][] getTableData()
Description copied from interface: TableReport
get the data elements

Specified by:
getTableData in interface TableReport
Returns:
data for the table

getTableTitle

public java.lang.String getTableTitle()
Description copied from interface: TableReport
get the title of the table

Specified by:
getTableTitle in interface TableReport
Returns:
the title of the table