gpmap.simulate¶
gpmap.simulate.base module¶
-
class
gpmap.simulate.base.BaseSimulation(wildtype, mutations, *args, **kwargs)¶ Bases:
gpmap.gpm.GenotypePhenotypeMapBuild a simulated GenotypePhenotypeMap. Generates random phenotypes.
-
build()¶
-
classmethod
from_length(length, alphabet_size=2, *args, **kwargs)¶ Create a simulate genotype-phenotype map from a given genotype length.
Parameters: - length (int) – length of genotypes
- alphabet_size (int (optional)) – alphabet size
Returns: self
Return type: GenotypePhenotypeSimulation
-
set_stdeviations(sigma)¶ Add standard deviations to the simulated phenotypes, which can then be used for sampling error in the genotype-phenotype map.
Parameters: sigma (float or array-like) – Adds standard deviations to the phenotypes. If float, all phenotypes are given the same stdeviations. Else, array must be same length as phenotypes and will be assigned to each phenotype.
-
-
gpmap.simulate.base.random_mutation_set(length, alphabet_size=2, type='AA')¶ Generate a random mutations dictionary for simulations.
Parameters: - length (length of genotypes) –
- alphabet_size (int or list) – alphabet size at each site. if list is given, will make site i have size alphab_size[i].
- type ('AA' or "DNA') – Use amino acid alphabet or DNA alphabet
gpmap.simulate.fuji module¶
-
class
gpmap.simulate.fuji.MountFujiSimulation(wildtype, mutations, field_strength=1, roughness_width=None, roughness_dist='normal', *args, **kwargs)¶ Bases:
gpmap.simulate.base.BaseSimulationConstructs a genotype-phenotype map from a Mount Fuji model. [1]_
A Mount Fuji sets a “global” fitness peak (max) on a single genotype in the space. The fitness goes down as a function of hamming distance away from this genotype, called a “fitness field”. The strength (or scale) of this field is linear and depends on the parameters field_strength. Roughness can be added to the Mount Fuji model using a random roughness parameter. This assigns a random
\[f(g) = \nu (g) + c \cdot d(g_0, g)\]where $nu$ is the roughness parameter, $c$ is the field strength, and $d$ is the hamming distance between genotype $g$ and the reference genotype.
Parameters: - wildtype (str) – reference genotype to put the
- mutations (dict) – mutations alphabet for each site
- field_strength (float) – field strength
- roughness_width (float) – Width of roughness distribution
- roughness_dist (str, 'normal') – Distribution used to create noise around phenotypes.
References
- _ [1] Szendro, Ivan G., et al. “Quantitative analyses of empirical fitness
- landscapes.” Journal of Statistical Mechanics: Theory and Experiment 2013.01 (2013): P01005.
-
build()¶ Construct phenotypes using a rough Mount Fuji model.
-
field_strength¶
-
classmethod
from_length(length, field_strength=1, roughness_width=None, roughness_dist='normal', *args, **kwargs)¶ Constructs a genotype-phenotype map from a Mount Fuji model. [1]_
A Mount Fuji sets a “global” fitness peak (max) on a single genotype in the space. The fitness goes down as a function of hamming distance away from this genotype, called a “fitness field”. The strength (or scale) of this field is linear and depends on the parameters field_strength. Roughness can be added to the Mount Fuji model using a random roughness parameter. This assigns a random
\[f(g) = \nu (g) + c \cdot d(g_0, g)\]where $nu$ is the roughness parameter, $c$ is the field strength, and $d$ is the hamming distance between genotype $g$ and the reference genotype.
Parameters: - length (int) – length of the genotypes.
- field_strength (float) – field strength
- roughness_width (float) – Width of roughness distribution
- roughness_dist (str, 'normal') – Distribution used to create noise around phenotypes.
-
hamming¶ Hamming distance from reference
-
roughess_dist¶ Roughness distribution.
-
roughness¶ Array of roughness values for all genotypes
-
roughness_dist¶ Roughness distribution.
-
roughness_width¶
-
scale¶ Mt. Fuji phenotypes without noise.
gpmap.simulate.hoc module¶
-
class
gpmap.simulate.hoc.HouseOfCardsSimulation(wildtype, mutations, k_range=(0, 1), *args, **kwargs)¶ Bases:
gpmap.simulate.nk.NKSimulationConstruct a ‘House of Cards’ fitness landscape.
gpmap.simulate.nk module¶
-
class
gpmap.simulate.nk.NKSimulation(wildtype, mutations, K, k_range=(0, 1), *args, **kwargs)¶ Bases:
gpmap.simulate.base.BaseSimulationGenerate genotype-phenotype map from NK fitness model. Creates a table with binary sub-sequences that determine the order of epistasis in the model.
The NK fitness landscape is created using a table with binary, length-K, sub-sequences mapped to random values. All genotypes are binary with length N. The fitness of a genotype is constructed by summing the values of all sub-sequences that make up the genotype using a sliding window across the full genotype.
For example, imagine an NK simulation with N=5 and K=2. To construct the fitness for the 01011 genotype, select the following sub-sequences from an NK table “01”, “10”, “01”, “11”, “10”. Sum their values together.
-
nk_table¶ table with binary sub-sequences as keys which are used to construct phenotypes following an NK routine
Type: dict
-
keys¶ array of keys in NK table.
Type: array
-
values¶ array of values in the NK table.
Type: array
-
build()¶ Build phenotypes from NK table.
-
keys NK table keys.
-
nk_table NK table mapping binary sequence to value.
-
set_order(K)¶ Set the order (K) of the NK model.
-
set_random_values(k_range=(0, 1))¶ Set the values of the NK table by drawing from a uniform distribution between the given k_range.
-
set_table_values(values)¶ Set the values of the NK table from a list/array of values.
-
values NK table values
-