GMOD / jbrowse-components

Source code for JBrowse 2, a modern React-based genome browser
https://jbrowse.org/jb2
Apache License 2.0
206 stars 62 forks source link

Allow custom filtering expressions to be applied to state or configuration of tracks #1988

Closed cmdcolin closed 4 months ago

cmdcolin commented 3 years ago

The alignments track implemented a number of bespoke filtering options. It could be useful for our other tracks to have some filtering ability too. The VCF for example, I may want to look for translocations specifically, or I might want to filter out a specific gene in a gene track for demonstration purposes

cmdcolin commented 2 years ago

Some ideas about filtering discussed in gitter cc @scottcain , RE: having same GFF serve multiple tracks each with different filtering expressions.

This may download more data than is needed for each track since much data gets filtered out, but could still be interesting.

cmdcolin commented 2 years ago

We could also, if we want to really streamline things for users, make a flatfile-to-json for jbrowse 2

cmdcolin commented 2 years ago

This could potentially involve writing sorting, tabix, and bgzip in JS. We have already seen that properly advising how to sort GFF is difficult so taking this into our own hands could be useful #2831

cmdcolin commented 1 year ago

some possible implementation notes

1) the "ServerSideRendererType" which is used for most tracks is currently responsive to a "filters" property being used in the renderProps of a display method. "filters" is an array of jexl callbacks (just plain strings of the type "jexl:get(feature,'start')<100?true:false, receiving a "feature" object, and returning true or false to keep it 2) To implement this in a way the config system can hook into, we could make a "filter" slot on the base track or something that is just a single string, that can be a jexl callback, that gets added to this filters property of renderProps [1] 3) To make it something even easier to access, this is often done by adding a custom GUI element in e.g. to trackMenuItems. The trackMenuItem may pop up a dialog, and manipulate the track state instead of the config. This could allow the user to interactively choose edit their filters more easily than manually writing jexl callbacks in a copy of a track in the config editor. To make custom trackMenuItems, you can subclass a particular display type or extend it with the extendPluggableElements ExtensionPoint via a plugin for example

[1] I don't make it a stringArray of multiple filters because changing a stringArray to a jexl callback would be a single jexl callback that returns an array of strings, not an array of jexl callbacks. would need a different config slot type for that

cmdcolin commented 1 year ago

cc @andrzejgrzelak

cmdcolin commented 1 year ago

i'll just note that the alignments track could add this feature as a special filter for the sashimi's too if it is helpful

cmdcolin commented 10 months ago

this was added in internal form to alignments by @carolinebridge-oicr , could be generalized to other tracks and make UI for filter