Sequence::PolyTableSlice< T > Class Template Reference
[Analysis of molecular population genetic data]

A container class for "sliding windows" along a polymorphism table. More...

#include <Sequence/PolyTableSlice.hpp>

List of all members.

Public Types

typedef std::vector< std::pair
< PolyTable::const_site_iterator,
PolyTable::const_site_iterator >
>::const_iterator 
const_iterator

Public Member Functions

 PolyTableSlice (const PolyTable::const_site_iterator beg, const PolyTable::const_site_iterator end, const unsigned &window_size_S, const unsigned &window_step_len)
 PolyTableSlice (const PolyTable::const_site_iterator beg, const PolyTable::const_site_iterator end, const unsigned &window_size, const unsigned &step_len, const double &alignment_length, const double &physical_scale=1.)
const_iterator begin () const
const_iterator end () const
get_slice (const const_iterator) const throw (Sequence::SeqException)
unsigned size () const
operator[] (const unsigned &) const throw (Sequence::SeqException)

Detailed Description

template<typename T>
class Sequence::PolyTableSlice< T >

A container class for "sliding windows" along a polymorphism table.

This class is a simple container to store "sliding windows" along an object in the inheritance hierarchy of Sequence::PolyTable.

Sliding windows are used in population genetics to look at variation in levels of diversity along a region. This class supports two simple ways to make such windows. The first is the slide a window of some length (in base pairs) along your sequence, recording the SNPs in each window. The number of base pairs that you move the window each time is the "step length." The second type of window is to slide a window of a constant number of segregating sites along the SNP table. In the latter case, the step length is the number of segregating sites by which to move the beginning of the window each time. The two different constructors for this class correspond to these two different window types.

These two types of window are useful in different contexts, and it's up to the user to decide which one s/he wants. Please note that all this class does is facilitate the generation of the windows. It does not address any of the statistical headaches that arise from sliding window analyses. These issues include multiple test correction, non-independence of overlapping windows, variation in selective constraing along a sequence, and variation in power from window to window with respect to hypothesis testing.

The user should be aware that the approach used in Kreitman and Hudson (1991) "Inferring the evoltionary histories of the Adh and Adh-dup loci in Drosophila melanogaster from patterns of polymorphism and divergence." Genetics 127: 565 describe a clever variant of the sliding window. They slide along the physical sequence, but keep the number of synonymous/silent sites constant. Their procedure mitigates some of the difficulties mentioned above, but it is not implemented here because it relies on having an annotation for the SNP table available.

The user is also referred to Andolfatto, P., J. D. Wall and M. Kreitman, 1999 "Unusual haplotype structure at the proximal breakpoint of In(2L)t in a natural population of Drosophila melanogaster." Genetics 153:1397-1399, which discusses the multiple testing issue.

The following example reads in data from Hudson's program ms. Tajima's D is calculated for non-overlapping 100bp windows. It is assumed that 1000bp were simulated:

    #include<Sequence/SimData.hpp>
    #include<Sequence/SimParams.hpp>
    #include<Sequence/PolyTableSlice.hpp>
    #include<Sequence/PolySIM.hpp>
    #include<iostream>
    #include<cstdio>

    int main(int argc, char **argv)
    {
    Sequence::SimParams p;
    std::cin >> p;
    Sequence::SimData d(p.totsam());
    int i;
    while( (i=d.fromstdin()) && i != EOF) //read simulated data from stdin
    {
    Sequence::PolyTableSlice<Sequence::SimData> windows(d.sbegin(),d.send(),100,100,1000,1000);
    PolyTableSlice<Sequence::SimData>::const_iterator itr = windows.begin();
    while(itr < windows.end()) //iterate over windows
    {
    //create a data object for the current window
    SimData window = windows.get_slice(itr);
    //calculate and print Tajima's D for the window
    PolySIM analyze(&window); 
    std::cout << analyze.TajimasD() << '\t';
    }
    std::cout << std::endl;
    }
    }
Examples:

slidingWindow.cc, and slidingWindow2.cc.

Definition at line 115 of file PolyTableSlice.hpp.


Member Typedef Documentation

const_iterator type to access windows

Definition at line 151 of file PolyTableSlice.hpp.


Constructor & Destructor Documentation

template<typename T >
Sequence::PolyTableSlice< T >::PolyTableSlice ( const PolyTable::const_site_iterator  beg,
const PolyTable::const_site_iterator  end,
const unsigned &  window_size_S,
const unsigned &  step_len 
) [inline, explicit]

This constructor calculates sliding windows of a fixed number of segregating sites.

Parameters:
beg A pointer the first segregating site in the data
end A pointer to one-past-the-last segregating site in the data
window_size_S The number of segregating sites in each window
step_len The number of segregating sites by which to "jump" for each new window

Definition at line 31 of file PolyTableSlice.tcc.

template<typename T >
Sequence::PolyTableSlice< T >::PolyTableSlice ( const PolyTable::const_site_iterator  beg,
const PolyTable::const_site_iterator  end,
const unsigned &  window_size,
const unsigned &  step_len,
const double &  alignment_length,
const double &  physical_scale = 1. 
) [inline, explicit]

Use this constructor to generate a sliding window accross the sequence itself.

Parameters:
beg A pointer the first segregating site in the data
end A pointer to one-past-the-last segregating site in the data
window_size The size of the sliding window
step_len The distance by which the window jumps
alignment_length The length of the alignment in base pairs.
physical_scale. For SNP data, set this to 1. For data with positions labelled on the interval [0,1), set this equal to alignment_length. For example, if you simulate data for a 1000bp region using Hudson's program "ms", set this to 1000.

Definition at line 52 of file PolyTableSlice.tcc.


Member Function Documentation

template<typename T >
T Sequence::PolyTableSlice< T >::get_slice ( const  const_iterator  )  const throw (Sequence::SeqException) [inline]
Returns:
The window pointed to by the iterator itr.
Exceptions:
Sequence::SeqException if iterator is out of range ( >= this->end() )

Definition at line 193 of file PolyTableSlice.tcc.

template<typename T >
T Sequence::PolyTableSlice< T >::operator[] ( const unsigned &  i  )  const throw (Sequence::SeqException) [inline]
Returns:
the i-th window
Exceptions:
Sequence::SeqException if subscript i is out of range

Definition at line 220 of file PolyTableSlice.tcc.

template<typename T >
unsigned Sequence::PolyTableSlice< T >::size ( void   )  const [inline]
Returns:
The number of windows stored

Definition at line 211 of file PolyTableSlice.tcc.


The documentation for this class was generated from the following files:
Generated on Thu Aug 11 13:22:03 2011 for libsequence by  doxygen 1.6.3