Open scottcain opened 9 years ago
This feature request was a result of JBrowse being rolled out at WormBase:
Colin,
I was thinking of having it do the filtering within Apollo, but was not sure if this was a “JBrowse” or an “Apollo” feature.
Nathan
On Sep 15, 2014, at 12:31 PM, Scott Cain notifications@github.com wrote:
It would be really great to be able to sort and/or filter by feature score, regardless of the track type. While BAM and VCF data can be filtered in some ways, a fundamental option would be to allow a user-configurable cutoff score.
A potentially more difficult option would be to allow features to be sorted by score. This would keep a multitude of poorly scoring features from pushing the good scoring features of the bottom of the "max height reached" bottom.
— Reply to this email directly or view it on GitHub.
Filtering is definitely provided by JBrowse (FilterFeatureMixin). It can also be both global or on a track-specific basis. This means that, for example, you can either call browser.setFeatureFilter or track.setFeatureFilter to perform filtering. Or you can use addFeatureFilter/removeFeatureFilter to create a chain of them.
Here's a simple plugin for filtering that I refactored out of webapollo:
define([
'dojo/_base/declare',
'JBrowse/Plugin',
'dijit/CheckedMenuItem'
],
function(
declare,
JBrowsePlugin,
dijitCheckedMenuItem
) {
return declare( JBrowsePlugin,
{
constructor: function( args ) {
var browser = this.browser;
var thisB = this;
var plus_strand_toggle = new dijitCheckedMenuItem(
{
label: "Hide plus strand",
checked: browser.cookie("plusStrandFilter")=="1",
onClick: function(event) {
browser.cookie("plusStrandFilter",this.get("checked")?"1":"0");
thisB.strandFilter("plusStrandFilter",thisB.plusStrandFilter);
browser.view.redrawTracks();
}
});
browser.addGlobalMenuItem( 'view', plus_strand_toggle );
var minus_strand_toggle = new dijitCheckedMenuItem(
{
label: "Hide minus strand",
checked: browser.cookie("minusStandFilter")=="1",
onClick: function(event) {
browser.cookie("minusStrandFilter",this.get("checked")?"1":"0");
thisB.strandFilter("minusStrandFilter",thisB.minusStrandFilter);
browser.view.redrawTracks();
}
});
browser.addGlobalMenuItem( 'view', minus_strand_toggle );
this.strandFilter("minusStrandFilter",this.minusStrandFilter);
this.strandFilter("plusStrandFilter",this.plusStrandFilter);
},
strandFilter: function(name,callback) {
var browser=this.browser;
if(browser.cookie(name)=="1") {
browser.addFeatureFilter(callback,name)
} else {
browser.removeFeatureFilter(name);
}
},
minusStrandFilter: function(feature) {
var strand = feature.get('strand');
return (strand == 1 || strand == '+') { return true; }
else { return false; }
},
plusStrandFilter: function(feature) {
var strand = feature.get('strand');
if (strand == -1 || strand == '-') { return true; }
else { return false; }
}
});
});
I think the plugin framework is probably the best place to "put" the feature filters for now though, although someone really clever might find a different place to implement them (i.e. they could be loaded via right click menus, or something like that)
As for changing the "layout" or sorting algorithm, that is more tricky, but something that webapollo also plans to do.
Colin's right, this is definitely JBrowse (another one of those cases where I can hardly believe it wasn't already built this way in the first place.)
It also relates to the issue of piling up of features (track height, issue
best scoring visually at the top it would be much better.
-S
On Tue, Jan 27, 2015 at 7:15 AM, Colin Diesh notifications@github.com wrote:
Filtering is definitely provided by JBrowse (FilterFeatureMixin). It can also be both global or on a track-specific basis. This means that, for example, you can either call browser.setFeatureFilter or track.setFeatureFilter to perform filtering. Or you can use addFeatureFilter/removeFeatureFilter to create a chain of them.
Here's a simple global filter that I refactored out of webapollo:
define([ 'dojo/_base/declare', 'JBrowse/Plugin', 'dijit/CheckedMenuItem' ], function( declare, JBrowsePlugin, dijitCheckedMenuItem ) {
return declare( JBrowsePlugin, { constructor: function( args ) { var browser = this.browser; var thisB = this; var plus_strand_toggle = new dijitCheckedMenuItem( { label: "Hide plus strand", checked: browser.cookie("plusStrandFilter")=="1", onClick: function(event) { browser.cookie("plusStrandFilter",this.get("checked")?"1":"0"); thisB.strandFilter("plusStrandFilter",thisB.plusStrandFilter); browser.view.redrawTracks(); } }); browser.addGlobalMenuItem( 'view', plus_strand_toggle ); var minus_strand_toggle = new dijitCheckedMenuItem( { label: "Hide minus strand", checked: browser.cookie("minusStandFilter")=="1", onClick: function(event) { browser.cookie("minusStrandFilter",this.get("checked")?"1":"0"); thisB.strandFilter("minusStrandFilter",thisB.minusStrandFilter); browser.view.redrawTracks(); } }); browser.addGlobalMenuItem( 'view', minus_strand_toggle );
this.strandFilter("minusStrandFilter",this.minusStrandFilter); this.strandFilter("plusStrandFilter",this.plusStrandFilter); }, strandFilter: function(name,callback) { var browser=this.browser; if(browser.cookie(name)=="1") { browser.addFeatureFilter(callback,name) } else { browser.removeFeatureFilter(name); } }, minusStrandFilter: function(feature) { var strand = feature.get('strand'); return (strand == 1 || strand == '+') { return true; } else { return false; } }, plusStrandFilter: function(feature) { var strand = feature.get('strand'); if (strand == -1 || strand == '-') { return true; } else { return false; } }
});
});
I think the plugin framework is probably the best place to "put" the feature filters for now though, although someone really clever might find a different place to implement them (i.e. they could be loaded via right click menus, or something like that)
As for changing the "layout" or sorting algorithm, that is more tricky, but something that webapollo also plans to do.
— Reply to this email directly or view it on GitHub https://github.com/GMOD/jbrowse/issues/511#issuecomment-71663945.
It would be really great to be able to sort and/or filter by feature score, regardless of the track type. While BAM and VCF data can be filtered in some ways, a fundamental option would be to allow a user-configurable cutoff score.
A potentially more difficult option would be to allow features to be sorted by score. This would keep a multitude of poorly scoring features from pushing the good scoring features of the bottom of the "max height reached" bottom.