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

Filter or sort by score #511

Open
scottcain opened this issue Sep 15, 2014 · 4 comments
Open

Filter or sort by score #511

scottcain opened this issue Sep 15, 2014 · 4 comments
Labels
feature req this adds new functionality to JBrowse 1

Comments

@scottcain
Copy link
Member

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.

@scottcain scottcain added the feature req this adds new functionality to JBrowse 1 label Sep 15, 2014
@scottcain
Copy link
Member Author

This feature request was a result of JBrowse being rolled out at WormBase:

https://github.com/WormBase/website/issues/3120

@nathandunn
Copy link
Contributor

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.

@cmdcolin
Copy link
Contributor

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.

@selewis
Copy link

selewis commented Feb 2, 2015

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
#71 I think) that we've been discussing. If the default were to put the
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
#511 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature req this adds new functionality to JBrowse 1
Projects
None yet
Development

No branches or pull requests

4 participants