Skip to content

Commit f30f61e

Browse files
author
wjm41
authored
Merge branch 'main' into feat/SVG
2 parents fbe9a7e + bde11c4 commit f30f61e

3 files changed

Lines changed: 68 additions & 32 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
setup*
1+
# Setup files for pypi
22
MANIFEST
33
dist/
44
molplotly.egg-info/
55

6+
# VS-Code files
67
*.pyc
78
.DS_Store
89
settings.json

README.md

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
# molplotly
2+
23
[![Powered by RDKit](https://img.shields.io/static/v1?label=Powered%20by&message=RDKit&color=3838ff&style=flat&logo=data:image/x-icon;base64,AAABAAEAEBAQAAAAAABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAMAABILAAASCwAAAAAAAAAAAADc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nz/FBT/FBT/FBT/FBT/FBT/FBTc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nz/FBT/PBT/PBT/PBT/PBT/PBT/PBT/FBTc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nz/FBT/PBT/ZGT/ZGT/ZGT/ZGT/ZGT/ZGT/PBT/FBTc3Nzc3Nzc3Nzc3Nzc3Nz/FBT/PBT/ZGT/ZGT/ZGT/ZGT/ZGT/ZGT/ZGT/ZGT/PBT/FBTc3Nzc3Nzc3Nz/FBT/PBT/ZGT/ZGT/ZGT/jIz/jIz/jIz/jIz/ZGT/ZGT/ZGT/PBT/FBTc3Nzc3Nz/FBT/PBT/ZGT/ZGT/jIz/jIz/jIz/jIz/jIz/jIz/ZGT/ZGT/PBT/FBTc3Nzc3Nz/FBT/PBT/ZGT/ZGT/jIz/jIz/tLT/tLT/jIz/jIz/ZGT/ZGT/PBT/FBTc3Nzc3Nz/FBT/PBT/ZGT/ZGT/jIz/jIz/tLT/tLT/jIz/jIz/ZGT/ZGT/PBT/FBTc3Nzc3Nz/FBT/PBT/ZGT/ZGT/jIz/jIz/jIz/jIz/jIz/jIz/ZGT/ZGT/PBT/FBTc3Nzc3Nz/FBT/PBT/ZGT/ZGT/ZGT/jIz/jIz/jIz/jIz/ZGT/ZGT/ZGT/PBT/FBTc3Nzc3Nzc3Nz/FBT/PBT/ZGT/ZGT/ZGT/ZGT/ZGT/ZGT/ZGT/ZGT/PBT/FBTc3Nzc3Nzc3Nzc3Nzc3Nz/FBT/PBT/ZGT/ZGT/ZGT/ZGT/ZGT/ZGT/PBT/FBTc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nz/FBT/PBT/PBT/PBT/PBT/PBT/PBT/FBTc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nz/FBT/FBT/FBT/FBT/FBT/FBTc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nz/////+B////AP///gB///wAP//4AB//+AAf//gAH//4AB//+AAf//gAH//8AD///gB///8A////gf////////)](https://www.rdkit.org/)
3-
[![Pypi version](https://img.shields.io/pypi/v/molplotly)](https://pypi.python.org/pypi/molplotly)
4+
[![PyPI version](https://img.shields.io/pypi/v/molplotly)](https://pypi.python.org/pypi/molplotly)
45

5-
`molplotly` is an add-on to `plotly` built on RDKit which allows 2D images of molecules to be shown in `plotly` figures when hovering over the datapoints.
6+
`molplotly` is an add-on to `plotly` built on RDKit which allows 2D images of molecules to be shown in `plotly` figures when hovering over the data points.
67

78
![Beautiful :)](https://raw.githubusercontent.com/wjm41/molplotly/main/images/color.gif)
89
![Beautiful :)](https://raw.githubusercontent.com/wjm41/molplotly/main/images/pca.gif)
910

10-
Required packages:
11-
- [rdkit](http://rdkit.org/docs/Install.html)
12-
- [pandas](https://pandas.pydata.org/docs/getting_started/index.html)
13-
- [jupyter_dash](https://github.com/plotly/jupyter-dash)
14-
1511
➡️  A readable walkthrough of how to use the package together with some useful examples can be found in [this blog post](https://www.wmccorkindale.com/post/introducing-molplotly) while a runnable notebook can be found in `example.ipynb` :)
1612

13+
## ⬇️ Installation
14+
15+
```sh
16+
pip install molplotly
17+
conda install rdkit
18+
```
19+
1720
## 📜  Usage
1821

1922
```python
@@ -31,62 +34,70 @@ df_esol['y_true'] = df_esol['measured log solubility in mols per litre']
3134
fig = px.scatter(df_esol, x="y_true", y="y_pred")
3235

3336
# add molecules to the plotly graph - returns a Dash app
34-
app = molplotly.add_molecules(fig=fig,
35-
df=df_esol,
36-
smiles_col='smiles',
37-
title_col='Compound ID',
37+
app = molplotly.add_molecules(fig=fig,
38+
df=df_esol,
39+
smiles_col='smiles',
40+
title_col='Compound ID',
3841
)
3942

4043
# run Dash app inline in notebook (or in an external server)
4144
app.run_server(mode='inline', port=8011, height=1000)
4245
```
46+
4347
#### Input parameters
44-
* `fig` : plotly.graph_objects.Figure object\
48+
49+
- `fig` : plotly.graph_objects.Figure object\
4550
a plotly figure object containing datapoints plotted from df
46-
* `df` : pandas.DataFrame object\
51+
52+
- `df` : pandas.DataFrame object\
4753
a pandas dataframe that contains the data plotted in fig
48-
* `smiles_col` : str, optional\
54+
- `smiles_col` : str, optional\
4955
name of the column in df containing the smiles plotted in fig (default 'SMILES')
50-
* `show_img` : bool, optional\
56+
- `show_img` : bool, optional\
5157
whether or not to generate the molecule image in the dash app (default True)
52-
* `title_col` : str, optional\
58+
- `title_col` : str, optional\
5359
name of the column in df to be used as the title entry in the hover box (default None)
54-
* `show_coords` : bool, optional\
60+
- `show_coords` : bool, optional\
5561
whether or not to show the coordinates of the data point in the hover box (default True)
56-
* `caption_cols` : list, optional\
62+
- `caption_cols` : list, optional\
5763
list of column names in df to be included in the hover box (default None)
58-
* `caption_transform` : dict, optional\
64+
- `caption_transform` : dict, optional\
5965
Functions applied to specific items in all cells. The dict must follow a key: function structure where the key must correspond to one of the columns in subset or tooltip. (default {})
60-
* `color_col` : str, optional\
66+
- `color_col` : str, optional\
6167
name of the column in df that is used to color the datapoints in df - necessary when there is discrete conditional coloring (default None)
62-
* `wrap` : bool, optional\
68+
- `wrap` : bool, optional\
6369
whether or not to wrap the title text to multiple lines if the length of the text is too long (default True)
64-
* `wraplen` : int, optional\
70+
- `wraplen` : int, optional\
6571
the threshold length of the title text before wrapping begins - adjust when changing the width of the hover box (default 20)
66-
* `width` : int, optional\
72+
- `width` : int, optional\
6773
the width in pixels of the hover box (default 150)
68-
* `fontfamily` : str, optional\
74+
- `fontfamily` : str, optional\
6975
the font family used in the hover box (default 'Arial')
70-
* `fontsize` : int, optional\
76+
- `fontsize` : int, optional\
7177
the font size used in the hover box - the font of the title line is fontsize+2 (default 12)
72-
78+
7379
#### Output parameters
80+
7481
by default a JupyterDash `app` is returned which can be run inline in a jupyter notebook or deployed on a server via `app.run_server()`
7582

76-
* The recommended `height` of the app is `50+(height of the plotly figure)`.
77-
* For the `port` of the app, make sure you don't pick the same `port` as another `molplotly` plot otherwise the tooltips will clash with each other!
83+
- The recommended `height` of the app is `50+(height of the plotly figure)`.
84+
- For the `port` of the app, make sure you don't pick the same `port` as another `molplotly` plot otherwise the tooltips will clash with each other!
7885

7986
## 💻   Can I run this in colab?
87+
8088
JupyterDash is supposed to have support for Google Colab but at some point that seems to have broken... Keep an eye on the raised issue [here](https://github.com/plotly/jupyter-dash/issues/10)!
8189

8290
## 💾   Can I save these plots?
91+
8392
`moltplotly` works using a Dash app which is non-trivial to export because server side javascript is needed in addition to HTML/CSS styling ([as detailed here](https://stackoverflow.com/questions/60097577/how-to-export-a-plotly-dashboard-app-into-a-html-standalone-file-to-share-with-t))
8493

8594
Until I find a way to get around that, the best alternative is exporting the plotly figure without molecules showing :( as detailed in this [page](https://plotly.com/python/interactive-html-export/). If you want to use it in a presentation I'd suggest keeping the figure open in a browser and changing windows to it during your talk!
8695

87-
## 🛑  Warning about memory size
96+
## 🛑  Warning about memory size
97+
8898
Just adding a warning here that memory usage in a notebook can increase significanly when using plotly (not `molplotly`'s fault!). If you notice your jupyter notebook slowing down, plotly itself is a likely culprit... In that case I'd consider either using plotly with [static image rendering](https://plotly.com/python/renderers/#static-image-renderers), or ... use [seaborn](https://seaborn.pydata.org/index.html) :P
8999

90100
## Acknowledgements
91-
* [@wjm41](https://github.com/wjm41) (contributor)
92-
* [@RokasEl](https://github.com/RokasEl) (contributor)
101+
102+
- [@wjm41](https://github.com/wjm41) (contributor)
103+
- [@RokasEl](https://github.com/RokasEl) (contributor)

setup.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from setuptools import find_packages, setup
2+
3+
setup(
4+
name="molplotly",
5+
version="1.0.1",
6+
description="plotly add-on to render molecule images on mouseover",
7+
long_description=open("README.md").read(),
8+
long_description_content_type="text/markdown",
9+
url="https://github.com/wjm41/molplotly",
10+
author="William McCorkindale",
11+
license="Apache License 2.0",
12+
packages=find_packages(),
13+
install_requires=[
14+
"dash",
15+
"plotly",
16+
"pandas",
17+
],
18+
classifiers=[
19+
"Programming Language :: Python :: 3.8",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Topic :: Scientific/Engineering",
23+
],
24+
)

0 commit comments

Comments
 (0)