}, { 'name':'endGen', 'default':5, 'type':[int, long], 'label':'Ending Generation', 'description':'Length of evolution', 'validator':simuOpt.valueGT(0) }, { 'name':'malleleFreq', 'default':0.4, 'type':[float, long], 'label':'Male Allele Frequency', 'description':'Initial allele frequency in males,', 'validator':simuOpt.valueBetween(0, 1) }, { 'name':'falleleFreq', 'default':0.7, 'type':[float, long], 'label':'Female Allele Frequency', 'description':'Initial allele frequency in females.', 'validator':simuOpt.valueBetween(0, 1) }, ] # get all parameters par = simuOpt.Params(options, __doc__)
it determines the complexity of the disease. A single number is allowed and implies a simple disease with one disease locus.''', 'type': [types.TupleType, types.ListType], 'validator': simuOpt.valueListOf(simuOpt.valueGT(0)) }, { 'name': 'DSLLoc', 'default': [.5, .5, .5], 'label': 'DSL location between markers', 'description': '''A list of loci location between two markers. Since all disease loci will be *between* equal spaced markers, the location should be between 0 and 1. A single value is acceptable as the location of all DSL.''', 'type': [types.TupleType, types.ListType], 'validator': simuOpt.valueListOf(simuOpt.valueBetween(0, 1)) }, # # { 'separator': 'Demographic model:' }, { 'name': 'initSize', 'default': 10000, 'label': 'Initial population size', 'type': [int, long], 'description': '''Initial population size. This size will be maintained till the end of burnin stage''', 'validator': simuOpt.valueGT(0) },
'type': [int, long], 'validator': simuOpt.valueGT(0), }, { 'name': 'numOfSubPops', 'default': 5, 'type': [int, long], 'label': 'Number of Subpopulations', 'validator': simuOpt.valueGT(0) }, { 'name': 'm', 'default': 0.05, 'label': 'Migration Rate', 'type': [float], 'validator': simuOpt.valueBetween(0., 1.), }, { 'name': 'generations', 'default': 200, 'label': 'Generations to evolve', 'description': 'Length of evolution', 'type': [int, long], 'validator': simuOpt.valueGT(0) }, ] def simuMigration(subPopSize, numOfSubPops, m, generations): '''Simulate the change of allele frequencies among subpopulations as a result of migration.''' # diploid population, one chromosome with 1 locus
from Bio import SeqIO dirW = os.environ["work"] dirI = os.path.join(dirW, "Scripts/in") dirO = os.path.join(dirW, "Scripts/out") options = [ { 'arg': 'r:', 'longarg': 'n_pop=', 'default': 6, 'useDefault': True, 'label': 'Sub-populations', 'allowedTypes': [types.IntType, types.LongType], 'description': '', 'validate': simuOpt.valueBetween(0, 7) }, { 'longarg': 'init_freq=', 'default': [0.2] * 3 + [0.8] * 3, 'label': 'Initial allele-freq for Sub-pop', 'allowedTypes': [types.ListType, types.TupleType], 'description': '', 'validate': simuOpt.valueListOf(simuOpt.valueBetween(0, 1)) }, { 'longarg': 'n_ind=', 'default': 100, 'label': 'Sub-pop Size', 'allowedTypes': [types.IntType, types.LongType], 'description': '',
'name': 'markerList', 'default': 'hh550v3_snptable.txt', 'label': 'Marker list file', 'description': '''A file with a list of marker names. If there are more than one fields at a line, the rest of them are ignored.''', 'allowedTypes': [StringType], 'validate': simuOpt.valueOr(simuOpt.valueEqual(''), simuOpt.valueValidFile()), }, { 'name': 'chroms', 'default': [2,5,10], 'label': 'Chromosomes to use', 'description': 'A list of chromosomes (1-22) to use.', 'allowedTypes': [TupleType, ListType], 'chooseFrom':range(1,23), 'validate': simuOpt.valueListOf(simuOpt.valueBetween(1, 22)), }, { 'name': 'numMarkers', 'default': [2000,2000,2000], 'label': 'Number of markers to use', 'description': '''Number of markers to use for each chromosome. This parameter should be ignored if it is unspecified or is set to zero for some chromosomes. ''', 'allowedTypes': [TupleType, ListType], 'validate': simuOpt.valueOr(simuOpt.valueGT(0), simuOpt.valueListOf(simuOpt.valueGE(0))) }, { 'name': 'startPos', 'default': [25000000, 25000000, 40000000],
'label': 'File to save expanded population', 'default': 'MAF_0.05_1.pop', 'useDefault': True, 'description': '''File to save the expanded population.''', 'allowedTypes': [types.StringType], }, {'separator': 'Mutation, recombination, etc'}, { 'longarg': 'mutaRate=', 'default': 1e-8, 'useDefault': True, 'label': 'Mutation rate', 'allowedTypes': [types.IntType, types.FloatType], 'description': '''Mutation rate at all markers. This value will be scaled by the scaling parameter.''', 'validate': simuOpt.valueBetween(0,1), }, {'longarg': 'recIntensity=', 'default': 1e-8, 'useDefault': True, 'allowedTypes': [types.FloatType, types.IntType, types.LongType], 'label': 'Recombination intensity', 'description': '''Recombination intensity. The actual recombination rate between two adjacent loci will be this intensity times loci distance in basepair, and times the scaling parameter. For example, if two loci are 1M bp apart, the recombination rate will be 1e6 x 1e-8 (default value), namely 1e-2 times scaling parameter. (This is roughly 0.01 per cM). If a variable 'geneticMap' that stores the genetic map of each locus exists in this population, the genetic map will be used.''', 'validate': simuOpt.valueGE(0), },
}, { 'name':'Taftersplit', 'default':200, 'type':[int, long], 'label':'Number of Generations to simulate after the split', 'description':'Number of Generations to simulate after the split', 'validator':simuOpt.valueGT(0) }, { 'name':'r2loci', 'default':0.01, 'label':'Recombination Rate between selected and neutral loci', 'type':[float], 'description':'Recombination rate', 'validator':simuOpt.valueBetween(0., 1.), }, { 'name':'numLoci', 'default':2, 'label':'Number of loci', 'type':[int], 'description':'Number of loci', 'validator':simuOpt.valueGT(0), }, { 'name':'K_sel', 'default':10, 'label':'Number of allelic states at selected locus', 'type':[int, long], 'validator':simuOpt.valueGT(0),
types Additive and Multiplicative by using alternative definitions of genotype relative risks and minimal detectable relative risk. | Dominant: r_AB=r_AA, Grr = r_AA / r_BB | Recessive: r_AB=r_BB, Grr = r_AA / r_BB | Multiplicative: r_AB=sqrt(r_AA * r_BB), Grr = r_AB / r_BB | Additive: r_AB=(r_AA + r_BB)/2, Grr = r_AB / r_BB | Additive_AA: r_AB=(r_AA + r_BB)/2, Grr = r_AA / r_BB, Minimal Detectable Relative Risk = (p*p*Grr+pq(Grr+1))/(p*p+2pq) | LogAdditive: r_AB=sqrt(r_AA * r_BB), Grr = r_AA / r_BB ''', }, { 'longarg': 'K=', 'default': 0.05, 'label': 'Disease prevalence', 'allowedTypes': [types.ListType, types.TupleType], 'validate': simuOpt.valueListOf(simuOpt.valueBetween(0., 1)), }, { 'longarg': 'p=', 'default': 0.15, 'label': 'Disease allele frequency', 'allowedTypes': [types.ListType, types.TupleType], 'validate': simuOpt.valueListOf(simuOpt.valueBetween(0., 1)), }, { 'separator': 'Marker locus information' }, { 'longarg': 'x=', 'default':
'description': '''Maximum allele state at each DSL. For stepwise model, 255 is more than enough. For k-allele model, you may want to have more than 255 alleles especially when expected effective allele numbers are big. Note that using large maxAllele to mimic infinite allele model will slow down the program significantly. NOTE: very large maxAllele will significantly slow down the simulation due to the creation of large array as population variable.''', 'validator': simuOpt.valueGT(1), }, {'name': 'mutaRate', 'default': [0.0001], 'label': 'Mutation rate(s)', 'type': [types.ListType, types.TupleType], 'description': '''Mutation rate for all DSL. Can be different for each DSL.''', 'validator': simuOpt.valueListOf( simuOpt.valueBetween(0,1)) }, {'name': 'initSize', 'default': 10000, 'label': 'Initial population size', 'type': [int, long], 'description': '''Initial population size. This size will be maintained till the end of burnin stage''', 'validator': simuOpt.valueGT(0) }, {'name': 'finalSize', 'default': 1000000, 'label': 'Final population size', 'type': [int, long], 'description': 'Ending population size (after expansion.', 'validator': simuOpt.valueGT(0)
def path_maker(outer,*args): """Takes multiple levels and creates a directory hierarchy. outer highest directory name arglist list of lower directory names.""" dirpath = "%s/%s" %(outer,"/".join(args)) return dirpath replicator_options = [ {'separator':'Minor Allele Frequency'}, {'name':'MAF_range_hi', 'default':0.05, 'label':'Maximum MAF', 'type':'number', 'validate':simuOpt.valueBetween(0,1) }, {'name':'MAF_range_lo', 'default':0.05, 'label':'Minimum MAF', 'type':'number', 'validate':simuOpt.valueBetween(0,1) }, {'name':'MAF_num_steps', 'default':1, 'label':'Number of MAF levels', 'type':int, 'validate':simuOpt.valueGE(1) }, {'name':'MAF_replicates', 'default':1,
'validator': simuOpt.valueGT(0) }, {'name': 'G1', 'default': 1000, 'label': 'Length of expansion stage', 'type': 'integer', 'description': 'Number of geneartions of the sim.population expansion stage', 'validator': simuOpt.valueGT(0) }, {'name': 'spec', 'default': [0.9] + [0.02]*5, 'label': 'Initial allelic spectrum', 'type': 'numbers', 'description': '''Initial allelic spectrum, should be a list of allele frequencies, for allele 0, 1, 2, ... respectively.''', 'validator': simuOpt.valueListOf(simuOpt.valueBetween(0, 1)), }, {'name': 's', 'default': 0.01, 'label': 'Selection pressure', 'type': 'number', 'description': '''Selection coefficient for homozygtes (aa) genotype. A recessive selection model is used so the fitness values of genotypes AA, Aa and aa are 1, 1 and 1-s respectively.''', 'validator': simuOpt.valueGT(-1), }, {'name': 'mu', 'default': 1e-4, 'label': 'Mutation rate', 'type': 'number', 'description': 'Mutation rate of a k-allele mutation model',