(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 9.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 55916, 1411] NotebookOptionsPosition[ 53969, 1341] NotebookOutlinePosition[ 54430, 1361] CellTagsIndexPosition[ 54387, 1358] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ "Supplementary ", StyleBox["Mathematica", FontSlant->"Italic"], " File to accompany Dey, Proulx, and Teot\[OAcute]nio, PLOS Biology 2016" }], "Title", CellChangeTimes->{{3.661540159195071*^9, 3.6615401947528353`*^9}, { 3.6616094899835577`*^9, 3.661609504139064*^9}, {3.661614171095907*^9, 3.6616141723572206`*^9}}], Cell[CellGroupData[{ Cell["\<\ Code for fixation probabilities of alternate types of maternal effects (For \ figure 5A)\ \>", "Chapter", CellChangeTimes->{{3.661540205634605*^9, 3.661540241191059*^9}, { 3.661608642403595*^9, 3.661608642570116*^9}, {3.661610247365903*^9, 3.661610260626287*^9}}], Cell[CellGroupData[{ Cell["Fitness funtions for DME and RME", "Subsubsection", CellChangeTimes->{{3.661429453433366*^9, 3.6614294609375677`*^9}}], Cell["\<\ The geometric mean selection coefficient for DME when the DME strategy \ produces the anoxia phenotype that has the log relative fitness effects Lw1 \ and Lw2 under anoxia and normoxia. Note that when the normoxia phenotype is \ produced it has log relative fitness of 0 (because it has relative fitness of \ 1). The effective selection coefficient used in the Wright-Fisher Model is \ found by subtracing 1. \ \>", "Text", CellChangeTimes->{{3.661429850337277*^9, 3.6614299227282667`*^9}, { 3.661429957606719*^9, 3.661430042268972*^9}, {3.6614303042172337`*^9, 3.661430331232185*^9}, {3.6614803772761993`*^9, 3.6614803855290213`*^9}}], Cell[BoxData[ RowBox[{"sDME", ":=", RowBox[{ RowBox[{"Exp", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", "\[Rho]"}], ")"}], " ", RowBox[{"(", RowBox[{ RowBox[{"Lw1", "/", "2"}], "+", RowBox[{"0", "/", "2"}]}], ")"}]}], "+", RowBox[{ RowBox[{"(", "\[Rho]", ")"}], RowBox[{"(", RowBox[{ RowBox[{"Lw2", "/", "2"}], "+", RowBox[{"0", "/", "2"}]}], ")"}]}]}], "]"}], "-", "1"}]}]], "Input", CellChangeTimes->{{3.6614294838963118`*^9, 3.6614295496360407`*^9}, { 3.661429753580055*^9, 3.66142979026088*^9}, {3.661608754805995*^9, 3.661608761437869*^9}}], Cell["\<\ For RME we assume that the optimal frequency of producing the two phenotypes \ is used in the maternal effect strategy. This is caclulated by solving for \ the point where the fitness derivative is zero (and checking that the second \ derivative is negative). We do this for the case where the two environmetns \ are equally frequent (as in the experiments)\ \>", "Text", CellChangeTimes->{{3.6614300576298237`*^9, 3.661430138428273*^9}, { 3.661430621302474*^9, 3.6614306361411123`*^9}}], Cell[BoxData[ RowBox[{"optimumRMEfreqs", ":=", RowBox[{"-", FractionBox[ RowBox[{ RowBox[{"Exp", "[", "Lw1", "]"}], "+", RowBox[{"Exp", "[", "Lw2", "]"}], "-", RowBox[{"2", " ", RowBox[{"Exp", "[", "Lw1", "]"}], " ", RowBox[{"Exp", "[", "Lw2", "]"}]}]}], RowBox[{"2", " ", RowBox[{"(", RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{"Exp", "[", "Lw1", "]"}]}], ")"}], " ", RowBox[{"(", RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{"Exp", "[", "Lw2", "]"}]}], ")"}]}]], " ", RowBox[{"(*", RowBox[{ "This", " ", "is", " ", "the", " ", "probability", " ", "of", " ", "offspring", " ", "having", " ", "the", " ", "anoxia", " ", "adapted", " ", "phenotype"}], "*)"}]}]}]], "Input", CellChangeTimes->{{3.638098321643491*^9, 3.638098353459807*^9}, { 3.661430192202958*^9, 3.661430237248734*^9}, {3.661430455152278*^9, 3.661430466374207*^9}}], Cell["\<\ Now the geometric mean fitness of the RME strategy can be calculated and the \ effective selection coefficient used in the Wright-Fisher Model is found by \ subtracing 1.\ \>", "Text", CellChangeTimes->{{3.661430472941987*^9, 3.6614304735497837`*^9}, { 3.6614305420608788`*^9, 3.66143058779465*^9}, {3.661480255923479*^9, 3.661480300935314*^9}, {3.661480346009638*^9, 3.661480357138034*^9}}], Cell[BoxData[ RowBox[{"sRME", ":=", RowBox[{ RowBox[{"Exp", "[", RowBox[{ RowBox[{ RowBox[{"1", "/", "2"}], RowBox[{"Log", "[", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", "optimumRMEfreqs"}], ")"}], "*", RowBox[{"Exp", "[", "Lw1", "]"}]}], "+", RowBox[{ RowBox[{"(", "optimumRMEfreqs", ")"}], " ", "1"}]}], "]"}]}], "+", RowBox[{ RowBox[{"1", "/", "2"}], " ", RowBox[{"Log", "[", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", "optimumRMEfreqs"}], ")"}], "*", RowBox[{"Exp", "[", "Lw2", "]"}]}], "+", RowBox[{ RowBox[{"(", "optimumRMEfreqs", ")"}], " ", "1"}]}], "]"}]}]}], "]"}], "-", "1"}]}]], "Input", CellChangeTimes->{{3.642877848063899*^9, 3.642877881219833*^9}, { 3.642877994901966*^9, 3.6428780204187*^9}, {3.6614305479771*^9, 3.661430552617477*^9}, {3.6614306798651333`*^9, 3.661430692133184*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Simulate fixation probabilities", "Subsubsection", CellChangeTimes->{{3.661430771729463*^9, 3.661430792280395*^9}}], Cell["\<\ We draw fitness parameters from a distribution and then calculate the \ fixation probabilities of DME and RME.\ \>", "Text", CellChangeTimes->{{3.661430794624236*^9, 3.6614308201750298`*^9}}], Cell["\<\ Some parameters are defined to specify the distribution of fitness effects \ and the population size.\ \>", "Text", CellChangeTimes->{{3.661430824111164*^9, 3.661430844267913*^9}, { 3.661480417266444*^9, 3.661480437717772*^9}, {3.6614805030753508`*^9, 3.661480512129014*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"\[Gamma]", "=", "2.0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"pinit", "=", ".01"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Ne", "=", "1000"}], ";"}], " "}]}], "Input", CellChangeTimes->{{3.642349914444407*^9, 3.642349934173126*^9}, 3.642352283533616*^9, {3.642352470374091*^9, 3.6423524910678387`*^9}, { 3.642352560614122*^9, 3.642352561892784*^9}, {3.642352618056858*^9, 3.642352618220278*^9}, {3.6423530013939943`*^9, 3.6423530115114803`*^9}, { 3.64235306318792*^9, 3.6423530975183687`*^9}, {3.642353240011653*^9, 3.642353240593378*^9}, {3.642354569883748*^9, 3.64235457029806*^9}, { 3.64235462220153*^9, 3.6423546224903097`*^9}, {3.642354665395756*^9, 3.642354665523892*^9}, {3.642354712752977*^9, 3.642354712950945*^9}, 3.642853421377645*^9, 3.642853463694593*^9, {3.64285442974091*^9, 3.6428544299914827`*^9}, {3.6428613220686283`*^9, 3.6428613222300577`*^9}, {3.642869070190692*^9, 3.642869164298304*^9}, { 3.642869232930451*^9, 3.642869256860689*^9}, {3.642869368899428*^9, 3.642869369138221*^9}, 3.642875501458926*^9, {3.661480448619567*^9, 3.661480448945896*^9}, {3.661480481277128*^9, 3.661480481402231*^9}, { 3.661608696569971*^9, 3.661608696801269*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"Clear", "[", "\[Rho]", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"benlevelsBoth", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", " ", "0", ",", "0"}], "}"}], ",", " ", RowBox[{"{", RowBox[{"i", ",", " ", "0.5", ",", "1", ",", " ", ".01"}], "}"}]}], "]"}]}], ";", RowBox[{"(*", RowBox[{ "This", " ", "calculates", " ", "the", " ", "fixation", " ", "probability", " ", "of", " ", "RME", " ", "and", " ", "DME", " ", "when", " ", "both", " ", "are", " ", "initially", " ", "present"}], "*)"}], "\n", RowBox[{"Table", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Lw1", "=", "1"}], ";", RowBox[{"Lw2", "=", "1"}], ";", " ", RowBox[{"(*", RowBox[{ "This", " ", "is", " ", "just", " ", "to", " ", "allow", " ", "entry", " ", "into", " ", "the", " ", "while", " ", "loop"}], "*)"}], "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{ RowBox[{"Lw1", "+", "Lw2"}], " ", ">", " ", "0"}], RowBox[{"(*", RowBox[{ RowBox[{ "We", " ", "assume", " ", "that", " ", "the", " ", "new", " ", "anoxia", " ", "adapted", " ", "phenotype", " ", "has", " ", "lower", " ", "geometric", " ", "mean", " ", "fitness", " ", "than", " ", "the", " ", "original"}], ",", " ", RowBox[{ "or", " ", "else", " ", "it", " ", "would", " ", "simply", " ", "replace", " ", "the", " ", RowBox[{"original", ".", " ", "The"}], " ", "new", " ", "phenotype", " ", "must", " ", "show", " ", "a", " ", "decrease", " ", "in", " ", "performance", " ", "under", " ", "normoxia", " ", "and", " ", "an", " ", "increase", " ", "under", " ", RowBox[{"anoxia", "."}]}]}], "*)"}], ",", " ", "\[IndentingNewLine]", RowBox[{ RowBox[{"Lw1", " ", "=", " ", RowBox[{"-", RowBox[{"Random", "[", RowBox[{"ExponentialDistribution", "[", "\[Gamma]", "]"}], "]"}]}]}], ";", "\n", " ", RowBox[{"Lw2", " ", "=", " ", RowBox[{"Random", "[", RowBox[{"ExponentialDistribution", "[", "\[Gamma]", "]"}], "]"}]}]}]}], "]"}], ";", "\[IndentingNewLine]", " ", "\n", "\[IndentingNewLine]", RowBox[{"sRMEsim", " ", "=", " ", RowBox[{"If", "[", RowBox[{ RowBox[{"0", " ", "<", " ", "optimumRMEfreqs", " ", "<", " ", "1"}], ",", " ", "sRME", ",", " ", "0"}], "]"}]}], ";", RowBox[{"(*", RowBox[{ "sRME", " ", "only", " ", "makes", " ", "sense", " ", "if", " ", "the", " ", "frequency", " ", "of", " ", "the", " ", "two", " ", "phenotypes", " ", "is", " ", "between", " ", "0", " ", "and", " ", "1"}], "*)"}], "\[IndentingNewLine]", " ", RowBox[{"sDMEsim", " ", "=", " ", RowBox[{"(", RowBox[{"sDME", " ", "/.", " ", RowBox[{"\[Rho]", " ", "->", " ", "i"}]}], ")"}]}], ";", " ", RowBox[{"(*", RowBox[{"just", " ", "changed", " ", "this"}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"benlevelsBoth", " ", "+=", " ", RowBox[{"Table", "[", RowBox[{"(*", RowBox[{ "First", " ", "determine", " ", "if", " ", "either", " ", "strategy", " ", "has", " ", "positive", " ", "selection", " ", "coefficient"}], "*)"}], "\n", " ", "\n", " ", RowBox[{ RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"sRMEsim", " ", "==", " ", "0"}], ",", " ", RowBox[{"pfixRME", " ", "=", " ", "0"}], ",", " ", RowBox[{"pfixRME", " ", "=", " ", RowBox[{ RowBox[{"(", RowBox[{"1", " ", "-", " ", RowBox[{"Exp", "[", RowBox[{ RowBox[{"-", "4"}], " ", "sRMEsim", " ", "pinit", " ", "Ne"}], "]"}]}], ")"}], " ", "/", RowBox[{"(", RowBox[{"1", " ", "-", " ", RowBox[{"Exp", "[", RowBox[{ RowBox[{"-", "4"}], " ", "Ne", " ", "sRMEsim"}], "]"}]}], ")"}]}]}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"sDMEsim", "<=", "0"}], ",", RowBox[{"pfixDME", "=", "0"}], ",", "\[IndentingNewLine]", RowBox[{"pfixDME", " ", "=", " ", RowBox[{ RowBox[{"(", RowBox[{"1", " ", "-", " ", RowBox[{"Exp", "[", RowBox[{ RowBox[{"-", "4"}], " ", "sDMEsim", " ", "pinit", " ", "Ne"}], "]"}]}], ")"}], " ", "/", RowBox[{"(", RowBox[{"1", " ", "-", " ", RowBox[{"Exp", "[", RowBox[{ RowBox[{"-", "4"}], " ", "Ne", " ", "sDMEsim"}], "]"}]}], ")"}]}]}]}], "]"}], ";", "\n", " ", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"pfixDME", ">", "0"}], "&&", RowBox[{"pfixRME", ">", "0"}]}], ",", " ", RowBox[{"(*", RowBox[{ RowBox[{"In", " ", "this", " ", "case"}], ",", " ", RowBox[{"both", " ", "could", " ", RowBox[{"fix", ".", " ", "Assume"}], " ", "that", " ", "if", " ", "both", " ", "are", " ", "not", " ", "lost", " ", "when", " ", "rare"}], ",", " ", RowBox[{ "the", " ", "more", " ", "fit", " ", "one", " ", "eventually", " ", RowBox[{"wins", ".", " ", "less"}], " ", "fit", " ", "only", " ", "fixes", " ", "if", " ", "more", " ", "fit", " ", "does", " ", "not", " ", RowBox[{"fix", "."}]}]}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"pfixDME", ">", "pfixRME"}], ",", RowBox[{"pfixRME", "=", RowBox[{"pfixRME", "*", RowBox[{"(", RowBox[{"1", "-", "pfixDME"}], ")"}]}]}]}], "]"}], " ", RowBox[{"(*", RowBox[{ RowBox[{ RowBox[{"Don", "'"}], "t", " ", "need", " ", "to", " ", "change", " ", "pfixDME"}], ",", " ", RowBox[{ "but", " ", "do", " ", "need", " ", "to", " ", "reduce", " ", "pfixRME"}]}], "*)"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"pfixDME", "<", "pfixRME"}], ",", RowBox[{"pfixDME", "=", RowBox[{"pfixDME", "*", RowBox[{"(", RowBox[{"1", "-", "pfixRME"}], ")"}]}]}]}], "]"}], " ", RowBox[{"(*", RowBox[{ RowBox[{ RowBox[{"don", "'"}], "t", " ", "need", " ", "to", " ", "change", " ", "pfixRME"}], ",", " ", RowBox[{ "but", " ", "do", " ", "need", " ", "to", " ", "reduce", " ", "pfixDME"}]}], " ", "*)"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"pfixDME", "==", "pfixRME"}], ",", RowBox[{ RowBox[{"pfixDME", "=", RowBox[{"pfixDME", "/", "2"}]}], ";", RowBox[{"pfixRME", "=", RowBox[{"pfixRME", "/", "2"}]}]}]}], "]"}], ";"}]}], RowBox[{"(*", RowBox[{ RowBox[{ RowBox[{ "If", " ", "they", " ", "happened", " ", "to", " ", "be", " ", "exactly", " ", "equal", " ", "then", " ", "I", " ", "would", " ", "have", " ", "to", " ", "reduce", " ", "each", " ", "by", " ", RowBox[{"1", "/", "2"}]}], "..."}], " ", "not", " ", "likely"}], " ", "*)"}], "\[IndentingNewLine]", "]"}], ";", "\n", "\[IndentingNewLine]", "\[IndentingNewLine]", " ", RowBox[{"{", RowBox[{"0", ",", " ", RowBox[{"Max", "[", RowBox[{"0", ",", " ", RowBox[{"pfixDME", "/", "10000"}]}], "]"}], ",", RowBox[{"Max", "[", RowBox[{"0", ",", " ", RowBox[{"pfixRME", "/", "10000"}]}], "]"}]}], "}"}]}], ",", " ", RowBox[{"{", RowBox[{"i", ",", " ", ".5", ",", "1", ",", " ", ".01"}], "}"}]}], "]"}]}], ";"}], "\n", " ", ",", " ", RowBox[{"{", "10000", "}"}]}], "]"}], ";"}]}], "Input", CellChangeTimes->{{3.6376735162667933`*^9, 3.637673650848969*^9}, { 3.6376737262857447`*^9, 3.637673911537498*^9}, {3.6376739746370163`*^9, 3.637673974943046*^9}, {3.637674382939499*^9, 3.637674449219997*^9}, 3.6376744838959513`*^9, {3.637674704610207*^9, 3.637674739871675*^9}, 3.637674772639016*^9, 3.63767494663452*^9, 3.6376749783500547`*^9, 3.637675013155835*^9, {3.637675069717936*^9, 3.637675125027495*^9}, { 3.637675253834323*^9, 3.6376752728101*^9}, {3.6376759806715813`*^9, 3.637675983131956*^9}, {3.637676218002586*^9, 3.637676309810032*^9}, { 3.637676436694317*^9, 3.637676533845235*^9}, {3.637676893410798*^9, 3.637676901993593*^9}, {3.6376774984461*^9, 3.6376775039880867`*^9}, { 3.637677557354743*^9, 3.637677566825039*^9}, {3.6376776757749643`*^9, 3.637677680557076*^9}, {3.637677714107732*^9, 3.63767771579303*^9}, { 3.637678080762199*^9, 3.637678081742033*^9}, {3.637678987793537*^9, 3.6376789892832737`*^9}, {3.6381007709642963`*^9, 3.63810082479702*^9}, { 3.638100855476697*^9, 3.638100881870234*^9}, {3.638101209979844*^9, 3.638101298943795*^9}, 3.638101424604727*^9, {3.63810150110001*^9, 3.638101509155219*^9}, {3.6381021391502542`*^9, 3.6381021407904654`*^9}, { 3.638102711271727*^9, 3.638102723494348*^9}, {3.6381028637341967`*^9, 3.6381028723993187`*^9}, {3.638102930411385*^9, 3.6381034808083363`*^9}, { 3.638103748473928*^9, 3.6381037546437607`*^9}, {3.638103800457563*^9, 3.6381038215522823`*^9}, {3.638103884521158*^9, 3.638103885417403*^9}, { 3.638104594958314*^9, 3.638104620258265*^9}, 3.638104852411559*^9, { 3.6381048845022783`*^9, 3.6381048854204197`*^9}, {3.642794209299748*^9, 3.6427942128633757`*^9}, {3.6427944950816193`*^9, 3.642794496857707*^9}, { 3.642794571499661*^9, 3.642794620408187*^9}, {3.642794857817462*^9, 3.642794859175878*^9}, {3.642795029961443*^9, 3.6427951109521627`*^9}, { 3.6427951804104548`*^9, 3.64279525445607*^9}, 3.64279534079704*^9, { 3.642795732781892*^9, 3.642795803155734*^9}, 3.642796216858927*^9, 3.6427965061723623`*^9, {3.642796710894393*^9, 3.642796712014577*^9}, { 3.642796755853763*^9, 3.6427967720874777`*^9}, {3.642872750759095*^9, 3.6428727598911457`*^9}, {3.642874164877926*^9, 3.642874171310911*^9}, { 3.642874626757972*^9, 3.642874635005734*^9}, {3.642875389865912*^9, 3.642875471576934*^9}, {3.6428779363600683`*^9, 3.642877969649777*^9}, { 3.661430876362545*^9, 3.661430910932199*^9}, {3.661430990401465*^9, 3.661431133209976*^9}, {3.661431186953548*^9, 3.661431347607976*^9}, { 3.661431386126994*^9, 3.6614313864303007`*^9}, {3.661431425953689*^9, 3.661431437951426*^9}, {3.661431584871826*^9, 3.661431586080407*^9}, { 3.661431972730323*^9, 3.661431973831876*^9}, {3.66148052414369*^9, 3.661480572354192*^9}, {3.66148063860112*^9, 3.661480657443218*^9}, { 3.661480723159878*^9, 3.661480877044993*^9}, {3.6614809753788567`*^9, 3.661481026065036*^9}, {3.66148106759858*^9, 3.66148111948094*^9}, 3.661481156765087*^9, {3.661481286888174*^9, 3.6614813120062523`*^9}, { 3.66160879576164*^9, 3.6616087988799047`*^9}, {3.661609053169869*^9, 3.6616090560410023`*^9}, {3.6616091024414053`*^9, 3.6616091472817717`*^9}, {3.66160918223419*^9, 3.661609182419429*^9}, { 3.6616092199288893`*^9, 3.6616092299054003`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Show", "[", RowBox[{ RowBox[{"ListPlot", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"benlevelsBoth", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], ",", RowBox[{"benlevelsBoth", "[", RowBox[{"[", RowBox[{"i", ",", "2"}], "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"Length", "[", "benlevelsBoth", "]"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"ListPlot", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"benlevelsBoth", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], ",", RowBox[{"benlevelsBoth", "[", RowBox[{"[", RowBox[{"i", ",", "3"}], "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"Length", "[", "benlevelsBoth", "]"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], ",", RowBox[{"AxesOrigin", "\[Rule]", RowBox[{"{", RowBox[{"0.5", ",", "0"}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.638105359909362*^9, 3.638105432335181*^9}, { 3.661609298921317*^9, 3.6616092990645*^9}}], Cell[BoxData[ GraphicsBox[{{{}, {{}, {RGBColor[0.368417, 0.506779, 0.709798], PointSize[ 0.011000000000000001`], AbsoluteThickness[1.6], PointBox[CompressedData[" 1:eJw10WtIU3EYx/FlqGVCIEKp5Mw0Zy8qUiGi+QuJDBJjQ7KW4VSUIspZSF5G LFS0jIzEpEkZNFLUjCnIKC0vi6K2KV6amped3c+ukvca0s7x3wOHc159eZ7z OZhfLCwM4HA4Sf6HeW+PAf+/hKroGqfAgJZYtSL97hkoJPwQ/RsDgul9C6Wh YqzxchqGVw1ovp6X17X/Ds5TFeHd6RREpU8GOv7IIH/BDIUU/uD4lfjHcAmY IIWIvdEDvwXPkeqvSfhGiH5+uE3JX8Mf8xeNiNmq6rHuasN2zojqG1QWd897 JLFjQmtx+mxufS/8y/mDJiSvv6vN36ECUwvRmyAqv19T1tGPRGY9nhnykv7D 3uFBVDK5CjN464tpW2dHoNUwY8ZEYEHQhuILuGzQAnls9bPG6G8oYc6VWFCU OrfS2fId7HrDFkhrl2WPIrVgc+FWXFPKLoofjKKIHStU7b4m1coY2N+nskKR QhdOxo2DPTfEhswjutGR3Amw6+XYQLUfCp5pngSb67YhPCxLOqKdIg52+O5p +IMcPbY97OjbjLt56+g08bCD+zU3+9XlGeJhhyzSk1lWP0s8aAS1yTNOaX4R Dxo67ehcwe554kEjQtfTlpK2QDwcEPLViQvSRTxlD3agSz9UuZJtgJH1cODA sRNRmUsGJLMeTmwIlAb3Q4p4OBEx36ipiDMSDyfKZ+p67J+NxMMF4ep0n05k Ih4uZEjRFLZsIh4uVOsvXT1ebyYebmjpqqHWBAvYcyVu6M5ZQj+qLcTDjZ1j AaeTxFbi4cEFn7iY/mslHh6IE6Z4vXIb8fAg+2V8XcNJO/HwIqZzTa3U24mH F1mb3E+BpTTx8CLobWWUL8xBPJbQ/UMn21I68A93OZqh "]]}, {}}, {}}, {{}, {{}, {RGBColor[0.368417, 0.506779, 0.709798], PointSize[ 0.011000000000000001`], AbsoluteThickness[1.6], PointBox[CompressedData[" 1:eJwt0WtIU3EYx/GlXYcW2DTL5SUxL7OcrFQi/Zlgdls6LWo6LCXNUHNSKM2Q tIxIQ6UslwjaUihrRjldLwyUfFGkWJoTfeGubnNzy0pt2qiz4/+Bw+G8+fI8 5xOUW5Ke58ZgMHjU43qvjRpZJiOfx1EiXelfYxGokX+rURdNfT8XxzNVMjW6 2VznRup7KUxUP7ioRpOKdd9jrxLHNBKWPEWDJHevw7/clXgqdY0G2qSbrMSe PlgFrqAG/TPVv6vW9yGBqonjtTgr9CyqWFKAilFFLewznoJlaQ/WcloM9x7/ tvDuLXj06OCzqai0798bUMtRQR2m+yfag7lyuGpMlQ5nSqb5cZKXCHetF6ZH lPXBJXzuRIUrJ9Fju/5hl5Mjw/AX1+gxWrbbliNsQwAdNKBumzPkD6sFpa5z xQasDvg5Ov42gV5v0ID6tOj3SZxG0DnWLHY5qqQNCbXIp2cWmWNtmx3KGtC/ TzmL5YmRmtDqKtDnMo3I2HL6yswpCej1REa47TO0Nguvgc7JjRAt14ZE9hZj zcOEGxUXvt+NyiMeJvjbTCdKzNnEw4QpWWWt7wsh8TBh/+OjqpbxDOJhhmLr yPmYZ3ziYUZB3KQgPjmZeJiROjWWf7IpkXjMIfZexkXdcAwa6IPnsDqR3D6+ gQct7TGHRUedSHqOiwO0hwVeH71TjepI4mHBnbbWD09+hhMPC9bJuR1F5aHE w4r0q7mxo2UhxMMKZ0oBY+VTMPGwortrwGrI2kM85nHQsVDcGxAE+lzxPG5H vPaVegQSj3lEFK48Woj1Jx42DOYoDvEb2cTDhuzOIc4k24942CAxXs5sHttJ POwYDZQpFd2+xMOOfh4z7cirHcTDjsKvqz3MIR/i8QPs8uuOyiVv/AcXbYoF "]]}, {}}, {}}}, AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948], Axes->{True, True}, AxesLabel->{None, None}, AxesOrigin->{0.5, 0}, DisplayFunction->Identity, Frame->{{False, False}, {False, False}}, FrameLabel->{{None, None}, {None, None}}, FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}}, GridLines->{None, None}, GridLinesStyle->Directive[ GrayLevel[0.5, 0.4]], Method->{}, PlotRange->{0, 1}, PlotRangeClipping->True, PlotRangePadding->{{ Scaled[0.02], Scaled[0.02]}, { Scaled[0.02], Scaled[0.05]}}, Ticks->{Automatic, Automatic}]], "Output", CellChangeTimes->{{3.661431409627647*^9, 3.661431430035821*^9}, 3.661431528521762*^9, 3.661431634158618*^9, 3.661431993008534*^9, 3.661432048450756*^9, 3.661432674746057*^9, 3.6614438374360037`*^9, 3.6614804666130342`*^9, 3.661480499453658*^9, 3.661480681505505*^9, 3.661480744792314*^9, 3.661480781856461*^9, 3.6614808988040457`*^9, 3.661481327422946*^9, 3.661608774666346*^9, 3.661608806240033*^9, 3.661609028154519*^9, 3.661609066551428*^9, {3.661609138170142*^9, 3.661609154650216*^9}, 3.661609192537663*^9, 3.66160924430774*^9, 3.6616092996125727`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData["benlevelsBoth"], "Input", CellChangeTimes->{{3.661431359623712*^9, 3.6614313933870287`*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0.5`", ",", "0", ",", "0.09440918590544937`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.51`", ",", "0.0005020236799576251`", ",", "0.0944091015421705`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.52`", ",", "0.0019590665913230584`", ",", "0.09440654450746665`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.53`", ",", "0.004418061600597898`", ",", "0.09433058138969692`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.54`", ",", "0.008290609273724204`", ",", "0.09381027428208902`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.55`", ",", "0.013743116134746639`", ",", "0.09259415149814346`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.56`", ",", "0.02179698256760707`", ",", "0.08991253108513227`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.5700000000000001`", ",", "0.032431645170998905`", ",", "0.08579226863853269`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.58`", ",", "0.044989785472349775`", ",", "0.08047433594572316`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.59`", ",", "0.06063173209323039`", ",", "0.07305823692305609`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.6`", ",", "0.07634543494299216`", ",", "0.06640192526904473`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.61`", ",", "0.0937711316346082`", ",", "0.05896102285930357`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.62`", ",", "0.11197617777950111`", ",", "0.05171371412663342`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.63`", ",", "0.13094891921435875`", ",", "0.04451177694769403`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.64`", ",", "0.15054300561308165`", ",", "0.03744499892668087`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.65`", ",", "0.16909694969039765`", ",", "0.03193193465879818`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.66`", ",", "0.18843311933621437`", ",", "0.026447179144511376`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.67`", ",", "0.20787572341986332`", ",", "0.02147158940255343`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.6799999999999999`", ",", "0.22737246796082988`", ",", "0.0167665887386908`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.69`", ",", "0.24613574869125446`", ",", "0.013302926716502617`"}], "}"}], ",", RowBox[{"{", RowBox[{"0.7`", ",", "0.2649365868297866`", ",", "0.01060671384412053`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.71`", ",", "0.2834979052757609`", ",", "0.008549031039233308`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.72`", ",", "0.30272002500047257`", ",", "0.006420967770170388`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.73`", ",", "0.32176805207440223`", ",", "0.00472411743096335`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.74`", ",", "0.3406838144440212`", ",", "0.0036269056548680467`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.75`", ",", "0.3594208339217173`", ",", "0.0025861390558782863`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.76`", ",", "0.3778337045986534`", ",", "0.0018867098657570146`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.77`", ",", "0.3960338452589997`", ",", "0.0015661945053386723`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.78`", ",", "0.41476257045761855`", ",", "0.0012103578456871367`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.79`", ",", "0.43434007149572584`", ",", "0.0009043469777769349`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.8`", ",", "0.45369812549253374`", ",", "0.0006491231358170093`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.81`", ",", "0.4727911126785514`", ",", "0.0005060785457818381`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.8200000000000001`", ",", "0.49199632719770137`", ",", "0.00034796525171832147`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.8300000000000001`", ",", "0.5107366959698445`", ",", "0.00029026452218459926`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.8400000000000001`", ",", "0.5293341189548958`", ",", "0.00024936193635829936`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.8500000000000001`", ",", "0.5480870617416818`", ",", "0.0002203256949928905`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.86`", ",", "0.566953086438761`", ",", "0.00019796469069466663`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.87`", ",", "0.5859263884547509`", ",", "0.00017903519855742847`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.88`", ",", "0.6048348971595863`", ",", "0.00016375819877089082`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.89`", ",", "0.623421947002393`", ",", "0.00015097786690937412`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.9`", ",", "0.64199083175366`", ",", "0.00014006787967288161`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.91`", ",", "0.6610869197459636`", ",", "0.00013064481661113352`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.9199999999999999`", ",", "0.6802649738185325`", ",", "0.000122445763134433`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.9299999999999999`", ",", "0.6992431804742413`", ",", "0.00011527454375441214`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.94`", ",", "0.7182509589546354`", ",", "0.00010897668714927088`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.95`", ",", "0.7376342580330224`", ",", "0.00010342664149267644`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.96`", ",", "0.7569043788070456`", ",", "0.00009852044477290197`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.97`", ",", "0.7763298842377004`", ",", "0.00009417101515219188`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.98`", ",", "0.7955349648835104`", ",", "0.0000903048385316315`"}], "}"}], ",", RowBox[{"{", RowBox[{ "0.99`", ",", "0.8148174797799477`", ",", "0.00008685949182646805`"}], "}"}], ",", RowBox[{"{", RowBox[{ "1.`", ",", "0.8342278018738989`", ",", "0.00008378171911657375`"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.661608977558234*^9, 3.661609311133939*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Export", "[", RowBox[{ "\"\\"", ",", "benlevelsBoth", ",", "\"\\""}], "]"}]], "Input", CellChangeTimes->{3.661443820522064*^9}], Cell[BoxData["\<\"FixationProbData3.csv\"\>"], "Output", CellChangeTimes->{3.661443832501549*^9, 3.661609318890534*^9}] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Code for individual based simulations to show allele frequency trajectories \ (Figure 5B and 5C)\ \>", "Chapter", CellChangeTimes->{{3.6615402495763063`*^9, 3.661540266046463*^9}, { 3.661608667945924*^9, 3.66160867163354*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"dosimME", ":=", RowBox[{"(", RowBox[{ RowBox[{"pnorm", "=", RowBox[{"Ne", RowBox[{"(", RowBox[{"1", "-", RowBox[{"2", "*", "pinit"}]}], ")"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"pDME", "=", RowBox[{"Ne", " ", "pinit"}]}], ";", "\[IndentingNewLine]", RowBox[{"pRME", "=", RowBox[{"Ne", " ", "pinit"}]}], ";", "\[IndentingNewLine]", RowBox[{"env0", "=", "1"}], ";", "\[IndentingNewLine]", RowBox[{"yearmult", "=", RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"yearenv", "=", RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"curgeo", "=", RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"popt", "=", RowBox[{"Table", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"switch", "=", RowBox[{ RowBox[{"RandomSample", "[", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"\[Rho]", ",", RowBox[{"1", "-", "\[Rho]"}]}], "}"}], "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], ",", "1"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", RowBox[{"(*", RowBox[{ RowBox[{ "\[Rho]", " ", "is", " ", "prob", " ", "of", " ", "switching"}], ","}], "*)"}], "\[IndentingNewLine]", RowBox[{"env", "=", RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{"env0", "+", "2"}], ",", RowBox[{"switch", "+", "2"}]}], "]"}], "+", "1"}]}], ";", RowBox[{"(*", RowBox[{ "Just", " ", "used", " ", "to", " ", "cause", " ", "env", " ", "to", " ", "alternate", " ", "between", " ", "1", " ", "and", " ", "2"}], "*)"}], "\[IndentingNewLine]", RowBox[{"wDME", "=", RowBox[{"Exp", "[", RowBox[{"If", "[", RowBox[{ RowBox[{"env0", "\[Equal]", "1"}], ",", RowBox[{ RowBox[{"{", RowBox[{"Lw1", ",", "Lw2"}], "}"}], "[", RowBox[{"[", "env", "]"}], "]"}], ",", "0"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"c", "=", RowBox[{"If", "[", RowBox[{ RowBox[{"0", ">", "optimumRMEfreqs"}], ",", "0", ",", RowBox[{"If", "[", RowBox[{ RowBox[{"optimumRMEfreqs", ">", "1"}], ",", "1", ",", "optimumRMEfreqs"}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"wRME", "=", RowBox[{"If", "[", RowBox[{ RowBox[{"env", "\[Equal]", "1"}], ",", "\[IndentingNewLine]", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", "c"}], ")"}], "*", RowBox[{"Exp", "[", "Lw1", "]"}]}], "+", RowBox[{ RowBox[{"(", "c", ")"}], " ", "1"}]}], ",", "\[IndentingNewLine]", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", "c"}], ")"}], "*", RowBox[{"Exp", "[", "Lw2", "]"}]}], "+", RowBox[{ RowBox[{"(", "c", ")"}], " ", "1"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"totbirth", "=", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"pnorm", "*", "1"}], ",", RowBox[{"pDME", "*", "wDME"}], ",", RowBox[{"pRME", "*", "wRME"}]}], "}"}], ".", RowBox[{"{", RowBox[{"1", ",", "1", ",", "1"}], "}"}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "Calculate", " ", "what", " ", "the", " ", "geometric", " ", "mean", " ", "would", " ", "be", " ", "assayed", " ", "as"}], "*)"}], "\[IndentingNewLine]", RowBox[{"assays", "=", " ", RowBox[{"(*", RowBox[{"{", RowBox[{"aA", ",", "aN", ",", "nA", ",", "nN"}], "}"}], "*)"}], RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"pnorm", "*", "1"}], "+", RowBox[{"pRME", "*", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", "c"}], ")"}], "*", RowBox[{"Exp", "[", "Lw2", "]"}]}], "+", RowBox[{ RowBox[{"(", "c", ")"}], " ", "1"}]}], " ", ")"}]}], "+", " ", RowBox[{"pDME", " ", "*", "1"}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"pnorm", "*", "1"}], "+", RowBox[{"pRME", "*", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", "c"}], ")"}], "*", RowBox[{"Exp", "[", "Lw1", "]"}]}], "+", RowBox[{ RowBox[{"(", "c", ")"}], " ", "1"}]}], " ", ")"}]}], "+", " ", RowBox[{"pDME", " ", "*", RowBox[{"Exp", "[", "Lw2", "]"}]}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"pnorm", "*", "1"}], "+", RowBox[{"pRME", "*", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", "c"}], ")"}], "*", RowBox[{"Exp", "[", "Lw2", "]"}]}], "+", RowBox[{ RowBox[{"(", "c", ")"}], " ", "1"}]}], " ", ")"}]}], "+", " ", RowBox[{"pDME", " ", "*", "1"}]}], ",", " ", "\[IndentingNewLine]", RowBox[{ RowBox[{"pnorm", "*", "1"}], "+", RowBox[{"pRME", "*", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", "c"}], ")"}], "*", RowBox[{"Exp", "[", "Lw1", "]"}]}], "+", RowBox[{ RowBox[{"(", "c", ")"}], " ", "1"}]}], " ", ")"}]}], "+", " ", RowBox[{"pDME", " ", "*", RowBox[{"Exp", "[", "Lw1", "]"}]}]}]}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"assays", "=", RowBox[{"assays", "/", "Ne"}]}], ";", " ", RowBox[{"(*", RowBox[{ RowBox[{ RowBox[{"p", "'"}], "s", " ", "are", " ", "actually", " ", "numbers"}], ",", " ", RowBox[{"not", " ", RowBox[{"frequencies", ".", " ", "Must"}], " ", "to", " ", "divide", " ", "by", " ", "Ne", " ", "to", " ", "get", " ", "frequency"}]}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"altgeo", "=", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{"assays", "[", RowBox[{"[", "2", "]"}], "]"}], "*", RowBox[{"assays", "[", RowBox[{"[", "3", "]"}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"totgeo", "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"assays", "[", RowBox[{"[", "1", "]"}], "]"}], "*", RowBox[{"assays", "[", RowBox[{"[", "2", "]"}], "]"}], "*", RowBox[{"assays", "[", RowBox[{"[", "3", "]"}], "]"}], "*", RowBox[{"assays", "[", RowBox[{"[", "4", "]"}], "]"}]}], ")"}], "^", RowBox[{"(", RowBox[{"1", "/", "4"}], ")"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"curgeo", ",", RowBox[{"{", RowBox[{"altgeo", ",", "totgeo"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"end", " ", "geo", " ", "mean", " ", "calculation"}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"yearmult", ",", "totbirth"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"yearenv", ",", "env"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"newpop", "=", RowBox[{"RandomVariate", "[", RowBox[{"MultinomialDistribution", "[", RowBox[{"Ne", ",", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"pnorm", "*", "1"}], ",", RowBox[{"pDME", "*", "wDME"}], ",", RowBox[{"pRME", "*", "wRME"}]}], "}"}], "/", "totbirth"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"pnorm", "=", RowBox[{"newpop", "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"pDME", "=", RowBox[{"newpop", "[", RowBox[{"[", "2", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"pRME", "=", RowBox[{"newpop", "[", RowBox[{"[", "3", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"env0", "=", "env"}], ";", "\[IndentingNewLine]", RowBox[{"Flatten", "[", RowBox[{"{", RowBox[{"t", ",", RowBox[{"N", "[", RowBox[{"newpop", "/", "Ne"}], "]"}]}], "}"}], "]"}]}], ",", RowBox[{"{", RowBox[{"t", ",", "1", ",", "60"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"ListPlot", "[", RowBox[{ RowBox[{"Transpose", "[", "popt", "]"}], "[", RowBox[{"[", "2", "]"}], "]"}], "]"}]}], ")"}]}], "\[IndentingNewLine]"}]], "Input", CellChangeTimes->{{3.642867609134555*^9, 3.642867744141716*^9}, { 3.642867988964355*^9, 3.642867990898325*^9}, {3.642868021452359*^9, 3.642868075322175*^9}, {3.642868122572488*^9, 3.642868123677301*^9}, { 3.6428681689178867`*^9, 3.642868350819459*^9}, 3.642868397102294*^9, { 3.6428684299073973`*^9, 3.642868436264119*^9}, {3.642868508962289*^9, 3.64286851124693*^9}, {3.642868653096137*^9, 3.642868714624317*^9}, { 3.642868797807303*^9, 3.642868886946951*^9}, {3.642868978794232*^9, 3.6428690056514587`*^9}, {3.64286951889902*^9, 3.6428695532900248`*^9}, { 3.642870231441489*^9, 3.642870235480847*^9}, 3.6428703244674063`*^9, { 3.6428703947995872`*^9, 3.64287040765059*^9}, {3.642870441930225*^9, 3.642870442097558*^9}, {3.642870506882001*^9, 3.642870507569968*^9}, { 3.642871147029356*^9, 3.642871189480515*^9}, {3.6428712581213827`*^9, 3.642871261172373*^9}, {3.6428712962843103`*^9, 3.642871337693132*^9}, { 3.642871372422673*^9, 3.6428713938563643`*^9}, {3.642871496856255*^9, 3.642871521380217*^9}, {3.642871559741344*^9, 3.642871593795691*^9}, { 3.642871624862988*^9, 3.6428717857397614`*^9}, 3.642871992757552*^9, { 3.642872803674342*^9, 3.642872881413207*^9}, {3.6428729153231163`*^9, 3.642873070405182*^9}, 3.642873506210155*^9, {3.642874002917865*^9, 3.6428740531200113`*^9}, {3.642874743422453*^9, 3.642874779833089*^9}, { 3.64287496331038*^9, 3.642874963551626*^9}, {3.642876543904015*^9, 3.642876556955521*^9}, {3.642876905346262*^9, 3.6428769060169363`*^9}, 3.642877012243569*^9, {3.6428771752194233`*^9, 3.642877175791588*^9}, { 3.642878236360794*^9, 3.6428783284874563`*^9}, {3.642880699780307*^9, 3.642880734745686*^9}, {3.6428807980691977`*^9, 3.642880877316708*^9}, 3.642880945286055*^9, 3.642880990669726*^9, {3.642881041597802*^9, 3.642881231634658*^9}, {3.642881264012158*^9, 3.6428812795772877`*^9}, { 3.642881400551446*^9, 3.6428814627244463`*^9}, 3.64288151793322*^9, { 3.64288170484296*^9, 3.642881705194295*^9}, {3.642882020875781*^9, 3.642882024861762*^9}, {3.642882164344733*^9, 3.642882165870346*^9}, { 3.6428823602805347`*^9, 3.642882362445442*^9}, {3.642883375027248*^9, 3.642883384248246*^9}, {3.642883477857094*^9, 3.6428834859835453`*^9}, { 3.6428838535666513`*^9, 3.6428838537849216`*^9}, {3.6428999972339497`*^9, 3.6428999976095753`*^9}, 3.642938552860882*^9, {3.642948740413238*^9, 3.642948741057616*^9}, {3.642948798599094*^9, 3.642948799219228*^9}, { 3.6429490122656183`*^9, 3.6429490299099417`*^9}, {3.661540313699039*^9, 3.661540316779801*^9}, {3.661607836055142*^9, 3.661607883018518*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Ne", "=", "1000"}], ";", RowBox[{"pinit", "=", "0.01"}], ";"}]], "Input", CellChangeTimes->{{3.643389944693099*^9, 3.6433899505931263`*^9}, { 3.643390012737405*^9, 3.643390016417446*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"Lw1", ",", "Lw2"}], "}"}], "=", RowBox[{"{", RowBox[{ RowBox[{"-", "1.093450911402644`"}], ",", "0.9697906176375761`"}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Exp", "[", RowBox[{"{", RowBox[{"Lw1", ",", "Lw2"}], "}"}], "]"}], " "}]}], "Input", CellChangeTimes->{{3.661607940071107*^9, 3.661607944903077*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"0.33505824003968687`", ",", "2.637392178132301`"}], "}"}]], "Output", CellChangeTimes->{{3.6616079320587587`*^9, 3.661607946074583*^9}}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"\[Rho]", "=", ".95"}], ";"}]], "Input"], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{"dosimME", ";"}], "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{ RowBox[{"ListPlot", "[", RowBox[{ RowBox[{ RowBox[{"Transpose", "[", "popt", "]"}], "[", RowBox[{"[", "2", "]"}], "]"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", "Black", "}"}]}], ",", RowBox[{"Frame", "\[Rule]", "True"}], ",", RowBox[{"FrameLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}], ",", RowBox[{"ListPlot", "[", RowBox[{ RowBox[{ RowBox[{"Transpose", "[", "popt", "]"}], "[", RowBox[{"[", "3", "]"}], "]"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", "Red", "}"}]}]}], "]"}], ",", RowBox[{"ListPlot", "[", RowBox[{ RowBox[{ RowBox[{"Transpose", "[", "popt", "]"}], "[", RowBox[{"[", "4", "]"}], "]"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", "Blue", "}"}]}]}], "]"}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}]}], "]"}]}], "Input", CellChangeTimes->{{3.661607954261862*^9, 3.6616080288008413`*^9}, { 3.6616080876031437`*^9, 3.661608142152223*^9}}], Cell[BoxData[ GraphicsBox[{{{}, {{}, {GrayLevel[0], PointSize[0.011000000000000001`], AbsoluteThickness[1.6], PointBox[CompressedData[" 1:eJxdzk8ow2Ecx/FvO63lIC1JkklLCMMM2/y+w8zGMEcHrUXJxZ+W8iethBSH 5eAoOUhJDtJaS9xwGhcnyWGKmchNDvbj+1P7PPX09HrePX9MocmhMR0RObJT Xf/GuxIrXUkHYm+KbLBt3RVMJTXr+Wr2bKe4LiPO59eAekKzkUftDwOb2y/i Ij65VA+kxSV8cb3rPv1Micu4YPk8u/MkLpf778UVPO003O1NaTbz19JEIryV FFeyL09XvVZ4I65i0/HMeDSTENdwNLOoWEfi4loe/v3gvrie1dudBs0Wnns2 W/SHG+IGjnvVB1bFjbxgPPI8zofFTfx98HHrD0XEVvGguFkcFNuYckYLuBXc BraDHWAnuB2sgDnXETC5oIOpAzqYOqGDqQs6mNzQwdQNHUwe6GDqgQ4mL3Qw +aCDqRc6mPqgg8kPHUz9//4BoNB+TA== "]]}, {}}, {}}, {{}, {{}, {RGBColor[1, 0, 0], PointSize[0.011000000000000001`], AbsoluteThickness[ 1.6], PointBox[CompressedData[" 1:eJxd0DtIw1AUxvFDcRAR6VDEwUFFpPjCd61tzfFZ29oKClLEKegigg7i4CBu IiLdHARxEBEdRKSTiGAHcXLoUsRBg0MXsXWoIjqYNOcKfoEQfvnnJie3Vl+a nHcQkd88rat95DVv8m71+mBPkxt8GSp3NG3uikv55+Q9HdXPxU62nz8VuziR KrhnEylxFeePbyOerRtxNRtrrrOgkRbX8PZi9tt8pbiOP6zVhWdxPYetz1ca 4gYuma5oudjPit38+LW+cLWi3CjzvYqbOaY7496kcqv8z5u4TeZVbueZOd/T xE5O3MEP959TL0fKnZw5XA6UZZS7OF7cAOVuNoc1lyj3cHHcnLKH1T7b116w F9wH9oH94AC4H6yB+b83wDQAHUyD0ME0BB1Mw9DBNAIdTKPQwRSEDqYx6GAK QQdTGDqYItDBNA4dTFHoYIr9+Re/86/V "]]}, {}}, {}}, {{}, {{}, {RGBColor[0, 0, 1], PointSize[0.011000000000000001`], AbsoluteThickness[ 1.6], PointBox[CompressedData[" 1:eJxdzT1LglEYh/E/To4ODg0iFiEhIdqLZZnP8f2lFOojCEG4tETUEi4tESK0 uDkHjQ0O0uzc2ieQlhyLht5ugue64XD4netwzmLn9Og4ICn3vX72v3nzLmfx dPDh1rMDN45evx6O++ag+7jqTs7uhuaQyz5Oz59GN+Yw+oL7vJ8/tzoDc8S9 vP9eMMes98xLzv//sr13YY6bT8wrTr5JwKtwEk7BaXgNXoc34E04A2/B23AW 3oF34Ry8B+dhD3Z+92AV0GEV0WGV0GGV0WFV0GFV0WHV0GHV0WE10GE10WHt o8M6QIfVQofV/vcXqPNU5A== "]]}, {}}, {}}}, AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948], Axes->{True, True}, AxesLabel->{None, None}, AxesOrigin->{0, 0}, DisplayFunction->Identity, Frame->{{True, True}, {True, True}}, FrameLabel->{{ FormBox["\"Allele Frequency\"", TraditionalForm], None}, { FormBox["\"Generation\"", TraditionalForm], None}}, FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}}, GridLines->{None, None}, GridLinesStyle->Directive[ GrayLevel[0.5, 0.4]], Method->{}, PlotRange->{0, 1}, PlotRangeClipping->True, PlotRangePadding->{{ Scaled[0.02], Scaled[0.02]}, { Scaled[0.02], Scaled[0.05]}}, Ticks->{Automatic, Automatic}]], "Output", CellChangeTimes->{{3.661540428939776*^9, 3.661540441265625*^9}, { 3.661607960550149*^9, 3.66160802921999*^9}, {3.661608089125328*^9, 3.661608143044594*^9}}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"\[Rho]", "=", ".55"}], ";"}]], "Input", CellChangeTimes->{{3.661608155185321*^9, 3.6616081553269444`*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{"dosimME", ";"}], "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{ RowBox[{"ListPlot", "[", RowBox[{ RowBox[{ RowBox[{"Transpose", "[", "popt", "]"}], "[", RowBox[{"[", "2", "]"}], "]"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", "Black", "}"}]}], ",", RowBox[{"Frame", "\[Rule]", "True"}], ",", RowBox[{"FrameLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"AxesOrigin", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}]}], "]"}], ",", RowBox[{"ListPlot", "[", RowBox[{ RowBox[{ RowBox[{"Transpose", "[", "popt", "]"}], "[", RowBox[{"[", "3", "]"}], "]"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", "Red", "}"}]}]}], "]"}], ",", RowBox[{"ListPlot", "[", RowBox[{ RowBox[{ RowBox[{"Transpose", "[", "popt", "]"}], "[", RowBox[{"[", "4", "]"}], "]"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", "Blue", "}"}]}]}], "]"}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}]}], "]"}]}], "Input", CellChangeTimes->{{3.661607954261862*^9, 3.6616080288008413`*^9}, { 3.6616080876031437`*^9, 3.661608142152223*^9}, {3.661608180481987*^9, 3.661608187543407*^9}}], Cell[BoxData[ GraphicsBox[{{{}, {{}, {GrayLevel[0], PointSize[0.011000000000000001`], AbsoluteThickness[1.6], PointBox[CompressedData[" 1:eJxdkmtIk1EYx19GxJCIIRISFjPMLDNaWnPq3H9OnVOnWBEREjIKpA8pYuEN 0Q8iFjGi24duREQXJMKiIkLCRowIFRWWYeiwMFPTPlhQEp5z/J9AXxgvv/3O eS7v8yQGag6eNBmGkSN+8r3yLLhG+38fmrw37+IfSOu5OX//nWYzIndrnTER zRasO7JRHiHHIUYd0BwPy1HHs/DZH+SENd6Kqb8Pfw75td+GM5fiRcg5chJu iewlds3JEMF6b2+eIaegLCAzfCPvwvFXvg2mVO13Y2dlsG8xRfs9OPW6XmT4 Tt7LeqbINmw5diJ7vHyavA/2LnfV10F9Ph3NcY+90SYdLwMqfVj7/Rgvv3Dt dKyOdwAqfeUk2Y63goJ9n8mZuBGyPqmrjpId+DfSMJ1s+0LOwgPRfZd7gpwN c3eCqDBCzkG0SRb0iezkfIbJuXCqBt+TXfjTKr/AIBkY9ssOQivcBmxf337F c/4DvRu/ZLmLPN/mRqKo9uLcCH0e+xugz8OAXJ/r2nvwSEw3YPlI78EOm+xg jD4f6npwiD6f9YXpC3BYRAtZ39AXIF09T+kLYUrt3DTa/4K+EEtynQI8b3g5 7+f03tXxjCKodUvroS/CbMXLrR0zd+h9UOvUeZXex3lpX8x9uExfDIda0HP0 JeyngX4NG6W8X09fikYxfXN3C72f/VTR+3m/mr7sPy8DNQkSuw== "]]}, {}}, {}}, {{}, {{}, {RGBColor[1, 0, 0], PointSize[0.011000000000000001`], AbsoluteThickness[ 1.6], PointBox[CompressedData[" 1:eJxdyb1KggEUx+E/TY4NDQ0OGREREmrf+eZrZh9+1NAlBIK4uDSH9+DteFHN TRVF4HPgcHjOr/Y6f5lsJCm+9+f+zkf5+T5bvS2n5d+jm7Wp4E28hbdxFe/g XbyH9/EBPsR1fIQbuIlb+Bif4FN8hs/xBb7EV7iNC3yNO7jE3XUvcG7oOD06 zi0dp0/HuaPj3NNxHug4j3ScAR1nSMcZ0XHGdJwnOs7zv78AYIAqOQ== "]]}, {}}, {}}, {{}, {{}, {RGBColor[0, 0, 1], PointSize[0.011000000000000001`], AbsoluteThickness[ 1.6], PointBox[CompressedData[" 1:eJxdkltIVFEUhg8SIj5EyBAmYd4Qu5hamZXa+WfGccbLFBr0EBIhBiKlVlJW QxwJKQkREZGCsuhBRZHowSQkQkMpSE0EERlkNLPJOyLSDTp7z7+FPDAM33x7 zlr/Xiu6uKLwcpCmaRnmR3wHnlX9T8famLvY0PkDbvvjU0K6POQQ3LV0O313 qsi78OteWV9V00OyBb2RtQsFvc/I4fTt5L3bfBTqrJfmRmM6yTG4UJI+fbb+ DTkOYffff3rh6CHHI8kbF1zTPEBOwMeb71ojkj6TD+DB7snhzXPKH0JRQ/9G QtEI+TDO70x8/XRliJyMxQLR0RdyCupbykVJ8hHETv00E3wgH4WMbxkmH8Mt Ud6rfCpsIs6Uet9xuMzT3c5Jchr2ifiRPvIJ9u8ln8QO2eAE+RReXS9tXPJM k9MRmM9XcgZkvIYZcib7+0Y+jWuZoRMvK/1kHYHrnCcDj67M/+5Y+xFgA8zz nd4K2W4tzxtWrLYN5qXVzdHbsF9eMM8bNuyRAZS346AcyCy9HVdFuTGVP4v7 wH6NLN6f6tfB/y/QO/DksXiW6LPxPEJsBNnIRk2z3YzE85oTN8T16co7/3+f 5sKyR0+9+FZ5F+S4fMv0OTCXxUy8Qp+DnvW/49V+5XO5X8rncj/JWh6CZEHl t7GWD3M45oSUz0eiLKi8m/uqvJv5lD+zxf8An0cjVg== "]]}, {}}, {}}}, AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948], Axes->{True, True}, AxesLabel->{None, None}, AxesOrigin->{0, 0}, DisplayFunction->Identity, Frame->{{True, True}, {True, True}}, FrameLabel->{{ FormBox["\"Allele Frequency\"", TraditionalForm], None}, { FormBox["\"Generation\"", TraditionalForm], None}}, FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}}, GridLines->{None, None}, GridLinesStyle->Directive[ GrayLevel[0.5, 0.4]], Method->{}, PlotRange->{0, 1}, PlotRangeClipping->True, PlotRangePadding->{{ Scaled[0.02], Scaled[0.02]}, { Scaled[0.02], Scaled[0.05]}}, Ticks->{Automatic, Automatic}]], "Output", CellChangeTimes->{3.661608157672336*^9, 3.661608188635293*^9}] }, Open ]] }, Open ]] }, Open ]] }, WindowSize->{1191, 821}, WindowMargins->{{23, Automatic}, {0, Automatic}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, ShowSelection->True, Magnification:>1.5 Inherited, FrontEndVersion->"10.3 for Mac OS X x86 (32-bit, 64-bit Kernel) (October 9, \ 2015)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[579, 22, 341, 8, 303, "Title"], Cell[CellGroupData[{ Cell[945, 34, 279, 6, 161, "Chapter"], Cell[CellGroupData[{ Cell[1249, 44, 125, 1, 52, "Subsubsection"], Cell[1377, 47, 652, 10, 135, "Text"], Cell[2032, 59, 668, 20, 43, "Input"], Cell[2703, 81, 500, 8, 135, "Text"], Cell[3206, 91, 961, 26, 101, "Input"], Cell[4170, 119, 407, 7, 76, "Text"], Cell[4580, 128, 1012, 28, 94, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[5629, 161, 122, 1, 52, "Subsubsection"], Cell[5754, 164, 202, 4, 46, "Text"], Cell[5959, 170, 291, 6, 46, "Text"], Cell[6253, 178, 1293, 22, 94, "Input"], Cell[7549, 202, 12296, 250, 1169, "Input"], Cell[CellGroupData[{ Cell[19870, 456, 1366, 40, 119, "Input"], Cell[21239, 498, 3397, 68, 362, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[24673, 571, 107, 1, 43, "Input"], Cell[24783, 574, 6414, 204, 569, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[31234, 783, 190, 5, 43, "Input"], Cell[31427, 790, 120, 1, 43, "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[31608, 798, 239, 5, 161, "Chapter"], Cell[31850, 805, 12712, 286, 1119, "Input"], Cell[44565, 1093, 228, 5, 43, "Input"], Cell[CellGroupData[{ Cell[44818, 1102, 426, 13, 69, "Input"], Cell[45247, 1117, 180, 4, 43, "Output"] }, Open ]], Cell[45442, 1124, 74, 2, 43, "Input"], Cell[CellGroupData[{ Cell[45541, 1130, 1260, 34, 144, "Input"], Cell[46804, 1166, 2589, 57, 370, "Output"] }, Open ]], Cell[49408, 1226, 142, 3, 43, "Input"], Cell[CellGroupData[{ Cell[49575, 1233, 1415, 38, 144, "Input"], Cell[50993, 1273, 2936, 63, 370, "Output"] }, Open ]] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)