Mutation & Genomic Element Types in shadie
¶
Mutation Types¶
Mutation types must be defined first in shadie
using the MutationType
class, created with the shadie.mtype()
function.
shadie.mtype()
requires a minimum of 3 arguments:
- dominance (float): dominance coefficient of the mutation for diploid
- distribution (str): distribution that the fitness effect will be selected from
- params ([float, list, tuple]): additional arguments that define the distribution - number of arguments will vary based on the distribution. If there is more than one argument, arguments must be passed in a list or tuple
shadie
defaults:
NEUT = MutationType(0.5, "f", 0.0) # neutral mutation
DEL = MutationType(0.1, "g", [-0.03, 0.2]) # deleterious
BEN = MutationType(0.8, "e", 0.1) # beneficial
import shadie
mut1 = shadie.mtype(0.5, 'n', [0.5, 0.1])
mut1.inspect();
Mutation Type
idx: m5
dominance coefficient: 0.5
distribution: n
distribution parameters: {'loc': 0.5, 'scale': 0.1}
distribution_mean: 0.5000
distribution_std: 0.1000
affects diploid fitness: True
affects haploid fitness: True
convert to substitution: False
# "f" is fixed fitness effect (no distribution), so takes a single argument = fitness effect
mut1 = shadie.mtype(0.5, "f", 0.1)
# "g" is a gamma distribution and takes 2 arguments: alpha, beta
mut2 = shadie.mtype(0.1, "g", [0.3, 0.2])
# "n" is a normal distribution and takes 2 arguments: mean, standard deviation
mut3 = shadie.mtype(0.5, "n", (0.05, 0.1))
# "e" is a exponential distribution and takes 2 arguments: rate
mut4 = shadie.mtype(0.5, "e", 0.1)
Note that the variable name you assign to your mutation type (e.g. "mut1") will only be recognized by your python environment, not internally by shadie. shadie will only recognize mutation types using the shadie
-assigned idx
when creating your genomic element types.
The repr lists the settings for the mutation type you just created:
mut4
MutationType(m9, 0.5, e, (0.1,),True, True)
Notice that your mutation type now has an idx
(in the format m#) - the first value listed in the repr. This is a unique id that shadie
uses to keep track of mutations. It may not start at m1
, as some default mutation types have already been defined by shadie
.
If you'd like more information about your mutation, you can use the inspect()
function to visualize your mutation distribution and see the parameters listed explicitly:
mut4.inspect();
Mutation Type
idx: m9
dominance coefficient: 0.5
distribution: e
distribution parameters: {'loc': 0.0, 'scale': 0.1}
distribution_mean: 0.1000
distribution_std: 0.1000
affects diploid fitness: True
affects haploid fitness: True
convert to substitution: False
Save your custom mutations to a list¶
You can create a MutationList
class object using the shadie.mlist()
function that contains all the mutations you would like to use in your simulation. This list may be useful for organizing sets of mutation types. This can be useful when creating genomic elements (see next section), running multiple iterations of a simulation with different fitness effects, etc. - however, you do not have to use them at all.
When creating mutation lists, you can use the default beneficial, deleterious, and neutral mutations in shadie or make your own custom mutations.
#list containing custom mutations
mylist = shadie.mlist(mut1, mut2, mut3, mut4)
mylist
<MutationList: ['m6', 'm7', 'm8', 'm9']>
mymixedlist = shadie.mlist(mut1, mut2, mut3, shadie.BEN, shadie.NEUT, shadie.DEL)
mymixedlist
<MutationList: ['m6', 'm7', 'm8', 'm3', 'm1', 'm2']>
#to see the scripts input into SLiM for each mutation type, you can access the `slim_dict` attribute
mylist.slim_dict
{'m6': "'m6', 0.5, 'f', 0.1", 'm7': "'m7', 0.1, 'g', 0.3, 0.2", 'm8': "'m8', 0.5, 'n', 0.05, 0.1", 'm9': "'m9', 0.5, 'e', 0.1"}
To inspect all the mutations you've created for your simulation, you can use .inspect()
function and iterate over the mutations to see the summary and the fitness effect distribution. You can also use .summary()
and .draw()
functions.
# iterate over elements in mlist
for mut in mylist:
mut.inspect()
Mutation Type idx: m6 dominance coefficient: 0.5 distribution: f distribution parameters: {'loc': 0.1, 'scale': 1e-09} distribution_mean: 0.1000 distribution_std: 0.0000 affects diploid fitness: True affects haploid fitness: True convert to substitution: False Mutation Type idx: m7 dominance coefficient: 0.1 distribution: g distribution parameters: {'a': 0.3, 'scale': 0.2} distribution_mean: 0.0600 distribution_std: 0.1095 affects diploid fitness: True affects haploid fitness: True convert to substitution: False Mutation Type idx: m8 dominance coefficient: 0.5 distribution: n distribution parameters: {'loc': 0.05, 'scale': 0.1} distribution_mean: 0.0500 distribution_std: 0.1000 affects diploid fitness: True affects haploid fitness: True convert to substitution: False Mutation Type idx: m9 dominance coefficient: 0.5 distribution: e distribution parameters: {'loc': 0.0, 'scale': 0.1} distribution_mean: 0.1000 distribution_std: 0.1000 affects diploid fitness: True affects haploid fitness: True convert to substitution: False
Genomic Element Types¶
Each ElementType
class object object describes a region of chromosome, and is created using the shadie.etype()
function. It is helpful to think of these regions as "non-coding", "exon", "intron", etc.
shadie.etype()
requires 2 lists of equal length:
- A list of mutations that can occur in that kind of region (e.g. only neutral mutations can occur in non-coding regions)
- A list of relative frequencies
shadie
defaults:
EXON = shadie.etype([NEUT, DEL, BEN], (2, 8, 0.1)) # exon
INTRON = shadie.etype([NEUT,DEL], (9, 1)) # intron
NONCOD = shadie.etype(NEUT, 1) # non-coding
#let's try making our own exon based on the shadie default, but with different
#frequencies of neutral, deleterious, and synonymous mutations:
my_exon = shadie.etype([shadie.NEUT, shadie.DEL, shadie.BEN], (5,1,2))
#as with the mutation types, you can visulize the distribution of fitness
#effects that will occur in this genomic element using `.draw()`
my_exon.draw();
#let's compare the distributions between our custom exon and the shadie default
my_exon.draw();
shadie.EXON.draw();
#remember how a mutation list can be useful for organization?
#You can call specific idx's from your list:
e1 = shadie.etype(
mutations=[mylist[0], mylist[1]],
frequencies=[1, 5]
)
e1.draw();
#or even use the whole list
#(i.e. you could define a separate list for each genomic element type)
e2 = shadie.etype(
mutations=mylist,
frequencies=[1, 2, 50, 50]
)
e2.draw();