Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding multiMapping plots #237

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

RiesBen
Copy link
Contributor

@RiesBen RiesBen commented Sep 15, 2023

This pull request adds obne nice small feature to gufe mapping visualization, such you can show multiple mappings on one figure:

  • adding a Multi mapping grid img function draw_multiple_mappings - drafty right now.
    image

@RiesBen RiesBen linked an issue Sep 15, 2023 that may be closed by this pull request
@RiesBen RiesBen changed the title WIP: Adding mol name labels to mapping vis [WIP] Adding mol name labels to mapping vis Sep 15, 2023
@RiesBen RiesBen changed the title [WIP] Adding mol name labels to mapping vis [WIP] Adding multiMapping plots Sep 27, 2023
@RiesBen RiesBen added the enhancement New feature or request label Sep 27, 2023
@RiesBen RiesBen self-assigned this Sep 27, 2023
@RiesBen RiesBen changed the title [WIP] Adding multiMapping plots Adding multiMapping plots Oct 23, 2024
Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 14.28571% with 30 lines in your changes missing coverage. Please review.

Project coverage is 97.31%. Comparing base (e57f300) to head (038a7c8).

Files with missing lines Patch % Lines
gufe/visualization/mapping_visualization.py 14.28% 30 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #237      +/-   ##
==========================================
- Coverage   98.73%   97.31%   -1.42%     
==========================================
  Files          36       36              
  Lines        2049     2083      +34     
==========================================
+ Hits         2023     2027       +4     
- Misses         26       56      +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -305,3 +307,57 @@ def draw_unhighlighted_molecule(mol, d2d=None):
bond_colors=[{}],
highlight_color=red,
)


def _concat_images(imgs, buffer_spacing=4, ncols=3)-> Image:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the function that was used to create the grid in the example? This should probably be used by the draw_multipule_mappings function to create a grid layout.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this PR is a very old one and I wanted to bring it to your attention as I think it could be a handy feature.

hm... I wonder if this function should be used in line 360 somehow? I also wonder if the code developed away from the initial implementation?


return res

def draw_multiple_mappings(mappings:List, out_file_path:str=None)->Image:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the type hints, for mappings and out_file_path, maybe change the second to be output_file. We should expose the grid layout settings as well to recreate the example.

Copy link
Contributor

@jthorton jthorton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this idea, it offers a quick way to see all the edges and mappings in the network without iterating through the network or using the CLI viewer! It just needs a bit more work to enable visuals like the great example. Do you have time to finish this @RiesBen or is this something that should be handed over to me and Hannah?

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Various comments on dependencies, tests, and documentation.


def draw_multiple_mappings(mappings:List, out_file_path:str=None)->Image:
"""
This function generates an image, consisting of multiple mapping visualization.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a public facing method, it would need better docstring, especially on the "what does it do and what are my parameters".

"""
views = []
for m in mappings:
view = draw_mapping(m._compA_to_compB, m.componentA.to_rdkit(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would really need tests of some kind, even if they are smoke tests (although I do note that matplotlib has a series of methods to test image equality that could be useful here).


def _concat_images(imgs, buffer_spacing=4, ncols=3)-> Image:
"""
This helper function is constructing a Grid Image of given imgs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if it's private, this really could use with a better explanation of what the method does.

from itertools import chain
from PIL import Image, ImageOps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe pillow now replaces PIL, which should be used instead.

Additionally - we would need to work out what we want to do with this additional dependency. Probably would need to be an optional.

Copy link
Contributor

@jthorton jthorton Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use pillow I think rdkit has that as part of its recipe.

@RiesBen
Copy link
Contributor Author

RiesBen commented Oct 28, 2024

I really like this idea, it offers a quick way to see all the edges and mappings in the network without iterating through the network or using the CLI viewer! It just needs a bit more work to enable visuals like the great example. Do you have time to finish this @RiesBen or is this something that should be handed over to me and Hannah?

Hi @jthorton , I sadly will not have time to continue here :(

@jameseastwood jameseastwood assigned jthorton and unassigned RiesBen Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

adding mol name to mapping figure?
3 participants