Skip to content

explainability vizualisation: scaling image size makes molecule depiction small and thin #126

@JochenSiegWork

Description

@JochenSiegWork

Setting the image size in pixels to a larger number (e.g. for a scientific poster) makes the molecule depiction thin and small

structure_heatmap_shap(explanation, width=2000, height=2000) instead of the default 600x600 pixels.

Adding the last three lines to the drawer option seems to fix the problem for this particular case.

    drawer = Draw.MolDraw2DCairo(width, height)
    # Coloring atoms of element 0 to 100 black
    drawer.drawOptions().updateAtomPalette({i: (0, 0, 0, 1) for i in range(100)})
    draw_opt = drawer.drawOptions()
    draw_opt.padding = 0.2
    draw_opt.bondLineWidth = 7
    draw_opt.minFontSize= 65
    draw_opt.additionalAtomLabelPadding = 0.1

However, this is not an automated way to scale bond line width and font size with pixel size. I see three options here:

  1. There is a way to automatically scale bond line width and font size in RDKit. A more recent blog post
  2. Scale the parameters with some transformation that we determine empirically. minFontSize seems to scale quadratically with pixels but bondLineWidth isn't.
  3. Let the user decide and make the drawOptions a parameter to structure_heatmap_shap.

Metadata

Metadata

Labels

status: backlogThings we will work on, but not right now

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions