{ "cells": [ { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## (📗) Cookbook: `ipyrad.analysis simulations` \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": { "deletable": true, "editable": true }, "source": [ "### import packages" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ipyrad v.0.6.11\n", "ipyparallel v.6.0.2\n", "numpy v.1.12.0\n" ] } ], "source": [ "## imports\n", "import numpy as np\n", "import ipyrad as ip\n", "import ipyparallel as ipp\n", "from ipyrad.analysis import baba\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": { "deletable": true, "editable": true }, "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, "deletable": true, "editable": 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": 3, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "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": { "deletable": true, "editable": true }, "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": 4, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tre.draw(width=400, height=200);" ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [ "## tree2dict \n", "import ete3\n", "newick = \"./analysis_tetrad/pedtest1.full.tre\"\n", "## load the newick string as a Tree object\n", "tre = ete3.Tree(newick)\n", "\n", "## set przewalskiis as the outgroup\n", "prz = [i for i in tre.get_leaves() if \"prz\" in i.name]\n", "out = tre.get_common_ancestor(prz)\n", "\n", "## set new outgroup and store back as a newick string\n", "tre.set_outgroup(out)\n", "newick = tre.write()\n", "\n", "\n", "def test_constraint(node, cdict, tip, exact):\n", " names = set(node.get_leaf_names())\n", " const = set(cdict[tip])\n", " if const:\n", " if exact:\n", " if len(names.intersection(const)) == len(const):\n", " return 1\n", " else:\n", " return 0\n", " else:\n", " if len(names.intersection(const)) == len(names):\n", " return 1\n", " else:\n", " return 0 \n", " return 1\n", " " ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "{'p1': [], 'p2': [], 'p3': [], 'p4': ['a']}" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "## constraints\n", "#if not constraint_dict:\n", "cdict = {\"p1\":[], \"p2\":[], \"p3\":[], \"p4\":[]}\n", "cdict.update({\"p4\":['a']})\n", "\n", "cdict" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "def tree2tests(newick, constraint_dict=None, constraint_exact=True):\n", " \"\"\"\n", " Returns dict of all possible four-taxon splits in a tree. Assumes\n", " the user has entered a rooted tree. Skips polytomies.\n", " \"\"\"\n", " ## make tree\n", " tree = ete3.Tree(newick)\n", " \n", " ## constraints\n", " #if not constraint_dict:\n", " cdict = {\"p1\":[], \"p2\":[], \"p3\":[], \"p4\":[]}\n", " cdict.update(constraint_dict)\n", " print cdict\n", "\n", " ## traverse root to tips. Treat the left as outgroup, then the right.\n", " tests = []\n", " ## topnode must have children\n", " for topnode in tree.traverse(\"levelorder\"): \n", " ## test onode as either child\n", " for oparent in topnode.children:\n", " ## test outgroup as all descendants on one child branch\n", " for onode in oparent.traverse():\n", " ## put constraints on onode\n", " if test_constraint(onode, cdict, \"p4\", constraint_exact):\n", " ## p123 parent is sister to oparent\n", " p123parent = oparent.get_sisters()[0]\n", " ## test p3 as all descendants of p123parent\n", " for p3parent in p123parent.children:\n", " ## p12 parent is sister to p3parent\n", " p12parent = p3parent.get_sisters()[0]\n", " for p3node in p3parent.traverse():\n", " if test_constraint(p3node, cdict, \"p3\", constraint_exact):\n", " if p12parent.children:\n", " p1parent, p2parent = p12parent.children\n", " for p2node in p2parent.traverse():\n", " if test_constraint(p2node, cdict, \"p2\", constraint_exact):\n", " for p1node in p1parent.traverse():\n", " if test_constraint(p1node, cdict, \"p1\", constraint_exact):\n", " test = {}\n", " test['p4'] = onode.get_leaf_names()\n", " test['p3'] = p3node.get_leaf_names()\n", " test['p2'] = p2node.get_leaf_names()\n", " test['p1'] = p1node.get_leaf_names()\n", " tests.append(test)\n", " return tests" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'p2': [], 'p3': ['30686_cyathophylla'], 'p1': [], 'p4': ['32082_przewalskii', '33588_przewalskii']}\n" ] }, { "data": { "text/plain": [ "33" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ " \n", "tests = tree2tests(newick, \n", " constraint_dict={\"p4\":['32082_przewalskii', '33588_przewalskii'], \n", " \"p3\":['30686_cyathophylla']}, \n", " constraint_exact=True)\n", "len(tests)" ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "[{'p1': ['38362_rex',\n", " '39618_rex',\n", " '35855_rex',\n", " '40578_rex',\n", " '30556_thamno',\n", " '35236_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba',\n", " '30686_cyathophylla',\n", " '41478_cyathophylloides',\n", " '41954_cyathophylloides'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['38362_rex', '39618_rex', '35855_rex', '40578_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba',\n", " '30686_cyathophylla',\n", " '41478_cyathophylloides',\n", " '41954_cyathophylloides'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['30556_thamno', '35236_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba',\n", " '30686_cyathophylla',\n", " '41478_cyathophylloides',\n", " '41954_cyathophylloides'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['38362_rex', '39618_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba',\n", " '30686_cyathophylla',\n", " '41478_cyathophylloides',\n", " '41954_cyathophylloides'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['35855_rex', '40578_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba',\n", " '30686_cyathophylla',\n", " '41478_cyathophylloides',\n", " '41954_cyathophylloides'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['30556_thamno'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba',\n", " '30686_cyathophylla',\n", " '41478_cyathophylloides',\n", " '41954_cyathophylloides'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['35236_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba',\n", " '30686_cyathophylla',\n", " '41478_cyathophylloides',\n", " '41954_cyathophylloides'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['38362_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba',\n", " '30686_cyathophylla',\n", " '41478_cyathophylloides',\n", " '41954_cyathophylloides'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['39618_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba',\n", " '30686_cyathophylla',\n", " '41478_cyathophylloides',\n", " '41954_cyathophylloides'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['35855_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba',\n", " '30686_cyathophylla',\n", " '41478_cyathophylloides',\n", " '41954_cyathophylloides'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['40578_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba',\n", " '30686_cyathophylla',\n", " '41478_cyathophylloides',\n", " '41954_cyathophylloides'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['38362_rex',\n", " '39618_rex',\n", " '35855_rex',\n", " '40578_rex',\n", " '30556_thamno',\n", " '35236_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba', '30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['38362_rex', '39618_rex', '35855_rex', '40578_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba', '30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['30556_thamno', '35236_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba', '30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['38362_rex', '39618_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba', '30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['35855_rex', '40578_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba', '30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['30556_thamno'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba', '30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['35236_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba', '30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['38362_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba', '30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['39618_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba', '30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['35855_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba', '30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['40578_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['29154_superba', '30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['38362_rex',\n", " '39618_rex',\n", " '35855_rex',\n", " '40578_rex',\n", " '30556_thamno',\n", " '35236_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['38362_rex', '39618_rex', '35855_rex', '40578_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['30556_thamno', '35236_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['38362_rex', '39618_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['35855_rex', '40578_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['30556_thamno'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['35236_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['38362_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['39618_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['35855_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']},\n", " {'p1': ['40578_rex'],\n", " 'p2': ['33413_thamno'],\n", " 'p3': ['30686_cyathophylla'],\n", " 'p4': ['32082_przewalskii', '33588_przewalskii']}]" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tests" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Or get any arbitrary tree" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
01abc
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "## pass a newick string to the Tree class object\n", "tre = baba.Tree(newick=\"((a,b),c);\")\n", "tre.draw(width=200, height=200);" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### get a tree with an admixture edge\n", "Shown by an arrow pointing backwards from source to sink (indicating that geneflow should be entered as occurring backwards in time). This is how the program `msprime` will interpret it. " ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
0123Cowabde0123
    \n", "
  • \n", "
  • \n", " Save as .csv\n", "
  • \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "## store newick tree and a migration event list [source, sink, start, stop, rate]\n", "## if not edges are entered then it is converted to cladogram\n", "newick = \"(((a,b),Cow), (d,e));\"\n", "events = [['e', 'Cow', 0, 1, 1e-6], \n", " ['3', '1', 1, 2, 1e-6]]\n", "\n", "## initiate Tree object with newick and admix args\n", "tre = baba.Tree(newick=newick, \n", " admix=events)\n", "\n", "## show the tree \n", "tre.draw(width=250, height=250, yaxis=True);" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[4.0, 3.0, 2.0, 1.0, 0.0]\n", "['d', 'e', 'Cow', 'a', 'b']\n" ] } ], "source": [ "## a way of finding names xpos from verts\n", "tre.verts[tre.verts[:, 1] == 0]\n", "tre.tree.search_nodes(name='b')[0].idx\n", "\n", "tre.verts[6, 0]\n", "\n", "print [tre.verts[tre.tree.search_nodes(name=name)[0].idx, 0]\n", " for name in tre.tree.get_leaf_names()]\n", "\n", "print tre.tree.get_leaf_names()" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### simulate data on that tree\n" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "## returns a Sim data object\n", "sims = tre.simulate(nreps=10000, Ns=50000, gen=20)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "sims \n", "debug 0\n", "nreps 10000\n", "names ['b', 'a', 'Cow', 'e', 'd']\n" ] } ], "source": [ "## what is in the sims object? 4 attributes:\n", "for key, val in sims.__dict__.items():\n", " print key, val" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "ename": "NameError", "evalue": "name 'test' is not defined", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mbaba\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_msp_to_arr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msims\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtest\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mNameError\u001b[0m: name 'test' is not defined" ] } ], "source": [ "baba._msp_to_arr(sims, test)" ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [ "def _msp_to_arr(Sim, test):\n", " \n", " ## the fixed tree dictionary\n", " #fix = {j: [i, i+1] for j, i in zip(list(\"abcdefghijkl\"), range(0, 24, 2))}\n", " fix = {j: [i, i+1] for j, i in zip(Sim.names, range(0, len(Sim.names)*2, 2))}\n", " \n", " ## fill taxdict by test\n", " keys = ['p1', 'p2', 'p3', 'p4']\n", " arr = np.zeros((Sim.nreps, 4, 100))\n", " \n", " ## unless it's a 5-taxon test\n", " if len(test) == 5:\n", " arr = np.zeros((100000, 6, 100))\n", " keys += ['p5']\n", " \n", " ## create array sampler for taxa\n", " taxs = [test[key] for key in keys]\n", " idxs = [list(itertools.chain(*[fix[j] for j in i])) for i in taxs]\n", " print idxs" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[2, 3], [0, 1], [4, 5], [6, 7, 8, 9]]\n" ] } ], "source": [ "from ipyrad.analysis.baba import *\n", "_msp_to_arr(sims, test)" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### A function to print the variant matrix of one rep.\n", "This is used just for demonstration. The matrix will have 2X as many columns as there are \n", "tips in the tree, corresponding to two alleles per individual. The number of rows is the \n", "number of variant sites simulated. " ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [ "def print_variant_matrix(tree):\n", " shape = tree.get_num_mutations(), tree.get_sample_size()\n", " arr = np.empty(shape, dtype=\"u1\")\n", " for variant in tree.variants():\n", " arr[variant.index] = variant.genotypes\n", " print(arr)" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[0 0 0 0 0 0 1 1 0 0]\n", " [1 1 1 1 0 0 0 0 0 0]\n", " [0 0 1 1 0 0 0 0 0 0]\n", " [1 0 1 1 0 0 0 0 0 0]\n", " [0 1 0 0 0 0 0 0 0 0]\n", " [0 0 0 0 0 0 1 1 1 1]]\n" ] } ], "source": [ "## in order of ladderized tip names (2 copies per tip)\n", "print_variant_matrix(sims.sims.next())" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Simulate data for ABBA-BABA tests" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sims" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "## simulate data on tree\n", "#sims = tre.simulate(nreps=10000, Ns=50000, gen=20)\n", "\n", "## pass sim object to baba\n", "test = {\n", " 'p4': ['e', 'd'],\n", " 'p3': ['Cow'], \n", " 'p2': ['b'],\n", " 'p1': ['a'], \n", "}\n", "\n", "#baba.batch(sims, test, ipyclient=ipyclient)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.13" } }, "nbformat": 4, "nbformat_minor": 1 }