{ "metadata": { "name": "hw6-the evolutionary origin of complex features.ipynb" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#The evolutionary origin of complex features\n", "\n", "###Materials by Randal S. Olson\n", "\n", "This entire notebook is licensed under a Creative Commons Attribution 3.0 Unported License.\n", "\n", "\"Creative\n", "\n", " 
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this 2003 paper, Richard Lenski et al. explored one of the most pressing questions in evolutionary theory: How do complex traits evolve?\n", "\n", ">Charles Darwin\u2019s theory of evolution, including its intertwined hypotheses of descent with modification and adaptation by natural selection, is widely regarded as one of the greatest scientific achievements of all time. From the outset, Darwin realized that \u201corgans of extreme perfection and complication\u201d, such as the eye, posed a difficulty for his theory. Such features are much too complex to appear de novo, and he reasoned that they must evolve by incremental transitions through many intermediate states, sometimes undergoing changes in function. There now exists substantial evidence concerning the evolution of complex features that supports Darwin\u2019s general model. Nonetheless, it is difficult to provide a complete account of the origin of any complex feature owing to the extinction of intermediate forms, imperfection of the fossil record, and incomplete knowledge of the genetic and developmental mechanisms that produce such features.\n", " \n", "The paper is free to download here: [http://myxo.css.msu.edu/papers/nature2003/Nature03_Complex.pdf](http://myxo.css.msu.edu/papers/nature2003/Nature03_Complex.pdf)\n", " \n", "Digital evolution is a powerful tool for studying populations as they evolve. In this study, Lenski et al. used the digital evolution platform [Avida](http://avida.devosoft.org/) to study the evolution of a specific complex feature in the populations.\n", "\n", "In this section, we're going to familiarize ourselves with Avida and retrace the steps of Lenski et al. in the complex features experiment." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##How to use Avida\n", "\n", "###Download and build Avida\n", " \n", "Before you can build Avida, you need to install CMake on the EC2 node:\n", "\n", " wget http://www.cmake.org/files/v2.8/cmake-2.8.12.tar.gz\n", " tar zxvf cmake-2.8.12.tar.gz\n", " cd cmake-2.8.12/\n", " ./bootstrap\n", " make\n", " make install\n", " cd ~/\n", " \n", "Download the latest zipped source code, unzip the file, and navigate into the base Avida directory on the command line.\n", "\n", " wget http://downloads.sourceforge.net/project/avida/avida-stable/2.12.4/avida-2.12.4-src.zip\n", " unzip avida-2.12.4-src.zip\n", " cd avida-2.12.4-src/\n", "\n", "To build Avida, just use the build Avida command:\n", " \n", " ./build_avida\n", " \n", "It may take up to a few minutes to fully build Avida. The build program will keep you updated while it builds.\n", "\n", "Once everything is built, navigate into the `~/avida-2.12.4-src/cbuild/work` directory. This directory contains several important Avida components, explained below.\n", "\n", "###Avida components\n", "\n", "* **avida**: The \"headless\" (i.e., no visual interface) version of the Avida executable.\n", "* **avida-viewer**: The version of the Avida executable with a visual interface.\n", "* **analyze.cfg**: The default file used to write analysis scripts.\n", "* **avida.cfg**: This is the main configuration file that is used by default.\n", "* **environment.cfg**: This file contains the default environment information.\n", "* **events.cfg**: This file contains the default event list.\n", "* **inst_set.default**: This is the main, heads-based instruction set that is used by\tdefault.\n", "* **organism.default**: This file contains the default starting ancestor of length 100.\n", "* **data/**: This is the name of the default output directory and is created by Avida if it does not exist. The name and location of this directory can be configured in avida.cfg. WARNING: All data from previous runs will be overwritten if you do not have Avida output to another directory in your latest run.\n", " \n", "For the most part, we will only be working with the `avida-viewer` executable and the `environment.cfg` configuration file.\n", "\n", "###Setting up an experiment\n", "\n", "The first step in an Avida experiment is setting up the `avida.cfg` file. To replicate the complex features experiments, we need to change a few of the default settings. Find and change the following settings:\n", "\n", "* `COPY_MUT_PROB` and change it to `0.0025`\n", "\n", "See the [configuration file documentation](http://devolab.cse.msu.edu/software/avida/doc/config.html) for more information about the Avida configuration file.\n", "\n", "These experiments also require us to edit the `environment.cfg` file. Open this file and you should see the following:\n", " \n", ">REACTION NOT not process:value=1.0:type=pow requisite:max_count=1\n", " \n", ">REACTION NAND nand process:value=1.0:type=pow requisite:max_count=1\n", " \n", ">REACTION AND and process:value=2.0:type=pow requisite:max_count=1\n", " \n", ">REACTION ORN orn process:value=2.0:type=pow requisite:max_count=1\n", " \n", ">REACTION OR or process:value=3.0:type=pow requisite:max_count=1\n", " \n", ">REACTION ANDN andn process:value=3.0:type=pow requisite:max_count=1\n", " \n", ">REACTION NOR nor process:value=4.0:type=pow requisite:max_count=1\n", " \n", ">REACTION XOR xor process:value=4.0:type=pow requisite:max_count=1\n", " \n", ">REACTION EQU equ process:value=5.0:type=pow requisite:max_count=1\n", "\n", "Each `REACTION` line specifies a logic task, such as `NOT`, that a digital organism can perform to receive merit. This process is akin to an organism metabolizing a resource and thus receiving energy from it. The more merit a digital organism receives, the more energy it has to perform other tasks during its lifetime, such as replicating itself.\n", "\n", "`process:value=2.0:type=pow` specifies how much merit the digital organism receives for performing that task. In this case, the digital organism receives $2^2$ merit for performing the task. See the Avida environment documentation for more settings: [http://devolab.cse.msu.edu/software/avida/doc/environment.html](http://devolab.cse.msu.edu/software/avida/doc/environment.html)\n", " \n", "Finally, `requisite:max_count=1` specifies the maximum number of times a digital organism can perform the task in its lifetime.\n", "\n", "##Homework\n", "\n", "In this homework, we will repeat the experiments that Lenski et al. performed to study the evolutionary origin of complex traits. Here, the complex trait is the `EQU` task, which is the most difficult task that digital organisms can perform in Avida. Conveniently, `EQU` can be performed by combining a sequence of simpler logic tasks. Thus, `EQU` is akin to a complex trait that is composed of simpler, seemingly unrelated traits.\n", "\n", "1) The first experiment only rewarded digital organisms for performing the `EQU` task. Modify `environment.cfg` to reflect this setting by removing all of the `REACTION` lines except the `EQU` reaction. The file should look like this:\n", " \n", ">REACTION NOT not process:value=0.0:type=add requisite:max_count=1\n", " \n", ">REACTION NAND nand process:value=0.0:type=add requisite:max_count=1\n", " \n", ">REACTION AND and process:value=0.0:type=add requisite:max_count=1\n", " \n", ">REACTION ORN orn process:value=0.0:type=add requisite:max_count=1\n", " \n", ">REACTION OR or process:value=0.0:type=add requisite:max_count=1\n", " \n", ">REACTION ANDN andn process:value=0.0:type=add requisite:max_count=1\n", " \n", ">REACTION NOR nor process:value=0.0:type=add requisite:max_count=1\n", " \n", ">REACTION XOR xor process:value=0.0:type=add requisite:max_count=1\n", " \n", ">REACTION EQU equ process:value=5.0:type=pow requisite:max_count=1\n", " \n", "Now, run Avida in visualization mode by entering `./avida-viewer` in the command line. Watch the population evolve for 100,000 updates. If you press `S`, you can see what tasks the digital organisms are currently performing. Press `M` to return to the map view.\n", "\n", "Do any of the digital organisms evolve to perform the `EQU` task? Why or why not? What happens when you repeat the experiment a few more times?\n", "\n", "2) The second experiment rewarded the digital organisms for performing any of the tasks. Modify `environment.cfg` to reflect this setting by adding back all of the `REACTION` lines. The file should look like this:\n", " \n", ">REACTION NOT not process:value=1.0:type=pow requisite:max_count=1\n", " \n", ">REACTION NAND nand process:value=1.0:type=pow requisite:max_count=1\n", " \n", ">REACTION AND and process:value=2.0:type=pow requisite:max_count=1\n", " \n", ">REACTION ORN orn process:value=2.0:type=pow requisite:max_count=1\n", " \n", ">REACTION OR or process:value=3.0:type=pow requisite:max_count=1\n", " \n", ">REACTION ANDN andn process:value=3.0:type=pow requisite:max_count=1\n", " \n", ">REACTION NOR nor process:value=4.0:type=pow requisite:max_count=1\n", " \n", ">REACTION XOR xor process:value=4.0:type=pow requisite:max_count=1\n", " \n", ">REACTION EQU equ process:value=5.0:type=pow requisite:max_count=1\n", " \n", "Again run Avida in visualization mode by entering `./avida-viewer` in the command line. Do any of the digital organisms evolve to perform the `EQU` task after 100,000 updates? What happens when you repeat the experiment a few more times?\n", "\n", "3) What do the results from #1 and #2 imply for the evolution of complex features?\n", "\n", "4) For one of the runs that had a digital organism evolve to perform the `EQU` task, plot the task performance of the population over time. The tasks performance is stored in `data/tasks.dat`. Did certain tasks evolve before other tasks? If you repeat this several times, does it seem like certain tasks must evolve before the `EQU` task?\n", "\n", "5) For one of the runs that had a digital organism evolve to perform the `EQU` task, plot the average fitness of the population over time. The average fitness is stored in `data/average.dat`. Can you tell when certain tasks evolved by looking at the average fitness plot?" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }