{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ipyrad-analysis toolkit: RAxML\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "RAxML is the most popular tool for inferring phylogenetic trees using maximum likelihood. It is fast even for very large data sets. The documentation for raxml is huge, and there are many options. However, I tend to use the same small number of options very frequently, which motivated me to write the `ipa.raxml()` tool to automate the process of generating RAxml command line strings, running them, and accessing the resulting tree files. The simplicity of this tool makes it easy to incorporate into other more complex tools, for example, to infer tress in sliding windows along the genome using the `ipa.treeslider` tool.\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Required software" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# conda install ipyrad -c bioconda\n", "# conda install raxml -c bioconda\n", "# conda install toytree -c eaton-lab" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import ipyrad.analysis as ipa\n", "import toytree" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Short Tutorial:\n", "\n", "The raxml tool takes a *phylip* formatted file as input. In addition you can set a number of analysis options either when you init the tool, or afterwards by accessing the `.params` dictionary. You can view the raxml command string that is generated from the input arguments and you can call `.run()` to start the tree inference. \n", "This example takes about 3-5 minutes to run on my laptop for a data set with 13 samples and ~1.2M SNPs and about 14% missing data." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# the path to your phylip formatted output file\n", "phyfile = \"../min10_outfiles/min10.phy\"" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "raxmlHPC-PTHREADS-SSE3 -f a -T 4 -m GTRGAMMA -n test -w /home/deren/Documents/ipyrad/newdocs/cookbook/analysis-raxml -s /home/deren/Documents/ipyrad/tests/pedicularis/data10_outfiles/data10.phy -p 54321 -N 10 -x 12345\n", "job test finished successfully\n" ] } ], "source": [ "# init raxml object with input data and (optional) parameter options\n", "rax = ipa.raxml(data=phyfile, T=4, N=10)\n", "\n", "# print the raxml command string for prosperity\n", "print(rax.command)\n", "\n", "# run the command, (options: block until finishes; overwrite existing)\n", "rax.run(block=True, force=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Draw the inferred tree\n", "After inferring a tree you can then visualize it in a notebook using `toytree`. " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "