{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Inferring species trees with *tetrad*\n", "\n", "When you install _ipyrad_ a number of analysis tools are installed as well. This includes the program __tetrad__, which applies the theory of phylogenetic invariants (see Lake 1987) to infer quartet trees based on a SNP alignment. It then uses the software wQMC to join the quartets into a species tree. This combined approach was first developed by Chifman and Kubatko (2015) in the software *SVDQuartets*. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Required software" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## conda install ipyrad -c ipyrad\n", "## conda install toytree -c eaton-lab" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import ipyrad.analysis as ipa\n", "import ipyparallel as ipp\n", "import toytree" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Connect to a cluster" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "connected to 4 cores\n" ] } ], "source": [ "## connect to a cluster\n", "ipyclient = ipp.Client()\n", "print(\"connected to {} cores\".format(len(ipyclient)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Run tetrad" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "loading seq array [13 taxa x 14159 bp]\n", "max unlinked SNPs per quartet (nloci): 2777\n" ] } ], "source": [ "## initiate a tetrad object\n", "tet = ipa.tetrad(\n", " name=\"pedic-full\",\n", " seqfile=\"analysis-ipyrad/pedic-full_outfiles/pedic-full.snps.phy\",\n", " mapfile=\"analysis-ipyrad/pedic-full_outfiles/pedic-full.snps.map\",\n", " nboots=100,\n", " )" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "host compute node: [4 cores] on oud\n", "inferring 715 induced quartet trees\n", "[####################] 100% initial tree | 0:00:06 | \n", "[####################] 100% boot 100 | 0:01:00 | \n" ] } ], "source": [ "## run tetrad on the cluster\n", "tet.run(ipyclient=ipyclient)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot the tree" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "