quantgen.sim package

Submodules

quantgen.sim.SLiM_writer module

class quantgen.sim.SLiM_writer.SLiM_generator(mu=1e-08, generations=1000000.0, chrom_length=10000000.0, recomb_rate=1e-07, starting_pop_size=10000, starting_pop_nickname='start')[source]

Class for generating a SLiM input file

Attributes

initialization_file  
recomb_rates  
seed  

Methods

add_chromosome_element(el_type, start, end) Adds a chromosomal element to the simulation
add_element_type(nickname, mut_types) Adds a genomic element type to the simulation
add_initialization_file(file) Adds an initialization file to start the population at a certain state
add_interval_recomb_rate(start, end, recomb_rate) Adds a specific recombination rate to a given interval.
add_mutation_type(nickname, h, dfe_type[, ...]) Adds a mutation type to the simulation
add_output_option(generation, output_type[, ...]) Adds an output option the the simulation
add_population(pop_nickname, ...[, source_pop]) Adds a new population to the simulation
add_predetermined_mutation(generation, ...) Adds a predetermined mutation to a population at a given time
change_pop_migration(source_pop_nickname, ...) Changes the migration rate from a source to a target population
change_pop_selfing(pop_nickname, ...) Changes the selfing rate of a population
change_pop_size(pop_nickname, ...) Changes the size of a population starting at a given generation
set_gene_conversion(fraction, mean_stretch) Adds gene conversion to the simulation
set_random_seed(seed) Sets the seed for the random number generator
write_input_file(file[, max_size]) Writes the input file for the SLiM simulation
__init__(mu=1e-08, generations=1000000.0, chrom_length=10000000.0, recomb_rate=1e-07, starting_pop_size=10000, starting_pop_nickname='start')[source]

Instantiates an object capable of generating a SLiM file.

Also adds a single neutral mutation type as m1 (nickname ‘neutral’)

Parameters:

mu : float

The mutation probability per nucleotide per generation

generations : int

The number of generations to run the simulation

chrom_length : int

The length of the chromosome in bp

recomb_rate : float

The basal recombination rate as a probability of a crossover event per bp

starting_pop_size : int

The effective size of the initial population. Note that you can add more if you want and/or change its parameters

starting_pop_nickname : str

A nickname for the starting population

add_chromosome_element(el_type, start, end)[source]

Adds a chromosomal element to the simulation

Parameters:

el_type : str

The nickname for the element type for this element

start : int

The start point for the element on the chromosome

end : int

The end point for the element on the chromosome

add_element_type(nickname, mut_types)[source]

Adds a genomic element type to the simulation

Parameters:

nickname : str

A nickname for the genomic element type (doesn’t affect the simulation file)

mut_types : dict

The mutation types you want to affect this element type, as a dictionary of nickname -> relative proportion

add_initialization_file(file)[source]

Adds an initialization file to start the population at a certain state

Parameters:

file : str

The name of the file

add_interval_recomb_rate(start, end, recomb_rate)[source]

Adds a specific recombination rate to a given interval. Note that the remaining pieces of the chromosome, unspecified, will remain at the basal rate

Parameters:

start : int

The start of the interval (inclusive)

end : int

The end of the interval (inclusive)

recomb_rate : float

The recombination rate in the interval as the probability of a crossover event in bp

add_mutation_type(nickname, h, dfe_type, mean_s=0.0, shape_alpha=None)[source]

Adds a mutation type to the simulation

Parameters:

nickname : str

A nickname for the mutation type (doesn’t affect the simulation file)

h : float

The dominance coefficient (0.5 would be codominant)

dfe_type : str

‘f’ for fixed, ‘e’ for exponential, and ‘g’ for gamma

mean_s : float

The mean selection coefficient for the distribution. Note that w = 1+hs

shape_alpha : float

The shape (alpha) parameter for the gamma distribution with mean s=s=(alpha)(beta)

add_output_option(generation, output_type, random_sample_pop=None, random_sample_size=None, mutation_track_type=None)[source]

Adds an output option the the simulation

Parameters:

generation : int

The generation that the output should take place

output_type : str

One of ‘A’ for the entire state of the population, ‘R’ for a random sample from the population, ‘F’ for list of all fixed mutations, or ‘T’ to track mutations of a particular type

random_sample_pop : float

The nickname of the population from which to take a random sample if using the ‘R’ option

random_sample_size : int

The size of the random sample from the population if using the ‘R’ option

mutation_track_type : str

The nickname of the mutation type to track if using the ‘T’ option

add_population(pop_nickname, generation_start, pop_size, source_pop=None)[source]

Adds a new population to the simulation

Parameters:

pop_nickname : str

A nickname for the new population

generation_start : int

The generation at which this population should appear (where the first generation is 1)

pop_size : int

The size of the population

source_pop : str

An optional specification of the nickname for the source population of this new population

add_predetermined_mutation(generation, mut_type, pos, pop_nickname, n_homo, n_hetero, partial=False, partial_freq=0.5)[source]

Adds a predetermined mutation to a population at a given time

Parameters:

generation : int

The generation at which the mutation should be added

mut_type : str

The nickname for the mutation type to be added

pos : int

The position of the added mutation

pop_nickname : str

The nickname of the population to get the mutation

n_homo : int

The number of homozygotes for the mutation to appear

n_hetero : int

The number of heterozygotes for the mutation to appear

partial : boolean

Should this be a partial sweep, where the selection coefficient of the mutation type applies until it reaches a certain frequency, at which point it drops to zero partial_freq If a partial sweep, the frequency at which s is set to zero

change_pop_migration(source_pop_nickname, target_pop_nickname, generation_start, rate)[source]

Changes the migration rate from a source to a target population

Parameters:

source_pop_nickname : str

The nickname for the source population

target_pop_nickname : str

The nickname for the target population

generation_start : int

The generation at which the migration rate should take effect

rate : float

Fraction of targeet population made up of migrants from source population each generation

change_pop_selfing(pop_nickname, generation_start, new_rate)[source]

Changes the selfing rate of a population

Parameters:

pop_nickname : str

The nickname of the population for which you want to adjust the selfing rate

generation_start : int

The generation at which the selfing rate should take effect

new_rate : float

The new selfing rate

change_pop_size(pop_nickname, generation_start, new_size)[source]

Changes the size of a population starting at a given generation

Parameters:

pop_nickname : str

The nickname of the population that you want to change the size of

generation_start : int

The generation at which the size change should start

new_size : int

The new size of the population

chrom_length = 10000000.0
element_types = {}
elements = []
gene_conversion_settings = []
generations = 1000000.0
initialization_file = None
mu = 1e-08
mutation_types = {'neutral': ('m1', 0.0, 'f', 0.0)}
output_settings = []
populations = {}
predetermined_mutations = []
recomb_rates = None
seed = None
set_gene_conversion(fraction, mean_stretch)[source]

Adds gene conversion to the simulation

Parameters:

fraction : float

The fraction of recombination events that result in gene conversion rather than crossing over

mean_stretch : int

The mean length of the conversion stretch, which # is drawn from a geometric distribution

set_random_seed(seed)[source]

Sets the seed for the random number generator

Parameters:

seed : int

A 32-bit integer

write_input_file(file, max_size=None)[source]

Writes the input file for the SLiM simulation

Parameters:

file : str

The name for the input file

max_size : str

The maximum number of bp alloewd in any given file. If this is specified, files will be output as file.1, file.2, etc. Writing will stop as soon as the total size of the segments are greater than or equal to the specified size

Module contents

Table Of Contents

This Page