A selection-vs-drift version of Weasel

In his endless pursuit of that wascally Weasel, Mung made the following silly claim:

GAs are often used to demonstrate “the power of cumulative selection.” Given small population sizes drift ought to dominate yet in GAs drift does not dominate.

That is clearly false, but for the benefit of Mung (and his cousin Elmer) I have modified my Weasel program to incorporate both drift and selection.  They can now see for themselves that small population sizes are insufficient to guarantee that drift dominates selection.

The code is here. Compile it under Linux using “gcc -std=gnu99 -lm weasel.c -o weasel”.

Run the program and type ‘h’ to see a list of interactive commands:

c – clear the histogram data
f – change the selection coefficient
h – print this help message
m – change the mutation rate
p – pause until a key is pressed
q – quit the program
s – toggle selection on/off
t – change the target phrase

The program generates and updates a scaled histogram showing the number of generations spent at each possible Hamming distance from the target.

222 thoughts on “A selection-vs-drift version of Weasel

  1. Mung: in small populations, the stochastic effects of random genetic drift overcome the effects of selection.

    Yes, it has been known since about 1930 that genetic drift in small populations can make selection ineffective. Lots of work, lots of interesting population genetic theory on that.

    Keith’s program can be used to investigate that, as it has parameters for the number of survivors and for the strength of selection.

    So who is it that is supposed to retract their statements?

  2. Joe Felsenstein: Keith’s program can be used to investigate that, as it has parameters for the number of survivors and for the strength of selection.

    Does the model in Mung’s “silver bullet” study apply to the system that Keith has implemented?

  3. Mung,

    But we already knew from your original program that drift did not dominate even with an effective population size of 1.

    Sure, but you claimed that drift ought to dominate, which is incorrect:

    GAs are often used to demonstrate “the power of cumulative selection.” Given small population sizes drift ought to dominate yet in GAs drift does not dominate.

    Mung:

    And you apparently didn’t read the material I referenced in my original OP.

    Not only did I read it, I quoted it at length in an effort to pinpoint the source of your confusion:

    I think I’ve identified the source of Mung’s confusion. He seems to have focused on this sentence from the Nature article:

    In other words, in small populations, the stochastic effects of random genetic drift overcome the effects of selection.

    Since Mung doesn’t understand GAs or evolution, he read that statement uncritically and literally. It’s reflected in these claims of his:

    Given small population sizes drift ought to dominate yet in GAs drift does not dominate.

    And:

    Given an effective population size of one, drift ought to dominate, but it doesn’t.

    But it isn’t population size alone that allows drift to overpower selection. The selection coefficient also matters, as the Nature article makes clear:

    It is important to note that the effectiveness of selection on a mutation depends both on the fitness effect of this mutation (the selection coefficient s) and on the effective population size (Ne). Specifically, when the product Ne * s is much less than 1, the fate of mutations is essentially determined by random genetic drift. In other words, in small populations, the stochastic effects of random genetic drift overcome the effects of selection. Thus, all mutations for which Ne * s is much less than 1 can be considered effectively neutral.

    Mung seems to have realized that the selection coefficient matters, as the Nature article stresses. He wrote:

    Given an effective population size of one, what must the selection coefficient be for drift to not dominate selection?

    Yet he went ahead and made his categorical statements despite having no inkling of the actual value of the selection coefficient.

    Typical Mung sloppiness.

    Mung:

    I’m sure they will be happy to post a retraction if you ask nicely.

    Why should they? It was your mistake, not theirs.

  4. Found a bug by inspection:

    This code…

    // adjust the total fitness to reflect only the remaining offspring
    total_fitness -= genome_array[j].fitness;

    …should be…

    // adjust the total fitness to reflect only the remaining offspring
    total_fitness -= genome_array[i].fitness;

    …because of the swap that occurs just above:

    // swap it with the one in the survivor slot
    swap_genomes(i,j);

    The bug will manifest only when the number of survivors is greater than one. Otherwise total_fitness is recomputed before it is used again.

    The fixed code is here.

    Compile under Linux with “gcc -std=gnu99 -lm weasel.c -o weasel”.

  5. petrushka,

    Perhaps someone can enlighten me as to whether selection coefficient remains constant in biology.

    Not really. It’s an abstraction which helps make problems more tractable. Given the textual result of Darwin that traits helping their bearers will increase in the population, relative rates of increase can be represented as a compounded exponent.

    In reality, environments aren’t that homogeneous, either temporally or spatially. But one still gets a handle on tendencies, and the factors that affect strength and direction.

    It seems to me that if a deleterious mutation becomes more prevalent in a small population, the relative advantage of non carriers increases. Wouldn’t selection advantage vary?

    Not in that scenario. The advantageous mutation is also operating in a small population. It’s been squeezed into the margins by drift; this does not make it more likely to resist further squeezing, and its rarity makes drift more likely.

    One could look at the situation where a novel advantageous mutation arises in single copy. Such single copies don’t have more selective advantage than the same allele in multiple copy – they don’t spread more strongly when rare. But this is exactly the same as your advantageous allele that has been pushed to the brink. Becoming rarer does not in itself change the exponent, but it does make it more likely that the tails of the distribution will be visited (in a probabilistic model), and the long-run mean will be obscured.

  6. Petrushka:

    Perhaps someone can enlighten me as to whether selection coefficient remains constant in biology.

    No. 🙂

    One case that is poignant — density dependent selection

    http://evolutionwiki.org/wiki/Density-dependent_selection

    Density-dependent selection occurs when the fitness value of a trait depends upon the density of the population.

    For example, in high density situations large seed size in plants tend to be favored, whereas in low density habitats, large seed size may be a disadvantage (Winn and Miller, 1995).

    Density-dependent selection is often mentioned in the same breath as frequency-dependent selection.

    Beyond that environmental changes.

    Additionally, I mentioned the issue of auto renomalization to the best of the bad. That is suppose the trait with the best S-coefficient and the defacto standard accidentally dies from the population (drifts out). Now we usually to re adjust the S-coefficients to some other standard among the living.

    For example, supposing we did indeed evolve from some bacterium that is now extinct. it makes little sense to set the S-coefficient (which represents a relative fitness relation) to the extinct bacteria, we have to set it to some standard of an existing population.

    So the S-coefficient is a bit of a floating variable, not a truly or approximately conserved or invariant quantity like one might find in a physical system (like say mass of all the reactants vs mass of the products after a chemical reaction).

  7. I think you are going for frequency dependent selection rather than density dependent. Anyway, I will defer to the experts here. Your wiki article is remarkably vague.

    But I guess I’m not the first to wonder.

  8. Keiths, I’m going to try your modifications. I would appreciate it if you would put a revision date at the top of your code.

  9. I included conio.h, and removed or commented out all the code that caused errors.

    It now compiles and runs, but the entry of new values doesn’t work. I can get it to request the new values, but it doesn’t restart. I suppose that’s what you get when you mess with the i/o.

  10. Petrushka:

    I guess I’m not the first to wonder.

    Always nice to see critical thinking in action.

  11. Sal, how’s your program coming along?

    I’m having trouble finding the thread where we tested it.

  12. keiths: Sure, but you claimed that drift ought to dominate, which is incorrect:

    Genetic drift ought to dominate selection in small populations, as my cited source says. All you have done is create an artificial scenario in which it is shown to not necessarily be the case. Again, I congratulate you.

    You are being unnecessarily tendentious. In my original OP I recognized the fact that drift did not dominate in your GA and asked why that was the case.

    You have failed to demonstrate that drift ought not overcome the effects of selection in small populations. Until then, you have not demonstrated that it is false that drift ought to overcome the effects of selection in small populations..

    “…in small populations, the stochastic effects of random genetic drift overcome the effects of selection.”

    They state this as a fact.

  13. Sal, how’s your program coming along?

    I’m having trouble finding the thread where we tested it.

    I stopped since Keiths is leading the charge with his bug-free weasel.

  14. stcordova: I stopped since Keiths is leading the charge with his bug-free weasel.

    Since you have stopped developing, I assume you accept his design and his results.

  15. petrushka,

    Keiths, I’m going to try your modifications. I would appreciate it if you would put a revision date at the top of your code.

    Good idea. I’ll do that.

    I included conio.h, and removed or commented out all the code that caused errors.

    It now compiles and runs, but the entry of new values doesn’t work. I can get it to request the new values, but it doesn’t restart. I suppose that’s what you get when you mess with the i/o.

    Try replacing the ‘\r’ with ‘\n’ in this line:

    } while (buffer[i-1] != ‘\r’); // accumulate characters in buffer until CR

  16. Good grief, Mung.

    You were wrong again. No one is surprised. Get over it.

    You got a little too excited by this sentence…

    In other words, in small populations, the stochastic effects of random genetic drift overcome the effects of selection.

    …and you didn’t register the importance of the sentences on either side of it:

    It is important to note that the effectiveness of selection on a mutation depends both on the fitness effect of this mutation (the selection coefficient s) and on the effective population size (Ne). Specifically, when the product Ne * s is much less than 1, the fate of mutations is essentially determined by random genetic drift. In other words, in small populations, the stochastic effects of random genetic drift overcome the effects of selection. Thus, all mutations for which Ne * s is much less than 1 can be considered effectively neutral.

    They got it right. You didn’t:

    Given small population sizes drift ought to dominate yet in GAs drift does not dominate.

    And:

    Given an effective population size of one, drift ought to dominate, but it doesn’t.

    Yes, Elmer, it’s embarrassing that you’ve now launched two failed threads against that wascally Weasel. Think before posting next time.

  17. Unlike the professional Liars for God, the rank-and-file (crypto-)creationists do not understand that quote mining is fallacious. They read scientific papers pretty much as they do the Bible, which is to say, quite poorly.

  18. keiths,

    That’s a fine explication of a quote mine. I really don’t think creationists intend to quote mine; it’s just the god goggles at work, preventing them from seeing anything to either side of the bright, shiny quote they want.

  19. Unlike professional liars for evolutionism, rational people understand that “weasel” does not simulate natural selection and has nothing to do with stochastic processes.

  20. Frankie:
    Unlike professional liars for evolutionism, rational people understand that “weasel” does not simulate natural selection and has nothing to do with stochastic processes.

    As a “professional liar for evolution” (according to Frankie), let me just point out that Weasel programs are stochastic processes, namely processes that have a random part. They simulate strong natural selection, mutation and genetic drift. That may not be enough for Frankie, to consider them as not simulating evolution. But there is no accounting for taste. Setting Frankie’s high standards aside, we can see that Weasel is an excellent demonstration of how the nonrandom phenomenon of natural selection works dramatically differently from pure chance.

  21. I have a good working DOS/Windows version of keiths’ program.

    I have the c source code that will compile with lcc (and probably any compiler that supports conio.h and tcconio.h).

    I have a 32 bit executable.

    What’s the best way to make them available? I can upload the source to a txt file, but I don’t know how to make the exe available.

  22. I get a bit of weirdness when everything is weaseled.

    Target Phrase: METHINKS IT IS LIKE A WEASEL
    Generation: 7030
    Selection: ON Coefficient: 10.00 Mutation rate: 0.01
    Organism 0 Fitness 1.44e+029 Hamming distance 0

    METHINKS IT IS LIKE A WEASEL
    Histogram of Hamming distances:
    0: 1372205943417472290 X
    1: 864712057832081664
    2: 366761898949282569
    3: 201659137
    4: 5043221769202206625 X
    5: 28
    6: 13
    7: 12
    8: 17
    9: 18

  23. Joe Felsenstein: As a “professional liar for evolution” (according to Frankie), let me just point out that Weasel programs are stochastic processes, namely processes that have a random part.They simulate strong natural selection, mutation and genetic drift.That may not be enough for Frankie, to consider them as not simulating evolution.But there is no accounting for taste.Setting Frankie’s high standards aside, we can see that Weasel is an excellent demonstration of how the nonrandom phenomenon of natural selection works dramatically differently from pure chance.

    They do not simulate natural selection at all, Joe. NS is not a search heuristic actively searching for a pre-specified target. OTOH weasel is a search heuristic actively searching for a pre-specified target.

    As for natural selection and pure chance, well NS is non-random in a very trivial way, ie not all variations have the same chance of being eliminated. It is all whatever is good enough, ie contingent serendipity.

    So thank you, Joe, for proving my point

  24. petrushka,

    I get a bit of weirdness when everything is weaseled.

    That might be because your version still has this bug.

    Could you post the code to pastebin.com? (No registration required.) Once you’ve done that, I’ll diff it against my latest and #ifdef the differences so that we can both compile from the same source file.

  25. petrushka,

    I’m not sure the histogram is being reset when you change the target.

    It isn’t, and that’s intentional. The histogram is cleared only when the user deliberately does so using the ‘c’ command.

  26. I sent a link in a message

    As I recall, I added conio.h and changed the functions to clear the screen and home the cursor.

    The rest is just deletions of your unix specific i/o code.

    I’m pretty sure I got your bug fix included.

  27. petrushka,

    I sent a link in a message

    As I recall, I added conio.h and changed the functions to clear the screen and home the cursor.

    The rest is just deletions of your unix specific i/o code.

    Thanks. I’ve folded the changes into my source code.

    I’m pretty sure I got your bug fix included.

    It was there in your latest, but not in the version you sent me earlier via PM. Let me know if you see that histogram weirdness after compiling my new code, which I’ll post soon.

  28. John Harshman:

    I really don’t think creationists intend to quote mine; it’s just the god goggles at work, preventing them from seeing anything to either side of the bright, shiny quote they want.

    I imagine “god goggles” looking something like this, only invisible:

  29. Let me see if I have this correct.

    In the paper I cite, the authors write:

    “…in small populations, the stochastic effects of random genetic drift overcome the effects of selection.”

    keiths claims this is false. Apparently the argument is that I have “quote-mined” the authors and that the authors claim the exact opposite to be the case in the sentences to either side.

    The statement I quoted summarizes what came before it. To claim it contradicts what came before it is gratuitous nonsense.

    In other words, in small populations, the stochastic effects of random genetic drift overcome the effects of selection.

    To establish that what I wrote was false, as you assert, would require that you demonstrate that it is not the case that in small populations drift ought to overcome the effects of selection. Sadly, you have not even begun to make that case and have resorted to insults.

    If it helps you to get over it, I apologize for insulting your silly program and claiming that it is biologically unrealistic, what with it killing off all members of the population but one and reconstructing the new generation from one single member.

    No doubt you’ll prove me wrong about that too by citing numerous papers where it is demonstrated that killing off all but one member of a population and then regenerating the entire new population from that one member is biologically realistic.

    It seems we struck a nerve.

  30. keiths: You’re not fooling anyone, Mung.

    Perhaps not. But it beats your approach hands down. So for now I’ll stick with what I am doing.

    I’m sort of hoping that you’ll repeat what you did in the Top-Down Causation thread. Just claim that I’m too stupid to understand and have nothing more to do with me. Please.

    By the way, I haven’t even tried yet to come up with additional support for my claim, but I’m certain it’s out there.

    As for you, do let us know when you can defend your claim that in small populations the stochastic effects of random genetic drift ought not overcome the effects of selection.. For my claim to be false, that’s what is required from you.

    Prediction: It won’t happen, because you can’t.

  31. Frankie: Neither are you, keiths.

    You forget where you are. This is TSZ. Just look at how quickly and easily people jumped on the “quote-mining” bandwagon, even though I made clear from my original OP the source for my position.

  32. In small, reproductively isolated populations, special circumstances exist that can produce rapid changes in gene frequencies totally independent of mutation and natural selection. These changes are due solely to chance factors. The smaller the population, the more susceptible it is to such random changes. This phenomenon is known as genetic drift.

    In order to get a better understanding of the potential effect of population size on evolution, it is useful to carry out a simple coin flipping experiment.

    Small Population Size Effects: Genetic Drift

    keiths: You’re not fooling anyone, Mung.

    And you don’t have a snowball’s chance in hell of demonstrating that my claim was false. I don’t need to fool anyone. You do.

  33. Poor Mung. His own source contradicts him.

    Mung:

    Given small population sizes drift ought to dominate yet in GAs drift does not dominate.

    And:

    Given an effective population size of one, drift ought to dominate, but it doesn’t.

    The Nature article Mung linked to:

    It is important to note that the effectiveness of selection on a mutation depends both on the fitness effect of this mutation (the selection coefficient s) and on the effective population size (Ne). Specifically, when the product Ne * s is much less than 1, the fate of mutations is essentially determined by random genetic drift.

    They’re right, Mung. You aren’t.

    Learn from your mistake.

  34. Mung,

    The sentence that you are hanging your hat on – “In other words, in small populations, the stochastic effects of random genetic drift overcome the effects of selection. ” – is an over-simplification of the preceding sentence. Quoting it in isolation is a quote-mine.
    I mean, really, what part of “Specifically, when the product Ne * s is much less than 1, the fate of mutations is essentially determined by random genetic drift.” do you not understand?
    The asterisk, “*”, denotes the multiplication operator; “product”, as used here, is a technical term that refers to the result of multiplication.

  35. keiths: They’re right, Mung. You aren’t.

    Let’s create a computer model that demonstrates that the smaller the population, the more susceptible it is to such random changes. If we can create such a model, then you haven’t demonstrated that my claim is false.

    Do you think it’s not possible to create such a model?

  36. Mung: Let’s create a computer model that demonstrates that the smaller the population, the more susceptible it is to such random changes. If we can create such a model, then you haven’t demonstrated that my claim is false.

    Do you think it’s not possible to create such a model?

    ??? Huh? My algebra might be rusty, but if we pin s to some fixed value and keep reducing Ne, then the product Ne * s will also be reduced. And the smaller the product, the smaller the selection component. Is this correct?

  37. DNA_Jock: The sentence that you are hanging your hat on – “In other words, in small populations, the stochastic effects of random genetic drift overcome the effects of selection. ” – is an over-simplification of the preceding sentence. Quoting it in isolation is a quote-mine.

    As my argument and recent quotes from other sources indicate, I am not “hanging my hat” on that one sentence. I am “hanging my hat” on the fact that keiths cannot demonstrate empirically that the statement I made is in fact false, which is what he claimed.

    Even if we assume that their summary, introduced by their use of “in other words,” actually over-simplifies that which came before it, it does not follow that it is false, it does not follow that it contradicts what came before, it does not follow that it is a “quote-mine”, and it does not follow that my claim was false.

    keiths is hanging his hat on the position that my claim was a quote-mine, that it is somehow contradicted by something else the authors wrote, and that he can in fact demonstrate empirically that my claim is false. That’s a tall order, even for keiths.

    DNA_Jock: I mean, really, what part of “Specifically, when the product Ne * s is much less than 1, the fate of mutations is essentially determined by random genetic drift.” do you not understand?

    The part where it is contradicted by the statement that follows, the statement that you claim is a quote-mine.

  38. Mung:

    I’m right, because this sentence from the Nature article backs me up.

    Onlookers:

    What about the preceding and following sentences, which contradict you?

    Mung:

    Pay no attention to those. The author is an idiot.

  39. The original version of ks-weasel had a default population size of 200.
    #define POPULATION_SIZE 200 // total population size

    The new version of ks-drift-weasel has a default population size of 50000.
    #define POPULATION_SIZE 50000 // total population size

    Given that there is no change to the effective population size, what was the point of changing the default value for the population size?

  40. Mung,

    Given that there is no change to the effective population size, what was the point of changing the default value for the population size?

    To approximate a Wright-Fisher scenario. See this comment by Joe.

  41. # ks-drift-weasel
    # define SELECTION_COEFF 5.0 // selection coefficient

    Not present in kf-weasel. Given how important s is to the claims keiths has been making, why not? But once again, keiths blazes his own trail.

    In population genetics, the selection coefficient is a measure of the relative fitness of a phenotype. Usually denoted by the letter s, it compares the fitness of a phenotype to another favored phenotype, and is the proportional amount that the considered phenotype is less fit as measured by fertile progeny. s = 0 then is selectively neutral compared to the favored phenotype, while s = 1 indicates complete lethality. For example, if the favored phenotype produces 100 fertile progeny, and only 90 are produced by the phenotype selected against then s = 0.1. An alternative way of expressing this is to describe the fitness of the favored phenotype as 1.0 and that of the phenotype selected against as 0.9.

    If s=1 indicates complete lethality what does s=5 indicate? 5x deader than dead?

    The coefficient of selection is usually taken to be a measure of the extent to which natural selection is acting to reduce the relative contribution of a given genotype to the next generation.

    Denoted as s, the selection coefficient is a number between zero and one. If s = 1, selection against the genotype is total, and it makes no contribution to the next generation.

    5x dead.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.