[Rdkit-discuss] similarity maps look strange when displayed

2014-03-21 Thread Michał Nowotka
Look at the following example:

import gi
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import SimilarityMaps
import matplotlib.pyplot as plt
mol =
Chem.MolFromSmiles('COc12cc(C(=O)NN3CCN(c45nccnc54)CC3)oc21')
refmol = Chem.MolFromSmiles('CCCN(N1CCN(c2c2OC)CC1)Cc1ccc2c2c1')
fp = SimilarityMaps.GetAPFingerprint(mol, fpType='normal')
fig, maxweight = SimilarityMaps.GetSimilarityMapForFingerprint(refmol, mol,
SimilarityMaps.GetMorganFingerprint)
plt.show()

This displays similarity map. Unfortunately the image is not scaled to fit
available area and it's not centered. This cases problems with mpld3
library, which converts matplotlib to javascript:

from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import SimilarityMaps
import mpld3
mol =
Chem.MolFromSmiles('COc12cc(C(=O)NN3CCN(c45nccnc54)CC3)oc21')
refmol = Chem.MolFromSmiles('CCCN(N1CCN(c2c2OC)CC1)Cc1ccc2c2c1')
fp = SimilarityMaps.GetAPFingerprint(mol, fpType='normal')
fig, maxweight = SimilarityMaps.GetSimilarityMapForFingerprint(refmol, mol,
SimilarityMaps.GetMorganFingerprint)
mpld3.show_d3(fig)

Again, the image is much larger then drawing area and is not aligned.

I've tried several options: changing coordScale or scale parameter but
without success. Any help in displaying the image correctly usiing
plt.show() and/or mpld3.show_d3 would be appreciated.

Regards,
Michal Nowotka
--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] similarity maps look strange when displayed

2014-03-21 Thread sereina riniker
Hi Michal

I think this is related to a previous mailing list item (
https://www.mail-archive.com/rdkit-discuss@lists.sourceforge.net/msg03528.html
).

It has probably something to do with the bounding boxes (they get scaled
during the map generation process). In the previous case it was enough to
set bbox_inches='tight' when saving the image to solve the problem. Maybe
there is something similar for mpld3.

Best,
Sereina





2014-03-21 12:12 GMT+01:00 Michał Nowotka mmm...@gmail.com:

 Look at the following example:

 import gi
 from rdkit import Chem
 from rdkit.Chem import Draw
 from rdkit.Chem.Draw import SimilarityMaps
 import matplotlib.pyplot as plt
 mol =
 Chem.MolFromSmiles('COc12cc(C(=O)NN3CCN(c45nccnc54)CC3)oc21')
 refmol =
 Chem.MolFromSmiles('CCCN(N1CCN(c2c2OC)CC1)Cc1ccc2c2c1')
 fp = SimilarityMaps.GetAPFingerprint(mol, fpType='normal')
 fig, maxweight = SimilarityMaps.GetSimilarityMapForFingerprint(refmol,
 mol, SimilarityMaps.GetMorganFingerprint)
 plt.show()

 This displays similarity map. Unfortunately the image is not scaled to fit
 available area and it's not centered. This cases problems with mpld3
 library, which converts matplotlib to javascript:

 from rdkit import Chem
 from rdkit.Chem import Draw
 from rdkit.Chem.Draw import SimilarityMaps
 import mpld3
 mol =
 Chem.MolFromSmiles('COc12cc(C(=O)NN3CCN(c45nccnc54)CC3)oc21')
 refmol =
 Chem.MolFromSmiles('CCCN(N1CCN(c2c2OC)CC1)Cc1ccc2c2c1')
 fp = SimilarityMaps.GetAPFingerprint(mol, fpType='normal')
 fig, maxweight = SimilarityMaps.GetSimilarityMapForFingerprint(refmol,
 mol, SimilarityMaps.GetMorganFingerprint)
 mpld3.show_d3(fig)

 Again, the image is much larger then drawing area and is not aligned.

 I've tried several options: changing coordScale or scale parameter but
 without success. Any help in displaying the image correctly usiing
 plt.show() and/or mpld3.show_d3 would be appreciated.

 Regards,
 Michal Nowotka


 --
 Learn Graph Databases - Download FREE O'Reilly Book
 Graph Databases is the definitive new guide to graph databases and their
 applications. Written by three acclaimed leaders in the field,
 this first edition is now available. Download your free book today!
 http://p.sf.net/sfu/13534_NeoTech
 ___
 Rdkit-discuss mailing list
 Rdkit-discuss@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss