|
614 | 614 | 20.56523380975767 |
615 | 615 | ], |
616 | 616 | "yaxis": "y" |
| 617 | + }, |
| 618 | + { |
| 619 | + "marker": { |
| 620 | + "color": "red", |
| 621 | + "size": 12, |
| 622 | + "symbol": "x" |
| 623 | + }, |
| 624 | + "mode": "markers", |
| 625 | + "showlegend": false, |
| 626 | + "type": "scatter", |
| 627 | + "x": [ |
| 628 | + 20.710113587648642, |
| 629 | + 4.312267729434556, |
| 630 | + 18.935473315914678, |
| 631 | + 17.68965247025577, |
| 632 | + 20.61053154671133 |
| 633 | + ], |
| 634 | + "y": [ |
| 635 | + 20.431212351814835, |
| 636 | + 4.189062767055896, |
| 637 | + 18.95856209889753, |
| 638 | + 17.674840683395807, |
| 639 | + 20.55944905349298 |
| 640 | + ] |
617 | 641 | } |
618 | 642 | ], |
619 | 643 | "layout": { |
|
1473 | 1497 | } |
1474 | 1498 | ], |
1475 | 1499 | "source": [ |
1476 | | - "import plotly.express as px\n", |
| 1500 | + "import plotly.graph_objects as go\n", |
1477 | 1501 | "\n", |
1478 | 1502 | "rmsd_df['pose_index'] = range(1, len(renamed_poses)+1)\n", |
1479 | 1503 | "rmsd_df['cluster'] = kmeans.labels_\n", |
|
1490 | 1514 | " labels={'1':'RMSD to pose 1',\n", |
1491 | 1515 | " '2':'RMSD to pose 2',}\n", |
1492 | 1516 | " )\n", |
| 1517 | + "scatter_fig.add_trace(\n", |
| 1518 | + " go.Scatter(\n", |
| 1519 | + " x = kmeans.cluster_centers_[:,0],\n", |
| 1520 | + " y = kmeans.cluster_centers_[:,1],\n", |
| 1521 | + " mode='markers',\n", |
| 1522 | + " marker=dict(color=\"red\", \n", |
| 1523 | + " symbol='x',\n", |
| 1524 | + " size=10),\n", |
| 1525 | + " showlegend=False,))\n", |
1493 | 1526 | "scatter_fig.update_traces(marker=dict(size=12))\n" |
1494 | 1527 | ] |
1495 | 1528 | }, |
1496 | 1529 | { |
1497 | 1530 | "cell_type": "markdown", |
1498 | 1531 | "metadata": {}, |
1499 | 1532 | "source": [ |
1500 | | - "Adding `molplotly` and specifying `mol_col` allows the 3D coordinates of the pose to be shown on mouseover!" |
| 1533 | + "Adding `molplotly` and specifying `mol_col` allows the 3D coordinates of the pose to be shown on mouseover!\n", |
| 1534 | + "\n", |
| 1535 | + "Unfortunately there are issues with handling additional non-molecular traces in `molplotly` so we'll have to re-create the scatter plot without the centroids." |
1501 | 1536 | ] |
1502 | 1537 | }, |
1503 | 1538 | { |
|
1520 | 1555 | " " |
1521 | 1556 | ], |
1522 | 1557 | "text/plain": [ |
1523 | | - "<IPython.lib.display.IFrame at 0x13733e8c0>" |
| 1558 | + "<IPython.lib.display.IFrame at 0x139627d30>" |
1524 | 1559 | ] |
1525 | 1560 | }, |
1526 | 1561 | "metadata": {}, |
|
1532 | 1567 | "\n", |
1533 | 1568 | "rmsd_df['mol'] = renamed_poses \n", |
1534 | 1569 | "\n", |
| 1570 | + "scatter_fig = px.scatter(rmsd_df, \n", |
| 1571 | + " x=\"1\", \n", |
| 1572 | + " y=\"2\",\n", |
| 1573 | + " color='cluster',\n", |
| 1574 | + " hover_name='pose_index',\n", |
| 1575 | + " width=1000,\n", |
| 1576 | + " height=800,\n", |
| 1577 | + " title='Clustering of ligand poses',\n", |
| 1578 | + " labels={'1':'RMSD to pose 1',\n", |
| 1579 | + " '2':'RMSD to pose 2',}\n", |
| 1580 | + " )\n", |
| 1581 | + "\n", |
| 1582 | + "scatter_fig.update_traces(marker=dict(size=12))\n", |
| 1583 | + "\n", |
1535 | 1584 | "app_clusters = molplotly.add_molecules(\n", |
1536 | 1585 | " fig=scatter_fig,\n", |
1537 | 1586 | " df=rmsd_df,\n", |
|
1553 | 1602 | }, |
1554 | 1603 | { |
1555 | 1604 | "cell_type": "code", |
1556 | | - "execution_count": 7, |
| 1605 | + "execution_count": 6, |
1557 | 1606 | "metadata": {}, |
1558 | 1607 | "outputs": [ |
1559 | 1608 | { |
|
1571 | 1620 | " " |
1572 | 1621 | ], |
1573 | 1622 | "text/plain": [ |
1574 | | - "<IPython.lib.display.IFrame at 0x13733f820>" |
| 1623 | + "<IPython.lib.display.IFrame at 0x13969be50>" |
1575 | 1624 | ] |
1576 | 1625 | }, |
1577 | 1626 | "metadata": {}, |
|
0 commit comments