{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## (📗) Cookbook: `ipyrad.analysis.baba` \n", "\n", "This notebook demonstrates how to use the `baba` module in `ipyrad` to test for admixture and introgression. The code is written in Python and is best implemented in a Jupyter-notebook like this one. Analyses can be split up among many computing cores. Finally, there are some simple plotting methods to accompany tests which I show below. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### import packages" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " ipyrad v.0.5.15\n", " ipyparallel v.5.2.0\n", " numpy v.1.11.2\n" ] } ], "source": [ "## imports\n", "import numpy as np\n", "import ipyrad as ip\n", "import ipyrad.analysis.baba as baba\n", "import ipyparallel as ipp\n", "\n", "## print versions\n", "print \" ipyrad v.{}\".format(ip.__version__)\n", "print \" ipyparallel v.{}\".format(ipp.__version__)\n", "print \" numpy v.{}\".format(np.__version__)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ipcluster setup to run parallel code\n", "You can find more details about this in our [ipyparallel tutorial]." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## start 4 engines by running the commented line below in a separate bash terminal. \n", "##\n", "## ipcluster start --n=4" ] }, { "cell_type": "code", "execution_count": 57, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " host compute node: [4 cores] on oud\n" ] } ], "source": [ "## connect to client and print connection summary\n", "ipyclient = ipp.Client()\n", "print ip.cluster_info(client=ipyclient)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get default (example) 12 taxon tree \n", "The function `baba.Tree()` takes a `newick` string as an argument, or, if no value is passed, it constructs the default 12 taxon tree shown below. The `Tree` Class object holds a representation of the tree, which can be used for plotting, as well as for describing a demographic model for simulating data, as we'll show below. " ] }, { "cell_type": "code", "execution_count": 58, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "