{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Canarium GBS: ABBA-BABA analyses\n", "### *Federman et al.*\n", "\n", "This notebook provides all code necessary to reproduce the ABBA-BABA analyses used in Federman et al. (xxxx). All code in this notebook is written in Python." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Required software" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## conda install ipyrad -c ipyrad\n", "## conda install toytree -c eaton-lab" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Imports" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ipyrad v.0.7.23\n" ] } ], "source": [ "import toytree\n", "import toyplot.svg\n", "import ipyrad as ip\n", "import ipyrad.analysis as ipa\n", "print \"ipyrad v.{}\".format(ip.__version__)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Connect to cluster" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "host compute node: [40 cores] on sacra\n" ] } ], "source": [ "import ipyparallel as ipp\n", "ipyclient = ipp.Client()\n", "ip.cluster_info(ipyclient)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ABBA-BABA tests" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## load input files\n", "locifile = \"./analysis-ipyrad/Canarium-min10_outfiles/Canarium-min10.loci\"\n", "newick = \"./analysis-raxml/RAxML_bestTree.Canarium-min10\"" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## make clade lists for setting up tests easily\n", "clade1A = [\"SF328\", \"SF200\", \"SF175\"]\n", "clade1B = [\"SF209\", \"D13052\"]\n", "clade1C = [\"SF172\", \"D14528\", \"SF286\", \"SF276\"]\n", "clade1 = clade1A + clade1B + clade1C\n", "\n", "clade2A = [\"D14482\", \"D14483\", \"D13103\", \"D13101\"]\n", "clade2B = [\"D14504\", \"D14505\", \"D14506\"]\n", "clade2C = [\"D14501\", \"D14513\", \"D14480\", \"D14485\", \"D14477\", \"D14478\"]\n", "clade2 = clade2A + clade2B + clade2C\n", "\n", "clade3X = [\"D12963\"]\n", "clade3A = [\"D13090\", \"D12950\"]\n", "clade3B = [\"SF155\", \"5573\", \"SF327\", \"SF228\", \"SF224\"]\n", "clade3C = [\"SF164\", \"SF153\", \"SF160\", \"D13097\", \"SF197\", \"D13075\", \"D13053\", \"D13063\"]\n", "clade3 = clade3A + clade3B + clade3C\n", "\n", "outgroups = [\"D13852\", \"SFC1988\", \"D14269\", \"D13374\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 1: Is SF172 a hybrid?" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[####################] 100% calculating D-stats | 0:00:38 | \n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dstatbootmeanbootstdZABBABABAnloci
0-0.575-0.5750.01441.321386.7651432.76243331
\n", "
" ], "text/plain": [ " dstat bootmean bootstd Z ABBA BABA nloci\n", "0 -0.575 -0.575 0.014 41.321 386.765 1432.762 43331" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "q1 = ipa.baba(data=locifile, newick=newick)\n", "q1.tests = [{\n", " \"p4\": outgroups,\n", " \"p3\": clade3 + clade3X, \n", " \"p2\": clade1A + clade1B,\n", " \"p1\": [\"SF172\"],\n", "}]\n", "q1.run(ipyclient)\n", "q1.results_table" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 2: Admixture between clades 1 and 3" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[####################] 100% calculating D-stats | 0:00:53 | \n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dstatbootmeanbootstdZABBABABAnloci
0-0.072-0.0720.0145.0421375.1451587.85359670
\n", "
" ], "text/plain": [ " dstat bootmean bootstd Z ABBA BABA nloci\n", "0 -0.072 -0.072 0.014 5.042 1375.145 1587.853 59670" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "q2 = ipa.baba(data=locifile, newick=newick)\n", "q2.tests = [{\n", " \"p4\": outgroups,\n", " \"p3\": list(set(clade1) - set([\"SF172\"])), \n", " \"p2\": clade2, \n", " \"p1\": clade3 + clade3X, \n", " }]\n", "q2.run(ipyclient)\n", "q2.results_table" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 3: Admixture between clades 1 & 3 geographic" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[####################] 100% calculating D-stats | 0:00:43 | \n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dstatbootmeanbootstdZABBABABAnloci
0-0.018-0.0190.0280.662380.611394.90650799
10.0100.0100.0240.415608.591596.39951984
\n", "
" ], "text/plain": [ " dstat bootmean bootstd Z ABBA BABA nloci\n", "0 -0.018 -0.019 0.028 0.662 380.611 394.906 50799\n", "1 0.010 0.010 0.024 0.415 608.591 596.399 51984" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "q3 = ipa.baba(data=locifile, newick=newick)\n", "q3.tests = [\n", " {\n", " \"p4\": outgroups,\n", " \"p3\": list(set(clade1) - set([\"SF172\"])), \n", " \"p2\": list(set(clade3C) - set([\"D13097\"])),\n", " \"p1\": [\"D13097\"], \n", " },\n", " {\n", " \"p4\": outgroups,\n", " \"p3\": list(set(clade1) - set([\"SF172\"])), \n", " \"p2\": list(set(clade3B) - set([\"D13097\"])),\n", " \"p1\": [\"D13097\"], \n", " },\n", "]\n", "q3.run(ipyclient)\n", "q3.results_table" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 4: Admixture into clade 3 (3A, 3B, 3C comparison)\n" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[####################] 100% calculating D-stats | 0:00:58 | \n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dstatbootmeanbootstdZABBABABAnloci
0-0.041-0.0400.0261.566521.038565.14732453
1-0.088-0.0890.0155.8511265.3511511.05857566
2-0.066-0.0660.0154.3461264.5981444.09357496
3-0.077-0.0770.0145.5391358.0931584.44759287
\n", "
" ], "text/plain": [ " dstat bootmean bootstd Z ABBA BABA nloci\n", "0 -0.041 -0.040 0.026 1.566 521.038 565.147 32453\n", "1 -0.088 -0.089 0.015 5.851 1265.351 1511.058 57566\n", "2 -0.066 -0.066 0.015 4.346 1264.598 1444.093 57496\n", "3 -0.077 -0.077 0.014 5.539 1358.093 1584.447 59287" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "q4 = ipa.baba(data=locifile, newick=newick)\n", "q4.tests = [{\n", " \"p4\": outgroups,\n", " \"p3\": list(set(clade1) - set([\"SF172\"])), \n", " \"p2\": clade2,\n", " \"p1\": clade, \n", " } for clade in [clade3A, clade3B, clade3C, clade3B + clade3C]]\n", "q4.run(ipyclient)\n", "q4.results_table" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 5: Admixture between clades 2A and 2B or 2C" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[####################] 100% calculating D-stats | 0:00:43 | \n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dstatbootmeanbootstdZABBABABAnloci
0-0.085-0.0840.0174.932985.6381168.77750034
10.1050.1040.0283.712369.301299.11226788
20.1130.1130.0205.680620.334494.67936498
30.0430.0430.0500.867134.177122.99319236
4-0.028-0.0280.0420.657141.597149.62320053
\n", "
" ], "text/plain": [ " dstat bootmean bootstd Z ABBA BABA nloci\n", "0 -0.085 -0.084 0.017 4.932 985.638 1168.777 50034\n", "1 0.105 0.104 0.028 3.712 369.301 299.112 26788\n", "2 0.113 0.113 0.020 5.680 620.334 494.679 36498\n", "3 0.043 0.043 0.050 0.867 134.177 122.993 19236\n", "4 -0.028 -0.028 0.042 0.657 141.597 149.623 20053" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "q5 = ipa.baba(data=locifile, newick=newick)\n", "q5.tests = [\n", " {\n", " \"p4\": outgroups,\n", " \"p3\": clade2A, \n", " \"p2\": clade2B,\n", " \"p1\": clade2C,\n", " }, \n", " {\n", " \"p4\": outgroups,\n", " \"p3\": clade2A, \n", " \"p2\": list(set(clade2C) - set([\"D14513\"])),\n", " \"p1\": [\"D14513\"],\n", " }, \n", " {\n", " \"p4\": outgroups,\n", " \"p3\": clade2A, \n", " \"p2\": list(set(clade2C) - set([\"D14513\", \"D14501\"])),\n", " \"p1\": [\"D14513\", \"D14501\"],\n", " }, \n", " {\n", " \"p4\": outgroups, \n", " \"p3\": clade2B, \n", " \"p2\": [\"D14483\", \"D14482\"],\n", " \"p1\": [\"D13101\", \"D13103\"],\n", " },\n", " {\n", " \"p4\": outgroups, \n", " \"p3\": clade2C, \n", " \"p2\": [\"D14483\", \"D14482\"],\n", " \"p1\": [\"D13101\", \"D13103\"],\n", " },\n", "]\n", "q5.run(ipyclient)\n", "q5.results_table" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 6: Admixture between clades 2B and 2C" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "50 tests generated from tree\n", "[####################] 100% calculating D-stats | 0:01:44 | \n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dstatbootmeanbootstdZABBABABAnloci
17-0.260-0.2610.02112.352407.642694.58732234
00.2330.2330.01911.979719.430447.24133055
40.2360.2360.02011.913716.248442.40532955
13-0.236-0.2360.02011.897442.405716.24832955
80.2600.2590.02211.893694.587407.64232234
9-0.233-0.2320.02011.853447.241719.43033055
11-0.229-0.2290.02011.595450.432717.97233016
20.2290.2290.02011.267717.972450.43233016
60.2340.2330.02111.175706.479438.95032776
15-0.234-0.2340.02110.898438.950706.47932776
\n", "
" ], "text/plain": [ " dstat bootmean bootstd Z ABBA BABA nloci\n", "17 -0.260 -0.261 0.021 12.352 407.642 694.587 32234\n", "0 0.233 0.233 0.019 11.979 719.430 447.241 33055\n", "4 0.236 0.236 0.020 11.913 716.248 442.405 32955\n", "13 -0.236 -0.236 0.020 11.897 442.405 716.248 32955\n", "8 0.260 0.259 0.022 11.893 694.587 407.642 32234\n", "9 -0.233 -0.232 0.020 11.853 447.241 719.430 33055\n", "11 -0.229 -0.229 0.020 11.595 450.432 717.972 33016\n", "2 0.229 0.229 0.020 11.267 717.972 450.432 33016\n", "6 0.234 0.233 0.021 11.175 706.479 438.950 32776\n", "15 -0.234 -0.234 0.021 10.898 438.950 706.479 32776" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "q6 = ipa.baba(data=locifile, newick=newick)\n", "q6.generate_tests_from_tree(\n", " constraint_exact=[False, False, True, True],\n", " constraint_dict={\n", " \"p4\": outgroups,\n", " \"p3\": clade2B,\n", " \"p2\": clade2C,\n", " \"p1\": clade2C,\n", " })\n", "q6.run(ipyclient)\n", "q6.results_table.sort_values(by='Z', ascending=False).head(10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 7: Admixture between 2C and 3" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "50 tests generated from tree\n", "[####################] 100% calculating D-stats | 0:02:00 | \n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dstatbootmeanbootstdZABBABABAnloci
1-0.236-0.2360.0396.107149.450241.92922961
100.2360.2360.0396.005241.929149.45022961
26-0.206-0.2030.0375.546154.434234.45723524
190.2060.2060.0385.458234.457154.43423524
240.1560.1570.0295.354344.367251.32827085
25-0.137-0.1370.0275.163263.416347.22127762
30-0.181-0.1820.0355.150180.356260.08324877
230.1810.1810.0365.056260.083180.35624877
27-0.134-0.1350.0275.004263.861345.72227697
180.1370.1380.0284.984347.221263.41627762
\n", "
" ], "text/plain": [ " dstat bootmean bootstd Z ABBA BABA nloci\n", "1 -0.236 -0.236 0.039 6.107 149.450 241.929 22961\n", "10 0.236 0.236 0.039 6.005 241.929 149.450 22961\n", "26 -0.206 -0.203 0.037 5.546 154.434 234.457 23524\n", "19 0.206 0.206 0.038 5.458 234.457 154.434 23524\n", "24 0.156 0.157 0.029 5.354 344.367 251.328 27085\n", "25 -0.137 -0.137 0.027 5.163 263.416 347.221 27762\n", "30 -0.181 -0.182 0.035 5.150 180.356 260.083 24877\n", "23 0.181 0.181 0.036 5.056 260.083 180.356 24877\n", "27 -0.134 -0.135 0.027 5.004 263.861 345.722 27697\n", "18 0.137 0.138 0.028 4.984 347.221 263.416 27762" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "q7 = ipa.baba(data=locifile, newick=newick)\n", "q7.generate_tests_from_tree(\n", " constraint_exact=[False, False, True, True],\n", " constraint_dict={\n", " \"p4\": outgroups,\n", " \"p3\": clade3B + clade3C, \n", " \"p2\": clade2C,\n", " \"p1\": clade2C,\n", " })\n", "q7.run(ipyclient)\n", "q7.results_table.sort_values(by='Z', ascending=False).head(10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 8: Clades 2C and 3 get top tests" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "50 tests generated from tree\n", "[####################] 100% calculating D-stats | 0:01:18 | \n" ] } ], "source": [ "qq = ipa.baba(data=locifile, newick=newick)\n", "qq.generate_tests_from_tree(\n", " constraint_exact=[True, False, False, True],\n", " constraint_dict={\n", " \"p4\": outgroups,\n", " \"p3\": clade3B + clade3C, \n", " \"p2\": [\"D14513\", \"D14501\"],\n", " \"p1\": [\"D14485\", \"D14480\", \"D14477\", \"D14478\"],\n", " })\n", "qq.run(ipyclient)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## get top 5 tests \n", "idxs = qq.results_table.sort_values(by='Z', ascending=False).head(5).index.tolist()\n", "qtests = [qq.tests[idx] for idx in idxs]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Make a summary plot" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## top tests from q6, q7, and q8\n", "q6s = [{\n", " \"p4\": outgroups, \n", " \"p3\": clade2B,\n", " \"p2\": [\"D14485\", \"D14480\", \"D14477\", \"D14478\"],\n", " \"p1\": [\"D14501\"],\n", "}]\n", "q7s = [{\n", " \"p4\": outgroups, \n", " \"p3\": clade3B + clade3C, \n", " \"p2\": [\"D14485\", \"D14480\", \"D14477\", \"D14478\"],\n", " \"p1\": [\"D14513\"],\n", "}]\n", "q8s = [{\n", " \"p4\": outgroups, \n", " \"p3\": clade3A,\n", " \"p2\": list(set(clade3B + clade3C) - set([\"D12963\"])),\n", " \"p1\": [\"D12963\"],\n", "}]" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[####################] 100% calculating D-stats | 0:01:11 | \n" ] } ], "source": [ "qall = ipa.baba(data=locifile, newick=newick)\n", "qall.tests = q1.tests + q2.tests + q3.tests + q4.tests + q5.tests +\\\n", " q6s + q7s + q8s + qtests\n", "qall.run(ipyclient)" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "collapsed": true }, "outputs": [], "source": [ "neworder = [0, 1, 4, 5, 6, 7, 2, 3, 15] + range(8, 15) + range(16, 21)" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
01234567891011121314151617181920SFC1988D13852D13374D14269SF328SF200SF175SF209D13052SF172D14528SF286SF276D14482D14483D13103D13101D14504D14505D14506D14501D14513D14485D14480D14477D14478D13090D12950D12963SF1555573SF327SF228SF224SF164SF153SF160D13097SF197D13075D13053D1306343.00.0-0.70.7Z-scoresD-statistics
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "canvas, axes, mark = qall.plot(\n", " pct_tree_x=0.65,\n", " width=900,\n", " height=500,\n", " style_tip_labels={\"font-size\": \"11px\"},\n", " style_results_labels={\"font-size\": \"11px\"},\n", " alpha=3.0,\n", " subset_tests=neworder\n", ");" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# save figure\n", "import toyplot.svg\n", "toyplot.svg.render(canvas, \"figures/abba-baba.svg\")\n", "! cp figures/abba-baba.svg /home/deren/Dropbox/\n" ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# join taxon names to test results in full_table\n", "qall.full_table = qall.results_table.copy()\n", "for col in qall.taxon_table.columns:\n", " qall.full_table[col] = qall.taxon_table[col]\n", " \n", "# save results table in new order, reset index, and save\n", "fulltable = qall.full_table.loc[neworder]\n", "fulltable.index = range(fulltable.shape[0])\n", "fulltable.to_csv(\"Table_S6.csv\", float_format=\"%.3f\")" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(35375.904761904763, 1180.7655167845865)" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy as np\n", "fulltable.nloci.mean(), np.mean(fulltable.ABBA + fulltable.BABA)" ] } ], "metadata": { "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 }