statgen / locuszoom

A Javascript/d3 embeddable plugin for interactively visualizing statistical genetic data from customizable sources.
https://statgen.github.io/locuszoom/
MIT License
154 stars 29 forks source link

Highlight points that match a field #167

Closed abought closed 4 years ago

abought commented 5 years ago

Per feature request by @amkwong

Purpose

We often want to connect data between layers. For example, click a point on an annotation track, and see how it lines up with the same set of points on an association plot.

This PR adds a controlled way for data layers to communicate with each other. It will only look at one field at a time, and the event can come from anywhere (including itself).

Summary of changes

  1. New directive: match: {send: fieldname, receive: fieldname }.
  2. If a layer specifies match.send, then whenever a point is clicked, that layer will broadcast the value of that point for the specified field.
  3. Any layer with match.receive will identify the points whose fieldname matches the broadcasted value. These points will be marked with a synthetic field, like lz_highlight_match (exact name TBD).
  4. LocusZoom already has layout directives to control color, labels, etc, based on the value of a field. We have updated some old examples to demonstrate how the plot would update.

To do

Testing notes

Normally, data layers are isolated: changes to one layer do not affect others. This feature explicitly breaks that boundary: it allows one layer to trigger a full re-render of the plot.

Example to look at:

Scenarios to watch for:

abought commented 5 years ago

Initial sketch of proposal, as discussed with @skybullbobby earlier.

This is the first draft of a general mechanism, showing the use of events + match + custom color directives.

One area of note: the PheWAS plots we are using depend on a custom layer (called category_scatter) with some weird behavior- in particular, it's not very good at handling custom point display options. That data layer may need some improvements to work with this new mechanism.

To try it out: npm install && npx gulp build Then open examples/gwas_catalog.html in your browser using a dev server of your choice. (your IDE may do that for you).

abought commented 5 years ago

I've updated this branch to work with how category_scatter specifies color options.

It changes the rules for how we identify color (one object of options---> array of multiple options), in a way that is more consistent with how all our other data layers work. But it should seamlessly be backwards compatible with older phewas_scatter usages. Let me know if there are bugs.

I'll work on adding unit tests next, and keep this bug open until we get some feedback from our internal beta testers.