Scroll to navigation

Bio::PopGen::Simulation::GeneticDrift(3pm) User Contributed Perl Documentation Bio::PopGen::Simulation::GeneticDrift(3pm)


Bio::PopGen::Simulation::GeneticDrift - A simple genetic drift simulation


  use Bio::PopGen::Simulation::GeneticDrift;
  my $sim = Bio::PopGen::Simulation::GeneticDrift->new(-popsize => 40,
                                                      -alleles => {A => 0.2,
                                                                   B => 0.8});
  for(my $i =0 ;$i < 10; $i++ ) {
    my %f = $sim->next_generation; # get the freqs for each generation
  for(my $i =0 ;$i < 10; $i++ ) {
    # get the allele freqs as part of a Bio::PopGen::Population object
    my $pop = $sim->next_generation('population'); 


A very simple 1 locus multi-allele random drift module, start with an initial set of allele frequency and simulate what happens over time.

This isn't really useful for anything in particular yet but will be built upon.

See Gillespie JH. (1998) "Population Genetics: a Concise guide." The Johns
Hopkins University Press, Baltimore, USA. pp.19-47.


Mailing Lists

User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated.                  - General discussion  - About the mailing lists


Please direct usage questions or support issues to the mailing list:

rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.

Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via email or the web:

AUTHOR - Jason Stajich

Email jason-at-bioperl-dot-org


The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _


 Title   : new
 Usage   : my $obj = Bio::PopGen::Simulation::GeneticDrift->new();
 Function: Builds a new Bio::PopGen::Simulation::GeneticDrift object 
 Returns : an instance of Bio::PopGen::Simulation::GeneticDrift
 Args    : -popsize => starting N
           -haploid => boolean if we should simulate haploids 
           -alleles => arrayref of the allele names
           -population => L<Bio::PopGen::PopulationI> object to initialize 
                          from some previously defined Population object
                          (or result from a previous simulation)


 Title   : next_generation
 Usage   : my %generation = $sim->next_generation
 Function: Get the next generation of allele frequencies based on the current
 Returns : Hash of allele frequencies
 Args    : 'allelefreqs' or 'population' to get back a hash of allele 
                 frequencies (default) OR a L<Bio::PopGen::Population> object


 Title   : population_size
 Usage   : $obj->population_size($newval)
 Example : 
 Returns : value of population_size (a scalar)
 Args    : on set, new value (a scalar or undef, optional)


 Title   : set_Frequencies_Equivalent
 Usage   : $sim->set_Frequencies_Equivalent
 Function: Reset the allele frequencies so they are all even
 Returns : none
 Args    : none


 Title   : get_Allele_Frequencies
 Usage   : my %allele_freqs = $marker->get_Allele_Frequencies;
 Function: Get the alleles and their frequency (set relative to
           a given population - you may want to create different
           markers with the same name for different populations
           with this current implementation
 Returns : Associative array where keys are the names of the alleles
 Args    : none


 Title   : add_Allele_Frequency
 Usage   : $marker->add_Allele_Frequency($allele,$freq)
 Function: Adds an allele frequency
 Returns : None
 Args    : $allele - allele name
           $freq   - frequency value


 Title   : reset_alleles
 Usage   : $marker->reset_alleles();
 Function: Reset the alleles for a marker
 Returns : None
 Args    : None


 Title   : validate_Frequencies
 Usage   : if( $sim->validate_Frequencies) {}
 Function: Sanity checker that allele frequencies sum to 1 or less
 Returns : boolean
 Args    : -strict => 1 boolean if you want to insure that sum of freqs is 1
2018-10-27 perl v5.26.2