{
 "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": [
       "        <script type=\"text/javascript\">\n",
       "        window.PlotlyConfig = {MathJaxConfig: 'local'};\n",
       "        if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}\n",
       "        if (typeof require !== 'undefined') {\n",
       "        require.undef(\"plotly\");\n",
       "        requirejs.config({\n",
       "            paths: {\n",
       "                'plotly': ['https://cdn.plot.ly/plotly-latest.min']\n",
       "            }\n",
       "        });\n",
       "        require(['plotly'], function(Plotly) {\n",
       "            window._Plotly = Plotly;\n",
       "        });\n",
       "        }\n",
       "        </script>\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": [
       "<div>\n",
       "        \n",
       "        \n",
       "            <div id=\"521f65a1-deb4-48ea-ab1f-a5362d3c4d5f\" class=\"plotly-graph-div\" style=\"height:500px; width:500px;\"></div>\n",
       "            <script type=\"text/javascript\">\n",
       "                require([\"plotly\"], function(Plotly) {\n",
       "                    window.PLOTLYENV=window.PLOTLYENV || {};\n",
       "                    \n",
       "                if (document.getElementById(\"521f65a1-deb4-48ea-ab1f-a5362d3c4d5f\")) {\n",
       "                    Plotly.newPlot(\n",
       "                        '521f65a1-deb4-48ea-ab1f-a5362d3c4d5f',\n",
       "                        [{\"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]}],\n",
       "                        {\"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}},\n",
       "                        {\"responsive\": true}\n",
       "                    ).then(function(){\n",
       "                            \n",
       "var gd = document.getElementById('521f65a1-deb4-48ea-ab1f-a5362d3c4d5f');\n",
       "var x = new MutationObserver(function (mutations, observer) {{\n",
       "        var display = window.getComputedStyle(gd).display;\n",
       "        if (!display || display === 'none') {{\n",
       "            console.log([gd, 'removed!']);\n",
       "            Plotly.purge(gd);\n",
       "            observer.disconnect();\n",
       "        }}\n",
       "}});\n",
       "\n",
       "// Listen for the removal of the full notebook cells\n",
       "var notebookContainer = gd.closest('#notebook-container');\n",
       "if (notebookContainer) {{\n",
       "    x.observe(notebookContainer, {childList: true});\n",
       "}}\n",
       "\n",
       "// Listen for the clearing of the current output cell\n",
       "var outputEl = gd.closest('.output');\n",
       "if (outputEl) {{\n",
       "    x.observe(outputEl, {childList: true});\n",
       "}}\n",
       "\n",
       "                        })\n",
       "                };\n",
       "                });\n",
       "            </script>\n",
       "        </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from cogent3 import load_tree\n",
    "from cogent3.app import io, evo\n",
    "\n",
    "tree = load_tree(\"../data/primate_brca1.tree\")\n",
    "fig = tree.get_figure(contemporaneous=True)\n",
    "fig.style_edges(\"Human\", tip2=\"Orangutan\",\n",
    "                outgroup=\"Galago\",\n",
    "                line=dict(color=\"red\"))\n",
    "fig.show(width=500, height=500)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Specify a distinct rate matrix for the great apes\n",
    "\n",
    "As illustrated above, this is done by specifying the names of two \"ingroup\" tips (their last common ancestor is the ancestor of all edges of interest) and an \"outgroup\" tip. We can define the clade by Orangutan and one of Human, Chimpanzee or Gorilla. Any tip not a member of the clade outside suffices as an outgroup.\n",
    "\n",
    "To construct a `model` with this information, we create a dictionary that we assign to the `time_het` argument as follows."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "time_het = evo.model(\"GN\", tree=tree,\n",
    "                     time_het=[dict(tip_names=[\"Human\", \"Orangutan\"],\n",
    "                                     outgroup_name=\"Galago\")])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The outcome of this setting to `model` is that the black edges will share one rate matrix, the red edges another. We fit the model to the sample data set."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "reader = io.load_aligned(format=\"fasta\")\n",
    "aln = reader(\"../data/primate_brca1.fasta\")\n",
    "result = time_het(aln)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Examining the fitted likelihood function, the rate parameters differ between the edge sets."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<h4>GN</h4>\n",
       "<p>log-likelihood = -6982.2248</p>\n",
       "<p>number of free parameters = 36</p>\n",
       "<table>\n",
       "<style>\n",
       "tr:last-child {border-bottom: 1px solid #000;} tr > th {text-align: center !important;} tr > td {text-align: left !important;}\n",
       "</style>\n",
       "<caption style=\"color: rgb(250, 250, 250); background: rgba(30, 140, 200, 1); align=top;\"><span style=\"font-weight: bold;\">Edge params</span><span></span></caption>\n",
       "<thead style=\"background: rgba(161, 195, 209, 0.75); font-weight: bold; text-align: center;\">\n",
       "<th>edge</th>\n",
       "<th>parent</th>\n",
       "<th>length</th>\n",
       "<th>A&gt;C</th>\n",
       "<th>A&gt;G</th>\n",
       "<th>A&gt;T</th>\n",
       "<th>C&gt;A</th>\n",
       "<th>C&gt;G</th>\n",
       "<th>C&gt;T</th>\n",
       "</thead>\n",
       "<tbody>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Galago</td>\n",
       "<td>root</td>\n",
       "<td style=\"font-family: monospace !important;\">0.1730</td>\n",
       "<td style=\"font-family: monospace !important;\">1.0064</td>\n",
       "<td style=\"font-family: monospace !important;\">3.7857</td>\n",
       "<td style=\"font-family: monospace !important;\">1.0385</td>\n",
       "<td style=\"font-family: monospace !important;\">1.7266</td>\n",
       "<td style=\"font-family: monospace !important;\">2.3267</td>\n",
       "<td style=\"font-family: monospace !important;\">6.3442</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">HowlerMon</td>\n",
       "<td>root</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0451</td>\n",
       "<td style=\"font-family: monospace !important;\">1.0064</td>\n",
       "<td style=\"font-family: monospace !important;\">3.7857</td>\n",
       "<td style=\"font-family: monospace !important;\">1.0385</td>\n",
       "<td style=\"font-family: monospace !important;\">1.7266</td>\n",
       "<td style=\"font-family: monospace !important;\">2.3267</td>\n",
       "<td style=\"font-family: monospace !important;\">6.3442</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Rhesus</td>\n",
       "<td>edge.3</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0215</td>\n",
       "<td style=\"font-family: monospace !important;\">1.0064</td>\n",
       "<td style=\"font-family: monospace !important;\">3.7857</td>\n",
       "<td style=\"font-family: monospace !important;\">1.0385</td>\n",
       "<td style=\"font-family: monospace !important;\">1.7266</td>\n",
       "<td style=\"font-family: monospace !important;\">2.3267</td>\n",
       "<td style=\"font-family: monospace !important;\">6.3442</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Orangutan</td>\n",
       "<td>edge.2</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0077</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2103</td>\n",
       "<td style=\"font-family: monospace !important;\">3.5008</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2093</td>\n",
       "<td style=\"font-family: monospace !important;\">0.9013</td>\n",
       "<td style=\"font-family: monospace !important;\">1.3534</td>\n",
       "<td style=\"font-family: monospace !important;\">4.9566</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Gorilla</td>\n",
       "<td>edge.1</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0025</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2103</td>\n",
       "<td style=\"font-family: monospace !important;\">3.5008</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2093</td>\n",
       "<td style=\"font-family: monospace !important;\">0.9013</td>\n",
       "<td style=\"font-family: monospace !important;\">1.3534</td>\n",
       "<td style=\"font-family: monospace !important;\">4.9566</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Human</td>\n",
       "<td>edge.0</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0061</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2103</td>\n",
       "<td style=\"font-family: monospace !important;\">3.5008</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2093</td>\n",
       "<td style=\"font-family: monospace !important;\">0.9013</td>\n",
       "<td style=\"font-family: monospace !important;\">1.3534</td>\n",
       "<td style=\"font-family: monospace !important;\">4.9566</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Chimpanzee</td>\n",
       "<td>edge.0</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0028</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2103</td>\n",
       "<td style=\"font-family: monospace !important;\">3.5008</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2093</td>\n",
       "<td style=\"font-family: monospace !important;\">0.9013</td>\n",
       "<td style=\"font-family: monospace !important;\">1.3534</td>\n",
       "<td style=\"font-family: monospace !important;\">4.9566</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">edge.0</td>\n",
       "<td>edge.1</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0000</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2103</td>\n",
       "<td style=\"font-family: monospace !important;\">3.5008</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2093</td>\n",
       "<td style=\"font-family: monospace !important;\">0.9013</td>\n",
       "<td style=\"font-family: monospace !important;\">1.3534</td>\n",
       "<td style=\"font-family: monospace !important;\">4.9566</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">edge.1</td>\n",
       "<td>edge.2</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0034</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2103</td>\n",
       "<td style=\"font-family: monospace !important;\">3.5008</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2093</td>\n",
       "<td style=\"font-family: monospace !important;\">0.9013</td>\n",
       "<td style=\"font-family: monospace !important;\">1.3534</td>\n",
       "<td style=\"font-family: monospace !important;\">4.9566</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">edge.2</td>\n",
       "<td>edge.3</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0121</td>\n",
       "<td style=\"font-family: monospace !important;\">1.0064</td>\n",
       "<td style=\"font-family: monospace !important;\">3.7857</td>\n",
       "<td style=\"font-family: monospace !important;\">1.0385</td>\n",
       "<td style=\"font-family: monospace !important;\">1.7266</td>\n",
       "<td style=\"font-family: monospace !important;\">2.3267</td>\n",
       "<td style=\"font-family: monospace !important;\">6.3442</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">edge.3</td>\n",
       "<td>root</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0076</td>\n",
       "<td style=\"font-family: monospace !important;\">1.0064</td>\n",
       "<td style=\"font-family: monospace !important;\">3.7857</td>\n",
       "<td style=\"font-family: monospace !important;\">1.0385</td>\n",
       "<td style=\"font-family: monospace !important;\">1.7266</td>\n",
       "<td style=\"font-family: monospace !important;\">2.3267</td>\n",
       "<td style=\"font-family: monospace !important;\">6.3442</td>\n",
       "</tr>\n",
       "</tbody>\n",
       "</table>\n",
       "<table>\n",
       "<thead style=\"background: rgba(161, 195, 209, 0.75); font-weight: bold; text-align: center;\">\n",
       "<th>edge</th>\n",
       "<th>G&gt;A</th>\n",
       "<th>G&gt;C</th>\n",
       "<th>G&gt;T</th>\n",
       "<th>T&gt;A</th>\n",
       "<th>T&gt;C</th>\n",
       "</thead>\n",
       "<tbody>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Galago</td>\n",
       "<td style=\"font-family: monospace !important;\">9.0145</td>\n",
       "<td style=\"font-family: monospace !important;\">1.2462</td>\n",
       "<td style=\"font-family: monospace !important;\">0.7647</td>\n",
       "<td style=\"font-family: monospace !important;\">1.4577</td>\n",
       "<td style=\"font-family: monospace !important;\">3.5709</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">HowlerMon</td>\n",
       "<td style=\"font-family: monospace !important;\">9.0145</td>\n",
       "<td style=\"font-family: monospace !important;\">1.2462</td>\n",
       "<td style=\"font-family: monospace !important;\">0.7647</td>\n",
       "<td style=\"font-family: monospace !important;\">1.4577</td>\n",
       "<td style=\"font-family: monospace !important;\">3.5709</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Rhesus</td>\n",
       "<td style=\"font-family: monospace !important;\">9.0145</td>\n",
       "<td style=\"font-family: monospace !important;\">1.2462</td>\n",
       "<td style=\"font-family: monospace !important;\">0.7647</td>\n",
       "<td style=\"font-family: monospace !important;\">1.4577</td>\n",
       "<td style=\"font-family: monospace !important;\">3.5709</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Orangutan</td>\n",
       "<td style=\"font-family: monospace !important;\">4.6227</td>\n",
       "<td style=\"font-family: monospace !important;\">1.1149</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0000</td>\n",
       "<td style=\"font-family: monospace !important;\">0.3394</td>\n",
       "<td style=\"font-family: monospace !important;\">2.9912</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Gorilla</td>\n",
       "<td style=\"font-family: monospace !important;\">4.6227</td>\n",
       "<td style=\"font-family: monospace !important;\">1.1149</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0000</td>\n",
       "<td style=\"font-family: monospace !important;\">0.3394</td>\n",
       "<td style=\"font-family: monospace !important;\">2.9912</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Human</td>\n",
       "<td style=\"font-family: monospace !important;\">4.6227</td>\n",
       "<td style=\"font-family: monospace !important;\">1.1149</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0000</td>\n",
       "<td style=\"font-family: monospace !important;\">0.3394</td>\n",
       "<td style=\"font-family: monospace !important;\">2.9912</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">Chimpanzee</td>\n",
       "<td style=\"font-family: monospace !important;\">4.6227</td>\n",
       "<td style=\"font-family: monospace !important;\">1.1149</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0000</td>\n",
       "<td style=\"font-family: monospace !important;\">0.3394</td>\n",
       "<td style=\"font-family: monospace !important;\">2.9912</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">edge.0</td>\n",
       "<td style=\"font-family: monospace !important;\">4.6227</td>\n",
       "<td style=\"font-family: monospace !important;\">1.1149</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0000</td>\n",
       "<td style=\"font-family: monospace !important;\">0.3394</td>\n",
       "<td style=\"font-family: monospace !important;\">2.9912</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">edge.1</td>\n",
       "<td style=\"font-family: monospace !important;\">4.6227</td>\n",
       "<td style=\"font-family: monospace !important;\">1.1149</td>\n",
       "<td style=\"font-family: monospace !important;\">0.0000</td>\n",
       "<td style=\"font-family: monospace !important;\">0.3394</td>\n",
       "<td style=\"font-family: monospace !important;\">2.9912</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">edge.2</td>\n",
       "<td style=\"font-family: monospace !important;\">9.0145</td>\n",
       "<td style=\"font-family: monospace !important;\">1.2462</td>\n",
       "<td style=\"font-family: monospace !important;\">0.7647</td>\n",
       "<td style=\"font-family: monospace !important;\">1.4577</td>\n",
       "<td style=\"font-family: monospace !important;\">3.5709</td>\n",
       "</tr>\n",
       "<tr>\n",
       "<td style=\"background: rgba(161, 195, 209, 0.25); font-weight: 600;\">edge.3</td>\n",
       "<td style=\"font-family: monospace !important;\">9.0145</td>\n",
       "<td style=\"font-family: monospace !important;\">1.2462</td>\n",
       "<td style=\"font-family: monospace !important;\">0.7647</td>\n",
       "<td style=\"font-family: monospace !important;\">1.4577</td>\n",
       "<td style=\"font-family: monospace !important;\">3.5709</td>\n",
       "</tr>\n",
       "</tbody>\n",
       "</table>\n",
       "\n",
       "<table>\n",
       "<style>\n",
       "tr:last-child {border-bottom: 1px solid #000;} tr > th {text-align: center !important;} tr > td {text-align: left !important;}\n",
       "</style>\n",
       "<caption style=\"color: rgb(250, 250, 250); background: rgba(30, 140, 200, 1); align=top;\"><span style=\"font-weight: bold;\">Motif params</span><span></span></caption>\n",
       "<thead style=\"background: rgba(161, 195, 209, 0.75); font-weight: bold; text-align: center;\">\n",
       "<th>A</th>\n",
       "<th>C</th>\n",
       "<th>G</th>\n",
       "<th>T</th>\n",
       "</thead>\n",
       "<tbody>\n",
       "<tr>\n",
       "<td style=\"font-family: monospace !important;\">0.3754</td>\n",
       "<td style=\"font-family: monospace !important;\">0.1768</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2080</td>\n",
       "<td style=\"font-family: monospace !important;\">0.2398</td>\n",
       "</tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "GN\n",
       "log-likelihood = -6982.2248\n",
       "number of free parameters = 36\n",
       "================================================================================\n",
       "      edge    parent    length       A>C       A>G       A>T       C>A       C>G\n",
       "--------------------------------------------------------------------------------\n",
       "    Galago      root    0.1730    1.0064    3.7857    1.0385    1.7266    2.3267\n",
       " HowlerMon      root    0.0451    1.0064    3.7857    1.0385    1.7266    2.3267\n",
       "    Rhesus    edge.3    0.0215    1.0064    3.7857    1.0385    1.7266    2.3267\n",
       " Orangutan    edge.2    0.0077    0.2103    3.5008    0.2093    0.9013    1.3534\n",
       "   Gorilla    edge.1    0.0025    0.2103    3.5008    0.2093    0.9013    1.3534\n",
       "     Human    edge.0    0.0061    0.2103    3.5008    0.2093    0.9013    1.3534\n",
       "Chimpanzee    edge.0    0.0028    0.2103    3.5008    0.2093    0.9013    1.3534\n",
       "    edge.0    edge.1    0.0000    0.2103    3.5008    0.2093    0.9013    1.3534\n",
       "    edge.1    edge.2    0.0034    0.2103    3.5008    0.2093    0.9013    1.3534\n",
       "    edge.2    edge.3    0.0121    1.0064    3.7857    1.0385    1.7266    2.3267\n",
       "    edge.3      root    0.0076    1.0064    3.7857    1.0385    1.7266    2.3267\n",
       "--------------------------------------------------------------------------------\n",
       "\n",
       "continued: \n",
       "======================================================================\n",
       "      edge       C>T       G>A       G>C       G>T       T>A       T>C\n",
       "----------------------------------------------------------------------\n",
       "    Galago    6.3442    9.0145    1.2462    0.7647    1.4577    3.5709\n",
       " HowlerMon    6.3442    9.0145    1.2462    0.7647    1.4577    3.5709\n",
       "    Rhesus    6.3442    9.0145    1.2462    0.7647    1.4577    3.5709\n",
       " Orangutan    4.9566    4.6227    1.1149    0.0000    0.3394    2.9912\n",
       "   Gorilla    4.9566    4.6227    1.1149    0.0000    0.3394    2.9912\n",
       "     Human    4.9566    4.6227    1.1149    0.0000    0.3394    2.9912\n",
       "Chimpanzee    4.9566    4.6227    1.1149    0.0000    0.3394    2.9912\n",
       "    edge.0    4.9566    4.6227    1.1149    0.0000    0.3394    2.9912\n",
       "    edge.1    4.9566    4.6227    1.1149    0.0000    0.3394    2.9912\n",
       "    edge.2    6.3442    9.0145    1.2462    0.7647    1.4577    3.5709\n",
       "    edge.3    6.3442    9.0145    1.2462    0.7647    1.4577    3.5709\n",
       "----------------------------------------------------------------------\n",
       "\n",
       "====================================\n",
       "     A         C         G         T\n",
       "------------------------------------\n",
       "0.3754    0.1768    0.2080    0.2398\n",
       "------------------------------------"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result.lf"
   ]
  }
 ],
 "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
}
