{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Specifying a non-stationary model with time-heterogeneous parameters\n", "\n", "A model is considered time-heterogeneous if rate matrix terms differ between edges on a tree.\n", "\n", "In this example, we load the and display our sample primate tree, highlighting the edge sets that will be assigned different rate matrices." ] }, { "cell_type": "code", "execution_count": 1, "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, 1, null, 0, 0, null, 0, 1, null, 0, 0, null, 0, 0.2, null, 0.2, 0.2, null, 0.2, 1.0, null, 0.2, 0.2, null, 0.2, 0.4, null ], "y": [ null, null, 2.6, 3.9000000000000004, null, 3.9000000000000004, 3.9000000000000004, null, 2.6, 2.6, null, 2.6, 2.6, null, 2.6, 0.08125000000000004, null, 0.08125000000000004, 0.08125000000000004, null, 0.08125000000000004, 1.3, null, 1.3, 1.3, null, 0.08125000000000004, -1.1375, null, -1.1375, -1.1375, null ] }, { "line": { "color": "red", "width": 1.25 }, "mode": "lines", "type": "scatter", "x": [ 0.4, 0.4, null, 0.4, 1.0, null, 0.4, 0.4, null, 0.4, 0.6000000000000001, null, 0.6000000000000001, 0.6000000000000001, null, 0.6000000000000001, 1.0, null, 0.6000000000000001, 0.6000000000000001, null, 0.6000000000000001, 0.8, null, 0.8, 0.8, null, 0.8, 1.0, null, 0.8, 0.8, null, 0.8, 1.0, null ], "y": [ -1.1375, 0.0, null, 0.0, 0.0, null, -1.1375, -2.275, null, -2.275, -2.275, null, -2.275, -1.3, null, -1.3, -1.3, null, -2.275, -3.25, null, -3.25, -3.25, null, -3.25, -2.6, null, -2.6, -2.6, null, -3.25, -3.9000000000000004, null, -3.9000000000000004, -3.9000000000000004, null ] }, { "hoverinfo": "text", "marker": { "color": "black", "size": 3, "symbol": "circle" }, "mode": "markers", "showlegend": false, "text": [ "root", "Galago", "HowlerMon", "edge.3", "Rhesus", "edge.2", "Orangutan", "edge.1", "Gorilla", "edge.0", "Chimpanzee", "Human" ], "type": "scatter", "x": [ 0, 1, 1, 0.2, 1.0, 0.4, 1.0, 0.6000000000000001, 1.0, 0.8, 1.0, 1.0 ], "y": [ 2.6, 3.9000000000000004, 2.6, 0.08125000000000004, 1.3, -1.1375, 0.0, -2.275, -1.3, -3.25, -2.6, -3.9000000000000004 ] } ], "layout": { "annotations": [ { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Galago", "textangle": 0, "x": 1.025, "xanchor": "left", "xref": "x", "y": 3.9000000000000004, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "HowlerMon", "textangle": 0, "x": 1.025, "xanchor": "left", "xref": "x", "y": 2.6, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Rhesus", "textangle": 0, "x": 1.025, "xanchor": "left", "xref": "x", "y": 1.3, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Orangutan", "textangle": 0, "x": 1.025, "xanchor": "left", "xref": "x", "y": 0.0, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Gorilla", "textangle": 0, "x": 1.025, "xanchor": "left", "xref": "x", "y": -1.3, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Chimpanzee", "textangle": 0, "x": 1.025, "xanchor": "left", "xref": "x", "y": -2.6, "yref": "y" }, { "font": { "family": "Inconsolata, monospace", "size": 12 }, "showarrow": false, "text": "Human", "textangle": 0, "x": 1.025, "xanchor": "left", "xref": "x", "y": -3.9000000000000004, "yref": "y" } ], "autosize": true, "font": { "family": "Balto", "size": 14 }, "height": 500, "hovermode": "closest", "margin": { "b": 50, "l": 50, "pad": 4, "r": 50, "t": 50 }, "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": [ "
log-likelihood = -6982.2248
\n", "number of free parameters = 36
\n", "edge | \n", "parent | \n", "length | \n", "A>C | \n", "A>G | \n", "A>T | \n", "C>A | \n", "C>G | \n", "C>T | \n", "\n", "\n", "
---|---|---|---|---|---|---|---|---|
Galago | \n", "root | \n", "0.1730 | \n", "1.0064 | \n", "3.7857 | \n", "1.0385 | \n", "1.7266 | \n", "2.3267 | \n", "6.3442 | \n", "
HowlerMon | \n", "root | \n", "0.0451 | \n", "1.0064 | \n", "3.7857 | \n", "1.0385 | \n", "1.7266 | \n", "2.3267 | \n", "6.3442 | \n", "
Rhesus | \n", "edge.3 | \n", "0.0215 | \n", "1.0064 | \n", "3.7857 | \n", "1.0385 | \n", "1.7266 | \n", "2.3267 | \n", "6.3442 | \n", "
Orangutan | \n", "edge.2 | \n", "0.0077 | \n", "0.2103 | \n", "3.5008 | \n", "0.2093 | \n", "0.9013 | \n", "1.3534 | \n", "4.9566 | \n", "
Gorilla | \n", "edge.1 | \n", "0.0025 | \n", "0.2103 | \n", "3.5008 | \n", "0.2093 | \n", "0.9013 | \n", "1.3534 | \n", "4.9566 | \n", "
Human | \n", "edge.0 | \n", "0.0061 | \n", "0.2103 | \n", "3.5008 | \n", "0.2093 | \n", "0.9013 | \n", "1.3534 | \n", "4.9566 | \n", "
Chimpanzee | \n", "edge.0 | \n", "0.0028 | \n", "0.2103 | \n", "3.5008 | \n", "0.2093 | \n", "0.9013 | \n", "1.3534 | \n", "4.9566 | \n", "
edge.0 | \n", "edge.1 | \n", "0.0000 | \n", "0.2103 | \n", "3.5008 | \n", "0.2093 | \n", "0.9013 | \n", "1.3534 | \n", "4.9566 | \n", "
edge.1 | \n", "edge.2 | \n", "0.0034 | \n", "0.2103 | \n", "3.5008 | \n", "0.2093 | \n", "0.9013 | \n", "1.3534 | \n", "4.9566 | \n", "
edge.2 | \n", "edge.3 | \n", "0.0121 | \n", "1.0064 | \n", "3.7857 | \n", "1.0385 | \n", "1.7266 | \n", "2.3267 | \n", "6.3442 | \n", "
edge.3 | \n", "root | \n", "0.0076 | \n", "1.0064 | \n", "3.7857 | \n", "1.0385 | \n", "1.7266 | \n", "2.3267 | \n", "6.3442 | \n", "
edge | \n", "G>A | \n", "G>C | \n", "G>T | \n", "T>A | \n", "T>C | \n", "\n", "\n", "
---|---|---|---|---|---|
Galago | \n", "9.0145 | \n", "1.2462 | \n", "0.7647 | \n", "1.4577 | \n", "3.5709 | \n", "
HowlerMon | \n", "9.0145 | \n", "1.2462 | \n", "0.7647 | \n", "1.4577 | \n", "3.5709 | \n", "
Rhesus | \n", "9.0145 | \n", "1.2462 | \n", "0.7647 | \n", "1.4577 | \n", "3.5709 | \n", "
Orangutan | \n", "4.6227 | \n", "1.1149 | \n", "0.0000 | \n", "0.3394 | \n", "2.9912 | \n", "
Gorilla | \n", "4.6227 | \n", "1.1149 | \n", "0.0000 | \n", "0.3394 | \n", "2.9912 | \n", "
Human | \n", "4.6227 | \n", "1.1149 | \n", "0.0000 | \n", "0.3394 | \n", "2.9912 | \n", "
Chimpanzee | \n", "4.6227 | \n", "1.1149 | \n", "0.0000 | \n", "0.3394 | \n", "2.9912 | \n", "
edge.0 | \n", "4.6227 | \n", "1.1149 | \n", "0.0000 | \n", "0.3394 | \n", "2.9912 | \n", "
edge.1 | \n", "4.6227 | \n", "1.1149 | \n", "0.0000 | \n", "0.3394 | \n", "2.9912 | \n", "
edge.2 | \n", "9.0145 | \n", "1.2462 | \n", "0.7647 | \n", "1.4577 | \n", "3.5709 | \n", "
edge.3 | \n", "9.0145 | \n", "1.2462 | \n", "0.7647 | \n", "1.4577 | \n", "3.5709 | \n", "
A | \n", "C | \n", "G | \n", "T | \n", "\n", "\n", "
---|---|---|---|
0.3754 | \n", "0.1768 | \n", "0.2080 | \n", "0.2398 | \n", "