igvteam / igv.js

Embeddable genomic visualization component based on the Integrative Genomics Viewer
MIT License
643 stars 230 forks source link

query current display for selected entity or region #163

Closed paul-shannon closed 8 years ago

paul-shannon commented 8 years ago

Would be very useful to:

a) make a selection in a track in igv.js (of a SNP, footprint, exon, or ...) b) or, select a region (a subset of what is currently displayed) c) obtain that name or region via a function in the javascript API

Thanks!

paul-shannon commented 8 years ago

Not intending to be a pest - may I ask if this request seem worthy? Perhaps there are hooks in the javascript I could use?

jrobinso commented 8 years ago

This is difficult and competing with many other more straightforward requests. For starters there is no means to make a selection. (c) is not very well defined, name of what? I'm happy to entertain a pull request here but before investing time on a UI selection we should have a discussion, the key will be an intuitive means of selecting a region.

You can get the current region at any time with this undocumented code, which could change in the future.

var chr = igv.browser.referenceFrame.chr; var start = igv.browser.referenceFrame.start; var end = start + igv.browser.trackViewportWidthBP(); console.log(chr + ':' + (start + 1) + '-' + end

paul-shannon commented 8 years ago

Hi Jim,

Thanks for the explanation, and for the sample code.

Would it be a bad idea to piggyback on the tooltip mechanism? I don’t understand all of the semantics of clicking on the track, but a tooltip reliably appears when I click on a region (a block, a bed file segment), as depicted below.

My use case is:

1) select a SNP or larger region portrayed on a track 2) igv.js records this in its queryable state (igv.browser.referenceFrame.currentSelection?) 3) this selection (its chrom:start-end, track name) can then be obtained through the igv.js api

Would it be crazy, or unwelcome, for me to experiment with this, possibly do a PR on anything useful which results?

On Jul 11, 2016, at 1:45 PM, Jim Robinson notifications@github.com wrote:

This is difficult and competing with many other more straightforward requests. For starters there is no means to make a selection. (c) is not very well defined, name of what? I'm happy to entertain a pull request here but before investing time on a UI selection we should have a discussion, the key will be an intuitive means of selecting a region.

You can get the current region at any time with this undocumented code, which could change in the future.

var chr = igv.browser.referenceFrame.chr; var start = igv.browser.referenceFrame.start; var end = start + igv.browser.trackViewportWidthBP(); console.log(chr + ':' + (start + 1) + '-' + end

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

jrobinso commented 8 years ago

Perhaps I've overly complicated what you are asking for. If you only want to click on a displayed object in a track, as opposed to sweeping out a general region, then yes piggybacking on the tooltip mechanism would be a good place to start. In fact, it looks like the mechanism already exists. Look at the example code in "examples/events/custom-track-click.html". This uses a track click event and callback function. Start there, if that doesn't quite get you what you need we can probably modify it.

jrobinso commented 8 years ago

BTW experimentation and pull requests are always welcome. Just try to keep them focused, and communicate along the way.

paul-shannon commented 8 years ago

Hi Jim,

Thanks for being open to possible contributions!

I am timid about this suggestion. Feel free to express dismay, outrage :} or incredulity.

cytoscape.js uses a mouse idiom in which (like igv) mouse-move scrolls the display, but shift-mousedown-mousemove allows you to draw a selection box on the canvas. Intersecting nodes and/or edges are then selected.

Perhaps shift-mousedown-mousemove available for these semantics in igv.js?

Don’t hesitate to decline this idea if it is ill-conceived!

On Jul 11, 2016, at 2:15 PM, Jim Robinson notifications@github.com wrote:

BTW experimentation and pull requests are always welcome. Just try to keep them focused, and communicate along the way.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

jrobinso commented 8 years ago

Paul, perhaps. IGV differs from cytoscape in that it is essentially 1-dimensional. Selecting across tracks in this way would be complex, and there would need to be some compelling justification for it. Do the track events mechanism described above solve your current need, or partially solve it?

paul-shannon commented 8 years ago

Hi Jim,

My thought was to limit the selection vertically to just one track. Does that make the idea more acceptable, more within the current spirit and design of igv.js?

The variables you pointed me towards were helpful. Right now I am doing a bit of console.log tracing in browser.js, $(trackContainerDiv).mousedown, trying to learn your dynamic architecture.

On Jul 12, 2016, at 3:01 PM, Jim Robinson notifications@github.com wrote:

Paul, perhaps. IGV differs from cytoscape in that it is essentially 1-dimensional. Selecting across tracks in this way would be complex, and there would need to be some compelling justification for it. Do the track events mechanism described above solve your current need, or partially solve it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

jrobinso commented 8 years ago

Paul, it wasn't the variables I was referring to, rather the event mechanism illustrated here: examples/events/custom-track-click.html. I think it does exactly what you were asking for. If it doesn't lets explore what is missing and start from that point, its very close.

paul-shannon commented 8 years ago

Hi Jim,

Very close indeed. The solution offered (and demonstrated) here is not exactly what I was thinking of, but I believe it will work very well for my purposes.

Thank you!

On Jul 12, 2016, at 3:14 PM, Jim Robinson notifications@github.com wrote:

Paul, it wasn't the variables I was referring to, rather the event mechanism illustrated here: examples/events/custom-track-click.html. I think it does exactly what you were asking for. If it doesn't lets explore what is missing and start from that point, its very close.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

paul-shannon commented 8 years ago

Hi Jim,

I see that “zooming in” is triggered if I click my mouse somewhat rapidly on an empty part of a track.

This happens if I am slightly off in my attempt to select the block indicating a snp. A zoom in that circumstance can be quite confusing!

Is it possible to disable this feature?

On Jul 12, 2016, at 4:33 PM, Paul Shannon paul.thurmond.shannon@gmail.com wrote:

Hi Jim,

Very close indeed. The solution offered (and demonstrated) here is not exactly what I was thinking of, but I believe it will work very well for my purposes.

Thank you!

  • Paul

On Jul 12, 2016, at 3:14 PM, Jim Robinson notifications@github.com wrote:

Paul, it wasn't the variables I was referring to, rather the event mechanism illustrated here: examples/events/custom-track-click.html. I think it does exactly what you were asking for. If it doesn't lets explore what is missing and start from that point, its very close.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

jrobinso commented 8 years ago

You can try setting the doubleClickDelay property on the browser option to a very small value, perhaps 0 or 1. see https://github.com/igvteam/igv.js/wiki/Browser.

If you'd like a configuration option to turn off double-click zoom please open a separate git issue, this one is beginning to wander.

On 7/12/16 5:01 PM, Paul Shannon wrote:

Hi Jim,

I see that “zooming in” is triggered if I click my mouse somewhat rapidly on an empty part of a track.

This happens if I am slightly off in my attempt to select the block indicating a snp. A zoom in that circumstance can be quite confusing!

Is it possible to disable this feature?

  • Paul

On Jul 12, 2016, at 4:33 PM, Paul Shannon paul.thurmond.shannon@gmail.com wrote:

Hi Jim,

Very close indeed. The solution offered (and demonstrated) here is not exactly what I was thinking of, but I believe it will work very well for my purposes.

Thank you!

  • Paul

On Jul 12, 2016, at 3:14 PM, Jim Robinson notifications@github.com wrote:

Paul, it wasn't the variables I was referring to, rather the event mechanism illustrated here: examples/events/custom-track-click.html. I think it does exactly what you were asking for. If it doesn't lets explore what is missing and start from that point, its very close.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/igvteam/igv.js/issues/163#issuecomment-232217451, or mute the thread https://github.com/notifications/unsubscribe/AA49HFcu_ubaIV0z7_E6dDOYyU8Z9tuZks5qVCrWgaJpZM4How1X.

jrobinso commented 8 years ago

Note correction above, "small value" not "large value". It was edited, but if you are following by email you won't see the edit.

paul-shannon commented 8 years ago

Thanks, Jim. I found that doubleClickDelay: 1 has the desired effect, but 0 does not. So "small non-zero value" might be a good summary.

jrobinso commented 8 years ago

Closing, there is an event mechanism that addresses the original request here. If that is not sufficient open a new issue.