{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Applying a discrete-time, non-stationary nucleotide model\n", "\n", "We fit a discrete-time Markov nucleotide model. This corresponds to a Barry and Hartigan 1987 model." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
BH
keylnLnfpDLCunique_Q
-6941.4684135True
\n" ], "text/plain": [ "BH\n", "============================================\n", "key lnL nfp DLC unique_Q\n", "--------------------------------------------\n", " -6941.4684 135 True \n", "--------------------------------------------\n", "\n", "1 rows x 5 columns" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from cogent3.app import io, evo\n", "\n", "loader = io.load_aligned(format=\"fasta\", moltype=\"dna\")\n", "aln = loader(\"../data/primate_brca1.fasta\")\n", "model = evo.model(\"BH\", tree=\"../data/primate_brca1.tree\")\n", "result = model(aln)\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**NOTE:** DLC stands for diagonal largest in column and the value is a check on the identifiability of the model. `unique_Q` is not applicable to a discrete-time model and so remains as `None`.\n", "\n", "Looking at the likelihood function, you will" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

BH

\n", "

log-likelihood = -6941.4684

\n", "

number of free parameters = 135

\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
Edge motif motif2 params
edgemotifmotif2psubs
GalagoTT0.8751
GalagoTC0.0649
GalagoTA0.0409
GalagoTG0.0192
GalagoCT0.1126
............
edge.3AG0.0055
edge.3GT0.0000
edge.3GC0.0011
edge.3GA0.0039
edge.3GG0.9950
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
Motif params
ACGT
0.37740.17630.20580.2404
\n" ], "text/plain": [ "BH\n", "log-likelihood = -6941.4684\n", "number of free parameters = 135\n", "=======================================\n", " edge motif motif2 psubs\n", "---------------------------------------\n", " Galago T T 0.8751\n", " Galago T C 0.0649\n", " Galago T A 0.0409\n", " Galago T G 0.0192\n", " Galago C T 0.1126\n", " Galago C C 0.8056\n", " Galago C A 0.0404\n", " Galago C G 0.0413\n", " Galago A T 0.0255\n", " Galago A C 0.0255\n", " Galago A A 0.8878\n", " Galago A G 0.0612\n", " Galago G T 0.0207\n", " Galago G C 0.0194\n", " Galago G A 0.1681\n", " Galago G G 0.7918\n", " HowlerMon T T 0.9689\n", " HowlerMon T C 0.0240\n", " HowlerMon T A 0.0041\n", " HowlerMon T G 0.0030\n", " HowlerMon C T 0.0376\n", " HowlerMon C C 0.9406\n", " HowlerMon C A 0.0069\n", " HowlerMon C G 0.0150\n", " HowlerMon A T 0.0038\n", " HowlerMon A C 0.0038\n", " HowlerMon A A 0.9589\n", " HowlerMon A G 0.0334\n", " HowlerMon G T 0.0031\n", " HowlerMon G C 0.0068\n", " HowlerMon G A 0.0403\n", " HowlerMon G G 0.9498\n", " Rhesus T T 0.9879\n", " Rhesus T C 0.0078\n", " Rhesus T A 0.0015\n", " Rhesus T G 0.0028\n", " Rhesus C T 0.0187\n", " Rhesus C C 0.9710\n", " Rhesus C A 0.0040\n", " Rhesus C G 0.0063\n", " Rhesus A T 0.0019\n", " Rhesus A C 0.0009\n", " Rhesus A A 0.9849\n", " Rhesus A G 0.0122\n", " Rhesus G T 0.0017\n", " Rhesus G C 0.0068\n", " Rhesus G A 0.0295\n", " Rhesus G G 0.9620\n", " Orangutan T T 0.9911\n", " Orangutan T C 0.0059\n", " Orangutan T A 0.0000\n", " Orangutan T G 0.0030\n", " Orangutan C T 0.0082\n", " Orangutan C C 0.9898\n", " Orangutan C A 0.0000\n", " Orangutan C G 0.0020\n", " Orangutan A T 0.0009\n", " Orangutan A C 0.0000\n", " Orangutan A A 0.9952\n", " Orangutan A G 0.0038\n", " Orangutan G T 0.0000\n", " Orangutan G C 0.0017\n", " Orangutan G A 0.0073\n", " Orangutan G G 0.9910\n", " Gorilla T T 1.0000\n", " Gorilla T C 0.0000\n", " Gorilla T A 0.0000\n", " Gorilla T G 0.0000\n", " Gorilla C T 0.0000\n", " Gorilla C C 0.9980\n", " Gorilla C A 0.0020\n", " Gorilla C G 0.0000\n", " Gorilla A T 0.0000\n", " Gorilla A C 0.0010\n", " Gorilla A A 0.9962\n", " Gorilla A G 0.0029\n", " Gorilla G T 0.0000\n", " Gorilla G C 0.0000\n", " Gorilla G A 0.0033\n", " Gorilla G G 0.9967\n", " Human T T 0.9941\n", " Human T C 0.0030\n", " Human T A 0.0015\n", " Human T G 0.0015\n", " Human C T 0.0041\n", " Human C C 0.9918\n", " Human C A 0.0020\n", " Human C G 0.0020\n", " Human A T 0.0000\n", " Human A C 0.0000\n", " Human A A 0.9971\n", " Human A G 0.0029\n", " Human G T 0.0000\n", " Human G C 0.0017\n", " Human G A 0.0083\n", " Human G G 0.9900\n", "Chimpanzee T T 0.9956\n", "Chimpanzee T C 0.0044\n", "Chimpanzee T A 0.0000\n", "Chimpanzee T G 0.0000\n", "Chimpanzee C T 0.0020\n", "Chimpanzee C C 0.9959\n", "Chimpanzee C A 0.0000\n", "Chimpanzee C G 0.0020\n", "Chimpanzee A T 0.0000\n", "Chimpanzee A C 0.0000\n", "Chimpanzee A A 0.9990\n", "Chimpanzee A G 0.0010\n", "Chimpanzee G T 0.0000\n", "Chimpanzee G C 0.0017\n", "Chimpanzee G A 0.0017\n", "Chimpanzee G G 0.9967\n", " edge.0 T T 1.0000\n", " edge.0 T C 0.0000\n", " edge.0 T A 0.0000\n", " edge.0 T G 0.0000\n", " edge.0 C T 0.0000\n", " edge.0 C C 1.0000\n", " edge.0 C A 0.0000\n", " edge.0 C G 0.0000\n", " edge.0 A T 0.0000\n", " edge.0 A C 0.0000\n", " edge.0 A A 1.0000\n", " edge.0 A G 0.0000\n", " edge.0 G T 0.0000\n", " edge.0 G C 0.0000\n", " edge.0 G A 0.0000\n", " edge.0 G G 1.0000\n", " edge.1 T T 1.0000\n", " edge.1 T C 0.0000\n", " edge.1 T A 0.0000\n", " edge.1 T G 0.0000\n", " edge.1 C T 0.0082\n", " edge.1 C C 0.9918\n", " edge.1 C A 0.0000\n", " edge.1 C G 0.0000\n", " edge.1 A T 0.0000\n", " edge.1 A C 0.0000\n", " edge.1 A A 0.9946\n", " edge.1 A G 0.0054\n", " edge.1 G T 0.0000\n", " edge.1 G C 0.0000\n", " edge.1 G A 0.0000\n", " edge.1 G G 1.0000\n", " edge.2 T T 0.9868\n", " edge.2 T C 0.0073\n", " edge.2 T A 0.0025\n", " edge.2 T G 0.0034\n", " edge.2 C T 0.0121\n", " edge.2 C C 0.9797\n", " edge.2 C A 0.0041\n", " edge.2 C G 0.0041\n", " edge.2 A T 0.0009\n", " edge.2 A C 0.0009\n", " edge.2 A A 0.9915\n", " edge.2 A G 0.0066\n", " edge.2 G T 0.0000\n", " edge.2 G C 0.0017\n", " edge.2 G A 0.0056\n", " edge.2 G G 0.9927\n", " edge.3 T T 0.9913\n", " edge.3 T C 0.0042\n", " edge.3 T A 0.0000\n", " edge.3 T G 0.0045\n", " edge.3 C T 0.0024\n", " edge.3 C C 0.9932\n", " edge.3 C A 0.0019\n", " edge.3 C G 0.0026\n", " edge.3 A T 0.0018\n", " edge.3 A C 0.0009\n", " edge.3 A A 0.9918\n", " edge.3 A G 0.0055\n", " edge.3 G T 0.0000\n", " edge.3 G C 0.0011\n", " edge.3 G A 0.0039\n", " edge.3 G G 0.9950\n", "---------------------------------------\n", "====================================\n", " A C G T\n", "------------------------------------\n", "0.3774 0.1763 0.2058 0.2404\n", "------------------------------------" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result.lf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get a tree with branch lengths as paralinear\n", "\n", "This is the only possible length metric for a discrete-time process." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "line": { "color": "black", "shape": "spline", "smoothing": 1.3, "width": 1.25 }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ null, null, 0, 0, null, 0, 0.03139195169925202, null, 0.03139195169925202, 0.03139195169925202, null, 0.03139195169925202, 0.08159484122097149, null, 0.08159484122097149, 0.08159484122097149, null, 0.08159484122097149, 0.09617900440577909, null, 0.09617900440577909, 0.09617900440577909, null, 0.09617900440577909, 0.0961878725442622, null, 0.0961878725442622, 0.0961878725442622, null, 0.0961878725442622, 0.10959571362620046, null, 0.0961878725442622, 0.0961878725442622, null, 0.0961878725442622, 0.12185690868725763, null, 0.09617900440577909, 0.09617900440577909, null, 0.09617900440577909, 0.1057597283305971, null, 0.08159484122097149, 0.08159484122097149, null, 0.08159484122097149, 0.11501597595635671, null, 0.03139195169925202, 0.03139195169925202, null, 0.03139195169925202, 0.12464469563427283, null, 0, 0, null, 0, 0.1930734042426634, null, 0, 0, null, 0, 0.7165441919466353, null ], "y": [ null, null, -2.6, -0.08125000000000004, null, -0.08125000000000004, -0.08125000000000004, null, -0.08125000000000004, 1.1375, null, 1.1375, 1.1375, null, 1.1375, 2.275, null, 2.275, 2.275, null, 2.275, 3.25, null, 3.25, 3.25, null, 3.25, 3.9000000000000004, null, 3.9000000000000004, 3.9000000000000004, null, 3.25, 2.6, null, 2.6, 2.6, null, 2.275, 1.3, null, 1.3, 1.3, null, 1.1375, 0.0, null, 0.0, 0.0, null, -0.08125000000000004, -1.3, null, -1.3, -1.3, null, -2.6, -2.6, null, -2.6, -2.6, null, -2.6, -3.9000000000000004, null, -3.9000000000000004, -3.9000000000000004, null ] }, { "hoverinfo": "text", "marker": { "color": "black", "size": 3, "symbol": "circle" }, "mode": "markers", "showlegend": false, "text": [ "root", "edge.3", "edge.2", "edge.1", "edge.0", "Chimpanzee", "Human", "Gorilla", "Orangutan", "Rhesus", "HowlerMon", "Galago" ], "type": "scatter", "x": [ 0, 0.03139195169925202, 0.08159484122097149, 0.09617900440577909, 0.0961878725442622, 0.10959571362620046, 0.12185690868725763, 0.1057597283305971, 0.11501597595635671, 0.12464469563427283, 0.1930734042426634, 0.7165441919466353 ], "y": [ -2.6, -0.08125000000000004, 1.1375, 2.275, 3.25, 3.9000000000000004, 2.6, 1.3, 0.0, -1.3, -2.6, -3.9000000000000004 ] } ], "layout": { "annotations": [ { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Chimpanzee", "textangle": 0, "x": 0.12750931842486635, "xanchor": "left", "xref": "x", "y": 3.9000000000000004, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Human", "textangle": 0, "x": 0.1397705134859235, "xanchor": "left", "xref": "x", "y": 2.6, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Gorilla", "textangle": 0, "x": 0.12367333312926299, "xanchor": "left", "xref": "x", "y": 1.3, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Orangutan", "textangle": 0, "x": 0.1329295807550226, "xanchor": "left", "xref": "x", "y": 0.0, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Rhesus", "textangle": 0, "x": 0.1425583004329387, "xanchor": "left", "xref": "x", "y": -1.3, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "HowlerMon", "textangle": 0, "x": 0.21098700904132928, "xanchor": "left", "xref": "x", "y": -2.6, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Galago", "textangle": 0, "x": 0.7344577967453012, "xanchor": "left", "xref": "x", "y": -3.9000000000000004, "yref": "y" }, { "ax": 0, "ay": 0, "showarrow": false, "text": "0.07", "x": 0.7523714015439671, "xref": "x", "y": 3.9000000000000004, "yref": "y", "yshift": 10 } ], "autosize": true, "font": { "family": "Balto", "size": 14 }, "height": 500, "hovermode": "closest", "margin": { "b": 50, "l": 50, "pad": 4, "r": 50, "t": 50 }, "shapes": [ { "line": { "color": "black", "width": 1.25 }, "type": "line", "x0": 0.7165441919466353, "x1": 0.7881986111412989, "y0": 3.9000000000000004, "y1": 3.9000000000000004 } ], "showlegend": false, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ], "sequentialminus": [ [ 0.0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1.0, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "width": 500, "xaxis": { "visible": false }, "yaxis": { "visible": false } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "tree = result.tree\n", "fig = tree.get_figure()\n", "fig.scale_bar = \"top right\"\n", "fig.show(width=500, height=500)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Getting parameter estimates\n", "\n", "For a discrete-time model, aside from the root motif probabilities, everything is edge specific. But note that the `tabular_result` has different keys from the continuous-time case, as demonstrated below." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2x tabular_result('edge motif motif2 params': Table, 'motif params': Table)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tabulator = evo.tabulate_stats()\n", "stats = tabulator(result)\n", "stats" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "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", "
edge motif motif2 params
edgemotifmotif2psubs
GalagoTT0.8751
GalagoTC0.0649
GalagoTA0.0409
GalagoTG0.0192
GalagoCT0.1126
............
edge.3AG0.0055
edge.3GT0.0000
edge.3GC0.0011
edge.3GA0.0039
edge.3GG0.9950
\n", "

\n", "176 rows x 4 columns

" ], "text/plain": [ "edge motif motif2 params\n", "===================================\n", " edge motif motif2 psubs\n", "-----------------------------------\n", "Galago T T 0.8751\n", "Galago T C 0.0649\n", "Galago T A 0.0409\n", "Galago T G 0.0192\n", "Galago C T 0.1126\n", " ... ... ... ...\n", "edge.3 A G 0.0055\n", "edge.3 G T 0.0000\n", "edge.3 G C 0.0011\n", "edge.3 G A 0.0039\n", "edge.3 G G 0.9950\n", "-----------------------------------\n", "\n", "176 rows x 4 columns" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stats['edge motif motif2 params']" ] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:c3dev] *", "language": "python", "name": "conda-env-c3dev-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.1" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }