Genetic Drift Expanded
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This model is an example of genetic drift. It shows that competing organisms, turtles of different colors, each with equal likelihood reproduction, will ultimately converge on one breed without any particular selection pressure.
HOW IT WORKS
The model starts with a random distribution of colored turtles. They move by wiggling randomly across the world. Each turn, a turtle produces between 0 and 5 offspring, value that can be modified by the user. If the total number of turtles is greater than the original number, then turtles are randomly killed until the original number is restored. This can be achieved by randomly kill considering all turtles or by killing the older turtles first. When only one breed of turtles is alive it is said that the breed as come to fixation and the simulation ends.
HOW TO USE IT
- The "setup" button initializes the model.
- The "go" button runs the model.
- Use the "colors" slider to select the number of competing colors (breeds).
- The "number" slider sets the number of turtles.
- Use the "walls" buttons to divide the world.
- Use the "remove-pop" button to randomly kill turtles and simulate bottle-neck effect.
- The "mutation-rate" buttons adds a turtle birth mutation rate.
- The "death-cause" chooser determines death cause when population exceeds "population" slider value.
- The "max-offspring" slider sets the maximum number of offspring for each turtles on each generation.
- Use the "clear-output" to clear the message log screen.
THINGS TO TRY
This models adds several features compared to other models. It is recommended to change things one at a time and notice how that changes the outcome of the simulation. Here is a list of possible things to do:
Experiment with adding walls. When walls are added, groups of individuals can be geographically isolated. Groups that are geographically isolated with walls will often end up with a different dominant color than the larger population.
Experiment with the two different options of death cause. Run a few simulations for each type. Did you notice any difference?
Looking at the graphs, use the "remove-pop" button to randomly remove turtles from the world. How does that affect each alive breed?
Change the population value and keep the number of colors constant. How does that affect the number of generations that it takes for a breed to go to fixation? Then keep the population constant and change the number of colors. What is the effect this time? How many generations does it take before a breed goes extinct?
When introducing mutations fixation can take many generations. Try selecting continuous update instead of by tick. Furthermore, try unselecting the "view update" option and focus on the plots.
Experiment with the bottle-neck effect. For a more extreme scenario click the "remove-pop" button two or three times at once.
THINGS TO NOTICE
Notice that often colors can get to quite a high population but still fail to win the race. Also notice that when a breed dies it can not come back, not even when mutation rate is greater than zero.
EXTENDING THE MODEL
Add-ons to the model by Carlo Maley were kept (e.g. organisms moving more slowly).
Juan Garcia Mesa added a mutation rate option and the ability for fixation in each area when the world is divided by walls.
The grim reaper in the procedure death does a random harvesting of the population to keep it roughly constant. This might be somewhat like a natural environment with a limited food supply. Juan Garcia Mesa added an option where older turtles die first to simulate aging. Can you think of other ways to write this procedure? Are the results affected?
RELATED MODELS
- GenDrift P global
- GenDrift P local
- GenDrift T interact
- GenDrift T reproduce
- Genetic Drift by Carlo Maley
HOW TO CITE
If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.
For the model itself:
- Wilensky, U. (1997). NetLogo GenDrift T reproduce model. http://ccl.northwestern.edu/netlogo/models/GenDriftTreproduce. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
Please cite the NetLogo software as:
- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
COPYRIGHT AND LICENSE
Copyright 1997 Uri Wilensky.
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.
This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.
This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2001.
Comments and Questions
globals [ max-percent ;; most numerous color turtles in % max-color ;; color of most numerous pop-removed-ticks ;; ticks since pop removal alive-colors ;; # of colors alive wall-list ;; list of wall coordinates ] turtles-own [age] ;; turtles' age to setup clear-commands populate-world ;; create turtles ask turtles [ set shape "circle" ] ;; set turtles to circle shape find-top-species ;; find percentage of most numerous species set alive-colors [5 15 25 35 45 55 65 85 95 125] count-alive-colors ;; count alive colors after setting list to all by default remove-all-walls set mutation-rate 0.0 reset-ticks setup-plots output-print( word "[New simulation]" ) end to clear-commands clear-patches clear-turtles clear-all-plots clear-ticks end to populate-world create-turtles population [ set color 5 + (random colors) * 10 if color = turquoise ;; turquoise (75) is too similar to another color [ set color magenta ] ;; so use magenta (125) instead setxy random-xcor random-ycor ] end to go if stop-run? [ ;; if fixation = true stop output-print (word "Fixation:" ticks " gen, mut rate:" mutation-rate ", pop:" population ", colors:" colors ) stop ] ask turtles [ ;; move turtles rt random 50 lt random 50 ifelse [ pcolor ] of patch-ahead 1 = black ;; if wall ahead change direction [ fd 0.2 ] ;; Move forward 0.2 (not 1 to slow down) [ bk 0.5 rt random 180 ] ; ] if ticks - pop-removed-ticks > 10 [ ;; if 10 ticks from removal clear death patches color ask patches with [pcolor = violet ] [ set pcolor black ] ] birth grow-old ifelse death-cause = "random-death" [ random-death ] [ death-by-age ] find-top-species count-alive-colors tick end ;; Get the string (name) of a color to-report translate-color [num] if num = 5 [report "grey"] if num = 15 [report "red"] if num = 25 [report "orange"] if num = 35 [report "brown"] if num = 45 [report "yellow"] if num = 55 [report "green"] if num = 65 [report "lime"] if num = 75 [report "turquoise"] if num = 85 [report "cyan"] if num = 95 [report "sky"] if num = 105 [report "blue"] if num = 115 [report "violet"] if num = 125 [report "magenta"] ifelse num = 135 [ report "pink" ] [ report "unknown color" ] end to birth ask turtles [ fd 0.3 hatch (random max-offspring + 1) [ ;; turtles hatch between 0 and max-offspring babies and move forward 0.3 if(random 1000) < (mutation-rate * 1000) ;; random mutation given rate [ set color one-of alive-colors ] set age 0 ] ] end ;; if the overall population is greater than the original number, ;; randomly kill turtles to keep population roughly constant to random-death let total-turtles count turtles ask turtles [ if random total-turtles > population [ die ] ] end to grow-old ask turtles [ set age age + 1 ;; turtles age increases by 1 every tick ] end to death-by-age ;; kill (randomly) older turtles first let list-turtles sort-on [age] turtles while [count turtles > population] [ ask last list-turtles [ die] set list-turtles remove-item (length list-turtles - 1) list-turtles ] end to remove-pop let num-turtles count turtles ;; count current number of turtles let xcoor random world-width - max-pxcor ;; select random x coordinate let ycoor random world-height - max-pycor ;; select random y coordinate ask patches with [ pxcor = xcoor and pycor = ycoor ] [ let radius (10 + random 10) ask patches in-radius radius [ if pcolor = black [ set pcolor violet ;; set death area to violet ] ] ask turtles in-radius radius [die] ;; make turtles in area die ] let killed-turtles (num-turtles - count turtles) / num-turtles * 100 output-print (word "Removed " round (killed-turtles) "% of turtles at generation " ticks ".") set pop-removed-ticks ticks end ;; find the percentage of the most populous species to find-top-species let winning-amount 0 foreach base-colors [ c -> let how-many count turtles with [color = c] if how-many > winning-amount [ set winning-amount how-many set max-color translate-color c ] ] set max-percent (100 * winning-amount / count turtles) end to count-alive-colors foreach alive-colors [ c -> if count turtles with [color = c] = 0 [ ;; if # of turtles of that color = 0 remove color from list set alive-colors remove c alive-colors ] ] end to-report stop-run? let stop-run (list) let i 0 let colors-in-area (list) while [i < length wall-list - 1] ;; get turtles between each set of walls (area) [ ask turtles with [ycor > item i wall-list and ycor < item (i + 1) wall-list ] [ ;; get color of all turtles in the area set colors-in-area insert-item 0 colors-in-area color ] if length colors-in-area > 1 [ ;; if there are more than 1 color in area add false to list ifelse variance colors-in-area = 0.0 [ set stop-run insert-item 0 stop-run true ] [ set stop-run insert-item 0 stop-run false ] ] ;; reset counters set colors-in-area (list) set i (i + 1) ] ;; if list has one or more 'false' values keep running simulation ifelse member? false stop-run [ report false ] ;; else stop simulation = true [ report true ] end ;; --------------------------------------------------------------------------------- ;; Below this point are procedure definitions that have to do with "walls," which ;; the user may create in order to separate groups of turtles from one another. ;; The use of walls is optional, and can be seen as a more advanced topic. ;; --------------------------------------------------------------------------------- to place-wall if mouse-down? [ ;; Note that when we place a wall, we must also place walls ;; at the world boundaries, so turtles can't change rooms ;; by wrapping around the edge of the world. ask patches with [abs pycor = max-pycor or pycor = round mouse-ycor] [ ;set pcolor white set pcolor white ;; There might be some turtles standing where the ;; new walls is, so we need to move them into a room. ask turtles-here [ move-off-wall ] ] set wall-list insert-item 1 wall-list round mouse-ycor set wall-list remove-duplicates wall-list set wall-list sort wall-list display ] end to remove-wall if mouse-down? [ ask patches with [pycor = round mouse-ycor] [ set pcolor black ] ;; if only 1 wall in wall-list remove-all (+ boundaries) if length wall-list = 3 [ remove-all-walls ] ;; remove wall from list set wall-list remove round mouse-ycor wall-list display ] end to remove-all-walls clear-patches set wall-list (list min-pycor max-pycor) end to move-off-wall ;; turtle procedure while [pcolor != black] [ move-to one-of neighbors ] end ; Copyright 1997 Uri Wilensky. ; See Info tab for full copyright and license.
There is only one version of this model, created about 6 years ago by Juan Jose Garcia Mesa.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.