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

Support dynamic components #2446

Merged
merged 4 commits into from
Oct 23, 2023

Conversation

jfoster17
Copy link
Member

Pull Request Template

Description

This is basically behind-the-scenes stuff to enable some functionality in glue-genes whereby some components update their values automatically in response to subset definitions changing and we want viewers to be able to react to these updated values. This should have no impact on existing glue viewers/etc.

@@ -228,6 +228,12 @@ def _check_subset_state_changed(self):
self._changed = True
self._state = state

def update_component_limits(self, components_changed):
Copy link
Member

Choose a reason for hiding this comment

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

Can you give a real life example of what this method would do? I wonder if this should be a more general method such as on_component_change or something similar that could be more versatile?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure -- in glue genes we have a SyncComponent which is a component that is added to a dataset when a subset is created and is updated as that subset is updated. For instance, we can calculate gene expression levels in a spatial dataset for a given subset of genes; as we change the subset of genes, we update the values in the SyncComponent on the spatial dataset, but we need to prompt the cmap_lim_helpers so that they display the full range of values in the new component.

Thus, a Viewer can add something like this:

@defer_draw
    def update_component_limits(self, components_changed):
        for limit_helper in [self.state.cmap_lim_helper]:
            if limit_helper.attribute in components_changed:
                limit_helper.update_values(force=True)
        self.redraw()

And the user experience is nice because changing the subset automatically scales the color to show the range of values.
Screen Recording 2023-09-21 at 5 10 13 PM

This could definitely be called something more general; I just had the one example and I thought a more specific name would be more readable in that case.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps the main 'hook' that gets called could be called with a more general name, and in your case it could then call from there update_component_limits?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, sounds good. I've updated to this approach.

@jfoster17
Copy link
Member Author

@astrofrog -- are we good to merge this now?

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Yes sorry for dropping the ball on this - thanks!

@astrofrog astrofrog merged commit fdc9157 into glue-viz:main Oct 23, 2023
21 checks passed
@jfoster17 jfoster17 deleted the support-dynamic-components branch October 31, 2023 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants