Skip to content

Instantly share code, notes, and snippets.

@gtsambos
Created July 10, 2019 17:46
Show Gist options
  • Save gtsambos/5aa3846af05e2fbf0b571a9918dda838 to your computer and use it in GitHub Desktop.
Save gtsambos/5aa3846af05e2fbf0b571a9918dda838 to your computer and use it in GitHub Desktop.
Divergence of two populations with msprime.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import msprime\n",
"from IPython.display import SVG"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"two populations, one splitting off another"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"20.00000000000003\"/><line x1=\"25.0\" x2=\"57.8125\" y1=\"20.00000000000003\" y2=\"20.00000000000003\"/><line x1=\"90.625\" x2=\"90.625\" y1=\"81.08277656676847\" y2=\"20.00000000000003\"/><line x1=\"90.625\" x2=\"57.8125\" y1=\"20.00000000000003\" y2=\"20.00000000000003\"/><line x1=\"62.5\" x2=\"62.5\" y1=\"157.9775106546139\" y2=\"81.08277656676847\"/><line x1=\"62.5\" x2=\"90.625\" y1=\"81.08277656676847\" y2=\"81.08277656676847\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"157.9775106546139\"/><line x1=\"50.0\" x2=\"62.5\" y1=\"157.9775106546139\" y2=\"157.9775106546139\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"157.9775106546139\"/><line x1=\"75.0\" x2=\"62.5\" y1=\"157.9775106546139\" y2=\"157.9775106546139\"/><line x1=\"118.75\" x2=\"118.75\" y1=\"114.4411267693111\" y2=\"81.08277656676847\"/><line x1=\"118.75\" x2=\"90.625\" y1=\"81.08277656676847\" y2=\"81.08277656676847\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"114.4411267693111\"/><line x1=\"100.0\" x2=\"118.75\" y1=\"114.4411267693111\" y2=\"114.4411267693111\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"143.1156479799271\" y2=\"114.4411267693111\"/><line x1=\"137.5\" x2=\"118.75\" y1=\"114.4411267693111\" y2=\"114.4411267693111\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"143.1156479799271\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"143.1156479799271\" y2=\"143.1156479799271\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"143.1156479799271\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"143.1156479799271\" y2=\"143.1156479799271\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"57.8125\" cy=\"20.00000000000003\" fill=\"red\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"90.625\" cy=\"81.08277656676847\" fill=\"red\" r=\"3\"/><circle cx=\"62.5\" cy=\"157.9775106546139\" fill=\"blue\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"118.75\" cy=\"114.4411267693111\" fill=\"red\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"137.5\" cy=\"143.1156479799271\" fill=\"red\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"95.625\" y=\"76.08277656676847\">11</text><text x=\"123.75\" y=\"109.4411267693111\">9</text><text x=\"142.5\" y=\"138.1156479799271\">8</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"57.5\" y=\"152.9775106546139\">7</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"57.8125\" y=\"15.000000000000028\">14</text><text x=\"25.0\" y=\"200.0\">5</text><text x=\"50.0\" y=\"200.0\">3</text><text x=\"75.0\" y=\"200.0\">4</text><text x=\"100.0\" y=\"200.0\">1</text><text x=\"125.0\" y=\"200.0\">0</text><text x=\"150.0\" y=\"200.0\">2</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"20.0\"/><line x1=\"25.0\" x2=\"57.8125\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"90.625\" x2=\"90.625\" y1=\"107.44230544986576\" y2=\"20.0\"/><line x1=\"90.625\" x2=\"57.8125\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"62.5\" x2=\"62.5\" y1=\"163.84607857260892\" y2=\"107.44230544986576\"/><line x1=\"62.5\" x2=\"90.625\" y1=\"107.44230544986576\" y2=\"107.44230544986576\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"163.84607857260892\"/><line x1=\"50.0\" x2=\"62.5\" y1=\"163.84607857260892\" y2=\"163.84607857260892\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"163.84607857260892\"/><line x1=\"75.0\" x2=\"62.5\" y1=\"163.84607857260892\" y2=\"163.84607857260892\"/><line x1=\"118.75\" x2=\"118.75\" y1=\"131.91129983410718\" y2=\"107.44230544986576\"/><line x1=\"118.75\" x2=\"90.625\" y1=\"107.44230544986576\" y2=\"107.44230544986576\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"131.91129983410718\"/><line x1=\"100.0\" x2=\"118.75\" y1=\"131.91129983410718\" y2=\"131.91129983410718\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"152.94461515735404\" y2=\"131.91129983410718\"/><line x1=\"137.5\" x2=\"118.75\" y1=\"131.91129983410718\" y2=\"131.91129983410718\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"152.94461515735404\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"152.94461515735404\" y2=\"152.94461515735404\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"152.94461515735404\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"152.94461515735404\" y2=\"152.94461515735404\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"57.8125\" cy=\"20.0\" fill=\"red\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"90.625\" cy=\"107.44230544986576\" fill=\"red\" r=\"3\"/><circle cx=\"62.5\" cy=\"163.84607857260892\" fill=\"blue\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"118.75\" cy=\"131.91129983410718\" fill=\"red\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"137.5\" cy=\"152.94461515735404\" fill=\"red\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"95.625\" y=\"102.44230544986576\">11</text><text x=\"123.75\" y=\"126.91129983410718\">9</text><text x=\"142.5\" y=\"147.94461515735404\">8</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"57.5\" y=\"158.84607857260892\">7</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"57.8125\" y=\"15.0\">16</text><text x=\"25.0\" y=\"200.0\">5</text><text x=\"50.0\" y=\"200.0\">3</text><text x=\"75.0\" y=\"200.0\">4</text><text x=\"100.0\" y=\"200.0\">1</text><text x=\"125.0\" y=\"200.0\">0</text><text x=\"150.0\" y=\"200.0\">2</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"20.0\"/><line x1=\"25.0\" x2=\"53.125\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"81.25\" x2=\"81.25\" y1=\"72.51579892854699\" y2=\"20.0\"/><line x1=\"81.25\" x2=\"53.125\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"72.51579892854699\"/><line x1=\"50.0\" x2=\"81.25\" y1=\"72.51579892854699\" y2=\"72.51579892854699\"/><line x1=\"112.5\" x2=\"112.5\" y1=\"107.44230544986576\" y2=\"72.51579892854699\"/><line x1=\"112.5\" x2=\"81.25\" y1=\"72.51579892854699\" y2=\"72.51579892854699\"/><line x1=\"87.5\" x2=\"87.5\" y1=\"163.84607857260892\" y2=\"107.44230544986576\"/><line x1=\"87.5\" x2=\"112.5\" y1=\"107.44230544986576\" y2=\"107.44230544986576\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"163.84607857260892\"/><line x1=\"75.0\" x2=\"87.5\" y1=\"163.84607857260892\" y2=\"163.84607857260892\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"163.84607857260892\"/><line x1=\"100.0\" x2=\"87.5\" y1=\"163.84607857260892\" y2=\"163.84607857260892\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"152.94461515735404\" y2=\"107.44230544986576\"/><line x1=\"137.5\" x2=\"112.5\" y1=\"107.44230544986576\" y2=\"107.44230544986576\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"152.94461515735404\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"152.94461515735404\" y2=\"152.94461515735404\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"152.94461515735404\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"152.94461515735404\" y2=\"152.94461515735404\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"53.125\" cy=\"20.0\" fill=\"red\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"81.25\" cy=\"72.51579892854699\" fill=\"red\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"112.5\" cy=\"107.44230544986576\" fill=\"red\" r=\"3\"/><circle cx=\"87.5\" cy=\"163.84607857260892\" fill=\"blue\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"137.5\" cy=\"152.94461515735404\" fill=\"red\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"86.25\" y=\"67.51579892854699\">12</text><text x=\"117.5\" y=\"102.44230544986576\">11</text><text x=\"142.5\" y=\"147.94461515735404\">8</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"82.5\" y=\"158.84607857260892\">7</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"53.125\" y=\"15.0\">16</text><text x=\"25.0\" y=\"200.0\">5</text><text x=\"50.0\" y=\"200.0\">1</text><text x=\"75.0\" y=\"200.0\">3</text><text x=\"100.0\" y=\"200.0\">4</text><text x=\"125.0\" y=\"200.0\">0</text><text x=\"150.0\" y=\"200.0\">2</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"20.0\"/><line x1=\"25.0\" x2=\"53.125\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"81.25\" x2=\"81.25\" y1=\"72.51579892854699\" y2=\"20.0\"/><line x1=\"81.25\" x2=\"53.125\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"72.51579892854699\"/><line x1=\"50.0\" x2=\"81.25\" y1=\"72.51579892854699\" y2=\"72.51579892854699\"/><line x1=\"112.5\" x2=\"112.5\" y1=\"107.44230544986576\" y2=\"72.51579892854699\"/><line x1=\"112.5\" x2=\"81.25\" y1=\"72.51579892854699\" y2=\"72.51579892854699\"/><line x1=\"87.5\" x2=\"87.5\" y1=\"163.84607857260892\" y2=\"107.44230544986576\"/><line x1=\"87.5\" x2=\"112.5\" y1=\"107.44230544986576\" y2=\"107.44230544986576\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"163.84607857260892\"/><line x1=\"75.0\" x2=\"87.5\" y1=\"163.84607857260892\" y2=\"163.84607857260892\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"163.84607857260892\"/><line x1=\"100.0\" x2=\"87.5\" y1=\"163.84607857260892\" y2=\"163.84607857260892\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"131.91129983410718\" y2=\"107.44230544986576\"/><line x1=\"137.5\" x2=\"112.5\" y1=\"107.44230544986576\" y2=\"107.44230544986576\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"131.91129983410718\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"131.91129983410718\" y2=\"131.91129983410718\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"131.91129983410718\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"131.91129983410718\" y2=\"131.91129983410718\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"53.125\" cy=\"20.0\" fill=\"red\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"81.25\" cy=\"72.51579892854699\" fill=\"red\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"112.5\" cy=\"107.44230544986576\" fill=\"red\" r=\"3\"/><circle cx=\"87.5\" cy=\"163.84607857260892\" fill=\"blue\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"137.5\" cy=\"131.91129983410718\" fill=\"red\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"86.25\" y=\"67.51579892854699\">12</text><text x=\"117.5\" y=\"102.44230544986576\">11</text><text x=\"142.5\" y=\"126.91129983410718\">9</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"82.5\" y=\"158.84607857260892\">7</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"53.125\" y=\"15.0\">16</text><text x=\"25.0\" y=\"200.0\">5</text><text x=\"50.0\" y=\"200.0\">1</text><text x=\"75.0\" y=\"200.0\">3</text><text x=\"100.0\" y=\"200.0\">4</text><text x=\"125.0\" y=\"200.0\">0</text><text x=\"150.0\" y=\"200.0\">2</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"20.0\"/><line x1=\"25.0\" x2=\"53.125\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"81.25\" x2=\"81.25\" y1=\"53.35523424579711\" y2=\"20.0\"/><line x1=\"81.25\" x2=\"53.125\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"53.35523424579711\"/><line x1=\"50.0\" x2=\"81.25\" y1=\"53.35523424579711\" y2=\"53.35523424579711\"/><line x1=\"112.5\" x2=\"112.5\" y1=\"94.50787987103254\" y2=\"53.35523424579711\"/><line x1=\"112.5\" x2=\"81.25\" y1=\"53.35523424579711\" y2=\"53.35523424579711\"/><line x1=\"87.5\" x2=\"87.5\" y1=\"160.96641576352476\" y2=\"94.50787987103254\"/><line x1=\"87.5\" x2=\"112.5\" y1=\"94.50787987103254\" y2=\"94.50787987103254\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"160.96641576352476\"/><line x1=\"75.0\" x2=\"87.5\" y1=\"160.96641576352476\" y2=\"160.96641576352476\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"160.96641576352476\"/><line x1=\"100.0\" x2=\"87.5\" y1=\"160.96641576352476\" y2=\"160.96641576352476\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"123.33881531216869\" y2=\"94.50787987103254\"/><line x1=\"137.5\" x2=\"112.5\" y1=\"94.50787987103254\" y2=\"94.50787987103254\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"123.33881531216869\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"123.33881531216869\" y2=\"123.33881531216869\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"123.33881531216869\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"123.33881531216869\" y2=\"123.33881531216869\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"53.125\" cy=\"20.0\" fill=\"red\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"81.25\" cy=\"53.35523424579711\" fill=\"red\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"112.5\" cy=\"94.50787987103254\" fill=\"red\" r=\"3\"/><circle cx=\"87.5\" cy=\"160.96641576352476\" fill=\"blue\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"137.5\" cy=\"123.33881531216869\" fill=\"red\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"86.25\" y=\"48.35523424579711\">12</text><text x=\"117.5\" y=\"89.50787987103254\">11</text><text x=\"142.5\" y=\"118.33881531216869\">9</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"82.5\" y=\"155.96641576352476\">7</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"53.125\" y=\"15.0\">15</text><text x=\"25.0\" y=\"200.0\">5</text><text x=\"50.0\" y=\"200.0\">1</text><text x=\"75.0\" y=\"200.0\">3</text><text x=\"100.0\" y=\"200.0\">4</text><text x=\"125.0\" y=\"200.0\">0</text><text x=\"150.0\" y=\"200.0\">2</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"62.5\" x2=\"62.5\" y1=\"94.50787987103254\" y2=\"20.0\"/><line x1=\"62.5\" x2=\"100.0\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"37.5\" x2=\"37.5\" y1=\"160.96641576352476\" y2=\"94.50787987103254\"/><line x1=\"37.5\" x2=\"62.5\" y1=\"94.50787987103254\" y2=\"94.50787987103254\"/><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"160.96641576352476\"/><line x1=\"25.0\" x2=\"37.5\" y1=\"160.96641576352476\" y2=\"160.96641576352476\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"160.96641576352476\"/><line x1=\"50.0\" x2=\"37.5\" y1=\"160.96641576352476\" y2=\"160.96641576352476\"/><line x1=\"87.5\" x2=\"87.5\" y1=\"123.33881531216869\" y2=\"94.50787987103254\"/><line x1=\"87.5\" x2=\"62.5\" y1=\"94.50787987103254\" y2=\"94.50787987103254\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"123.33881531216869\"/><line x1=\"75.0\" x2=\"87.5\" y1=\"123.33881531216869\" y2=\"123.33881531216869\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"123.33881531216869\"/><line x1=\"100.0\" x2=\"87.5\" y1=\"123.33881531216869\" y2=\"123.33881531216869\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"52.30447651636261\" y2=\"20.0\"/><line x1=\"137.5\" x2=\"100.0\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"52.30447651636261\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"52.30447651636261\" y2=\"52.30447651636261\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"52.30447651636261\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"52.30447651636261\" y2=\"52.30447651636261\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"100.0\" cy=\"20.0\" fill=\"red\" r=\"3\"/><circle cx=\"62.5\" cy=\"94.50787987103254\" fill=\"red\" r=\"3\"/><circle cx=\"37.5\" cy=\"160.96641576352476\" fill=\"blue\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"87.5\" cy=\"123.33881531216869\" fill=\"red\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"137.5\" cy=\"52.30447651636261\" fill=\"red\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"92.5\" y=\"118.33881531216869\">9</text><text x=\"142.5\" y=\"47.30447651636261\">13</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"57.5\" y=\"89.50787987103254\">11</text><text x=\"32.5\" y=\"155.96641576352476\">7</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"100.0\" y=\"15.0\">15</text><text x=\"25.0\" y=\"200.0\">3</text><text x=\"50.0\" y=\"200.0\">4</text><text x=\"75.0\" y=\"200.0\">0</text><text x=\"100.0\" y=\"200.0\">2</text><text x=\"125.0\" y=\"200.0\">1</text><text x=\"150.0\" y=\"200.0\">5</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"56.25\" x2=\"56.25\" y1=\"94.50787987103254\" y2=\"20.0\"/><line x1=\"56.25\" x2=\"87.5\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"37.5\" x2=\"37.5\" y1=\"160.96641576352476\" y2=\"94.50787987103254\"/><line x1=\"37.5\" x2=\"56.25\" y1=\"94.50787987103254\" y2=\"94.50787987103254\"/><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"160.96641576352476\"/><line x1=\"25.0\" x2=\"37.5\" y1=\"160.96641576352476\" y2=\"160.96641576352476\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"160.96641576352476\"/><line x1=\"50.0\" x2=\"37.5\" y1=\"160.96641576352476\" y2=\"160.96641576352476\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"94.50787987103254\"/><line x1=\"75.0\" x2=\"56.25\" y1=\"94.50787987103254\" y2=\"94.50787987103254\"/><line x1=\"118.75\" x2=\"118.75\" y1=\"52.30447651636261\" y2=\"20.0\"/><line x1=\"118.75\" x2=\"87.5\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"52.30447651636261\"/><line x1=\"100.0\" x2=\"118.75\" y1=\"52.30447651636261\" y2=\"52.30447651636261\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"177.28478140159623\" y2=\"52.30447651636261\"/><line x1=\"137.5\" x2=\"118.75\" y1=\"52.30447651636261\" y2=\"52.30447651636261\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"177.28478140159623\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"177.28478140159623\" y2=\"177.28478140159623\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"177.28478140159623\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"177.28478140159623\" y2=\"177.28478140159623\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"87.5\" cy=\"20.0\" fill=\"red\" r=\"3\"/><circle cx=\"56.25\" cy=\"94.50787987103254\" fill=\"red\" r=\"3\"/><circle cx=\"37.5\" cy=\"160.96641576352476\" fill=\"blue\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"118.75\" cy=\"52.30447651636261\" fill=\"red\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"137.5\" cy=\"177.28478140159623\" fill=\"red\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"123.75\" y=\"47.30447651636261\">13</text><text x=\"142.5\" y=\"172.28478140159623\">6</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"51.25\" y=\"89.50787987103254\">11</text><text x=\"32.5\" y=\"155.96641576352476\">7</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"87.5\" y=\"15.0\">15</text><text x=\"25.0\" y=\"200.0\">3</text><text x=\"50.0\" y=\"200.0\">4</text><text x=\"75.0\" y=\"200.0\">0</text><text x=\"100.0\" y=\"200.0\">5</text><text x=\"125.0\" y=\"200.0\">1</text><text x=\"150.0\" y=\"200.0\">2</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"43.75\" x2=\"43.75\" y1=\"52.30447651636261\" y2=\"20.0\"/><line x1=\"43.75\" x2=\"81.25\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"52.30447651636261\"/><line x1=\"25.0\" x2=\"43.75\" y1=\"52.30447651636261\" y2=\"52.30447651636261\"/><line x1=\"62.5\" x2=\"62.5\" y1=\"177.28478140159623\" y2=\"52.30447651636261\"/><line x1=\"62.5\" x2=\"43.75\" y1=\"52.30447651636261\" y2=\"52.30447651636261\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"177.28478140159623\"/><line x1=\"50.0\" x2=\"62.5\" y1=\"177.28478140159623\" y2=\"177.28478140159623\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"177.28478140159623\"/><line x1=\"75.0\" x2=\"62.5\" y1=\"177.28478140159623\" y2=\"177.28478140159623\"/><line x1=\"118.75\" x2=\"118.75\" y1=\"97.52545035361459\" y2=\"20.0\"/><line x1=\"118.75\" x2=\"81.25\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"97.52545035361459\"/><line x1=\"100.0\" x2=\"118.75\" y1=\"97.52545035361459\" y2=\"97.52545035361459\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"160.96641576352476\" y2=\"97.52545035361459\"/><line x1=\"137.5\" x2=\"118.75\" y1=\"97.52545035361459\" y2=\"97.52545035361459\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"160.96641576352476\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"160.96641576352476\" y2=\"160.96641576352476\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"160.96641576352476\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"160.96641576352476\" y2=\"160.96641576352476\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"81.25\" cy=\"20.0\" fill=\"red\" r=\"3\"/><circle cx=\"43.75\" cy=\"52.30447651636261\" fill=\"red\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"62.5\" cy=\"177.28478140159623\" fill=\"red\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"118.75\" cy=\"97.52545035361459\" fill=\"red\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"137.5\" cy=\"160.96641576352476\" fill=\"blue\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"67.5\" y=\"172.28478140159623\">6</text><text x=\"123.75\" y=\"92.52545035361459\">10</text><text x=\"142.5\" y=\"155.96641576352476\">7</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"38.75\" y=\"47.30447651636261\">13</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"81.25\" y=\"15.0\">15</text><text x=\"25.0\" y=\"200.0\">5</text><text x=\"50.0\" y=\"200.0\">1</text><text x=\"75.0\" y=\"200.0\">2</text><text x=\"100.0\" y=\"200.0\">0</text><text x=\"125.0\" y=\"200.0\">3</text><text x=\"150.0\" y=\"200.0\">4</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pop0 = msprime.PopulationConfiguration(sample_size=3, initial_size = 500, growth_rate = 0.00)\n",
"pop1 = msprime.PopulationConfiguration(sample_size=3, initial_size = 500, growth_rate = 0.00)\n",
"\n",
"demographic_events_ex = [\n",
" msprime.MassMigration(time = 1000, source = 1, dest = 0, proportion = 1)]\n",
"\n",
"ts = msprime.simulate(\n",
" population_configurations = [pop0, pop1], \n",
" length = 1e4, \n",
" demographic_events = demographic_events_ex, \n",
" recombination_rate = 1e-7\n",
")\n",
"\n",
"colour_map = {0:\"red\", 1:\"blue\"}\n",
"node_colours = {u.id: colour_map[u.population] for u in ts.nodes()}\n",
"\n",
"for tree in ts.trees():\n",
" display(SVG(tree.draw(node_colours=node_colours)))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"two populations diverging from an ancestral population"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"43.75\" x2=\"43.75\" y1=\"164.9581507976988\" y2=\"20.0\"/><line x1=\"43.75\" x2=\"81.25\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"164.9581507976988\"/><line x1=\"25.0\" x2=\"43.75\" y1=\"164.9581507976988\" y2=\"164.9581507976988\"/><line x1=\"62.5\" x2=\"62.5\" y1=\"178.05325918219248\" y2=\"164.9581507976988\"/><line x1=\"62.5\" x2=\"43.75\" y1=\"164.9581507976988\" y2=\"164.9581507976988\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"178.05325918219248\"/><line x1=\"50.0\" x2=\"62.5\" y1=\"178.05325918219248\" y2=\"178.05325918219248\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"178.05325918219248\"/><line x1=\"75.0\" x2=\"62.5\" y1=\"178.05325918219248\" y2=\"178.05325918219248\"/><line x1=\"118.75\" x2=\"118.75\" y1=\"132.4224192906033\" y2=\"20.0\"/><line x1=\"118.75\" x2=\"81.25\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"132.4224192906033\"/><line x1=\"100.0\" x2=\"118.75\" y1=\"132.4224192906033\" y2=\"132.4224192906033\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"138.4990844590638\" y2=\"132.4224192906033\"/><line x1=\"137.5\" x2=\"118.75\" y1=\"132.4224192906033\" y2=\"132.4224192906033\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"138.4990844590638\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"138.4990844590638\" y2=\"138.4990844590638\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"138.4990844590638\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"138.4990844590638\" y2=\"138.4990844590638\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"81.25\" cy=\"20.0\" fill=\"green\" r=\"3\"/><circle cx=\"43.75\" cy=\"164.9581507976988\" fill=\"red\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"62.5\" cy=\"178.05325918219248\" fill=\"red\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"118.75\" cy=\"132.4224192906033\" fill=\"blue\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"137.5\" cy=\"138.4990844590638\" fill=\"blue\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"67.5\" y=\"173.05325918219248\">6</text><text x=\"123.75\" y=\"127.4224192906033\">11</text><text x=\"142.5\" y=\"133.4990844590638\">10</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"38.75\" y=\"159.9581507976988\">7</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"81.25\" y=\"15.0\">13</text><text x=\"25.0\" y=\"200.0\">1</text><text x=\"50.0\" y=\"200.0\">0</text><text x=\"75.0\" y=\"200.0\">2</text><text x=\"100.0\" y=\"200.0\">5</text><text x=\"125.0\" y=\"200.0\">3</text><text x=\"150.0\" y=\"200.0\">4</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"43.75\" x2=\"43.75\" y1=\"140.00918170133468\" y2=\"20.0\"/><line x1=\"43.75\" x2=\"81.25\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"140.00918170133468\"/><line x1=\"25.0\" x2=\"43.75\" y1=\"140.00918170133468\" y2=\"140.00918170133468\"/><line x1=\"62.5\" x2=\"62.5\" y1=\"174.82432264328074\" y2=\"140.00918170133468\"/><line x1=\"62.5\" x2=\"43.75\" y1=\"140.00918170133468\" y2=\"140.00918170133468\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"174.82432264328074\"/><line x1=\"50.0\" x2=\"62.5\" y1=\"174.82432264328074\" y2=\"174.82432264328074\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"174.82432264328074\"/><line x1=\"75.0\" x2=\"62.5\" y1=\"174.82432264328074\" y2=\"174.82432264328074\"/><line x1=\"118.75\" x2=\"118.75\" y1=\"53.50847893432645\" y2=\"20.0\"/><line x1=\"118.75\" x2=\"81.25\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"53.50847893432645\"/><line x1=\"100.0\" x2=\"118.75\" y1=\"53.50847893432645\" y2=\"53.50847893432645\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"69.66412637802999\" y2=\"53.50847893432645\"/><line x1=\"137.5\" x2=\"118.75\" y1=\"53.50847893432645\" y2=\"53.50847893432645\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"69.66412637802999\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"69.66412637802999\" y2=\"69.66412637802999\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"69.66412637802999\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"69.66412637802999\" y2=\"69.66412637802999\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"81.25\" cy=\"20.0\" fill=\"green\" r=\"3\"/><circle cx=\"43.75\" cy=\"140.00918170133468\" fill=\"red\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"62.5\" cy=\"174.82432264328074\" fill=\"red\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"118.75\" cy=\"53.50847893432645\" fill=\"blue\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"137.5\" cy=\"69.66412637802999\" fill=\"blue\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"67.5\" y=\"169.82432264328074\">6</text><text x=\"123.75\" y=\"48.50847893432645\">11</text><text x=\"142.5\" y=\"64.66412637802999\">10</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"38.75\" y=\"135.00918170133468\">7</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"81.25\" y=\"15.0\">12</text><text x=\"25.0\" y=\"200.0\">1</text><text x=\"50.0\" y=\"200.0\">0</text><text x=\"75.0\" y=\"200.0\">2</text><text x=\"100.0\" y=\"200.0\">5</text><text x=\"125.0\" y=\"200.0\">3</text><text x=\"150.0\" y=\"200.0\">4</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"43.75\" x2=\"43.75\" y1=\"140.00918170133468\" y2=\"20.0\"/><line x1=\"43.75\" x2=\"81.25\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"140.00918170133468\"/><line x1=\"25.0\" x2=\"43.75\" y1=\"140.00918170133468\" y2=\"140.00918170133468\"/><line x1=\"62.5\" x2=\"62.5\" y1=\"174.82432264328074\" y2=\"140.00918170133468\"/><line x1=\"62.5\" x2=\"43.75\" y1=\"140.00918170133468\" y2=\"140.00918170133468\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"174.82432264328074\"/><line x1=\"50.0\" x2=\"62.5\" y1=\"174.82432264328074\" y2=\"174.82432264328074\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"174.82432264328074\"/><line x1=\"75.0\" x2=\"62.5\" y1=\"174.82432264328074\" y2=\"174.82432264328074\"/><line x1=\"118.75\" x2=\"118.75\" y1=\"69.66412637802999\" y2=\"20.0\"/><line x1=\"118.75\" x2=\"81.25\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"69.66412637802999\"/><line x1=\"100.0\" x2=\"118.75\" y1=\"69.66412637802999\" y2=\"69.66412637802999\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"83.31776521056537\" y2=\"69.66412637802999\"/><line x1=\"137.5\" x2=\"118.75\" y1=\"69.66412637802999\" y2=\"69.66412637802999\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"83.31776521056537\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"83.31776521056537\" y2=\"83.31776521056537\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"83.31776521056537\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"83.31776521056537\" y2=\"83.31776521056537\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"81.25\" cy=\"20.0\" fill=\"green\" r=\"3\"/><circle cx=\"43.75\" cy=\"140.00918170133468\" fill=\"red\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"62.5\" cy=\"174.82432264328074\" fill=\"red\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"118.75\" cy=\"69.66412637802999\" fill=\"blue\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"137.5\" cy=\"83.31776521056537\" fill=\"blue\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"67.5\" y=\"169.82432264328074\">6</text><text x=\"123.75\" y=\"64.66412637802999\">10</text><text x=\"142.5\" y=\"78.31776521056537\">9</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"38.75\" y=\"135.00918170133468\">7</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"81.25\" y=\"15.0\">12</text><text x=\"25.0\" y=\"200.0\">1</text><text x=\"50.0\" y=\"200.0\">0</text><text x=\"75.0\" y=\"200.0\">2</text><text x=\"100.0\" y=\"200.0\">4</text><text x=\"125.0\" y=\"200.0\">3</text><text x=\"150.0\" y=\"200.0\">5</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"200\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><g id=\"lines\" stroke=\"black\"><line x1=\"43.75\" x2=\"43.75\" y1=\"69.66412637802999\" y2=\"20.0\"/><line x1=\"43.75\" x2=\"81.25\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"25.0\" x2=\"25.0\" y1=\"180.0\" y2=\"69.66412637802999\"/><line x1=\"25.0\" x2=\"43.75\" y1=\"69.66412637802999\" y2=\"69.66412637802999\"/><line x1=\"62.5\" x2=\"62.5\" y1=\"83.31776521056537\" y2=\"69.66412637802999\"/><line x1=\"62.5\" x2=\"43.75\" y1=\"69.66412637802999\" y2=\"69.66412637802999\"/><line x1=\"50.0\" x2=\"50.0\" y1=\"180.0\" y2=\"83.31776521056537\"/><line x1=\"50.0\" x2=\"62.5\" y1=\"83.31776521056537\" y2=\"83.31776521056537\"/><line x1=\"75.0\" x2=\"75.0\" y1=\"180.0\" y2=\"83.31776521056537\"/><line x1=\"75.0\" x2=\"62.5\" y1=\"83.31776521056537\" y2=\"83.31776521056537\"/><line x1=\"118.75\" x2=\"118.75\" y1=\"96.16959547719229\" y2=\"20.0\"/><line x1=\"118.75\" x2=\"81.25\" y1=\"20.0\" y2=\"20.0\"/><line x1=\"100.0\" x2=\"100.0\" y1=\"180.0\" y2=\"96.16959547719229\"/><line x1=\"100.0\" x2=\"118.75\" y1=\"96.16959547719229\" y2=\"96.16959547719229\"/><line x1=\"137.5\" x2=\"137.5\" y1=\"174.82432264328074\" y2=\"96.16959547719229\"/><line x1=\"137.5\" x2=\"118.75\" y1=\"96.16959547719229\" y2=\"96.16959547719229\"/><line x1=\"125.0\" x2=\"125.0\" y1=\"180.0\" y2=\"174.82432264328074\"/><line x1=\"125.0\" x2=\"137.5\" y1=\"174.82432264328074\" y2=\"174.82432264328074\"/><line x1=\"150.0\" x2=\"150.0\" y1=\"180.0\" y2=\"174.82432264328074\"/><line x1=\"150.0\" x2=\"137.5\" y1=\"174.82432264328074\" y2=\"174.82432264328074\"/></g><g fill=\"black\" id=\"nodes\"><circle cx=\"81.25\" cy=\"20.0\" fill=\"green\" r=\"3\"/><circle cx=\"43.75\" cy=\"69.66412637802999\" fill=\"blue\" r=\"3\"/><circle cx=\"25.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"62.5\" cy=\"83.31776521056537\" fill=\"blue\" r=\"3\"/><circle cx=\"50.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"75.0\" cy=\"180.0\" fill=\"blue\" r=\"3\"/><circle cx=\"118.75\" cy=\"96.16959547719229\" fill=\"red\" r=\"3\"/><circle cx=\"100.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"137.5\" cy=\"174.82432264328074\" fill=\"red\" r=\"3\"/><circle cx=\"125.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/><circle cx=\"150.0\" cy=\"180.0\" fill=\"red\" r=\"3\"/></g><g fill=\"red\" id=\"mutations\"/><g font-size=\"14\" text-anchor=\"start\"><text x=\"67.5\" y=\"78.31776521056537\">9</text><text x=\"123.75\" y=\"91.16959547719229\">8</text><text x=\"142.5\" y=\"169.82432264328074\">6</text></g><g font-size=\"14\" text-anchor=\"end\"><text x=\"38.75\" y=\"64.66412637802999\">10</text></g><g font-size=\"14\" text-anchor=\"middle\"><text x=\"81.25\" y=\"15.0\">12</text><text x=\"25.0\" y=\"200.0\">4</text><text x=\"50.0\" y=\"200.0\">3</text><text x=\"75.0\" y=\"200.0\">5</text><text x=\"100.0\" y=\"200.0\">1</text><text x=\"125.0\" y=\"200.0\">0</text><text x=\"150.0\" y=\"200.0\">2</text></g><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"start\"/><g alignment-baseline=\"middle\" font-size=\"14\" font-style=\"italic\" text-anchor=\"end\"/></svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pop0 = msprime.PopulationConfiguration(sample_size=3, initial_size = 500, growth_rate = 0.00)\n",
"pop1 = msprime.PopulationConfiguration(sample_size=3, initial_size = 500, growth_rate = 0.00)\n",
"pop2 = msprime.PopulationConfiguration(sample_size=0, initial_size = 500, growth_rate = 0.00)\n",
"\n",
"demographic_events_ex = [\n",
" msprime.MassMigration(time = 1000, source = 0, dest = 2, proportion = 1),\n",
" msprime.MassMigration(time = 1000, source = 1, dest = 2, proportion = 1)]\n",
"\n",
"ts = msprime.simulate(\n",
" population_configurations = [pop0, pop1, pop2], \n",
" length = 1e4, \n",
" demographic_events = demographic_events_ex, \n",
" recombination_rate = 1e-7\n",
")\n",
"\n",
"colour_map = {0:\"red\", 1:\"blue\", 2:\"green\"}\n",
"node_colours = {u.id: colour_map[u.population] for u in ts.nodes()}\n",
"\n",
"for tree in ts.trees():\n",
" display(SVG(tree.draw(node_colours=node_colours)))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment