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

Highlight samples in gcnv bed on click instead of specifying in file #1411

Closed
jethror1 opened this issue Oct 27, 2021 · 11 comments · Fixed by #1429
Closed

Highlight samples in gcnv bed on click instead of specifying in file #1411

jethror1 opened this issue Oct 27, 2021 · 11 comments · Fixed by #1429

Comments

@jethror1
Copy link
Contributor

It would be great if when loading bed files of copy ratios from gcnv if the highlighting on samples could be done 'on click' instead of having to specify these either in loading config or written into the first line of the bed file.

At the moment I know it is possible to add the following:

track type=gcnv height=500 highlight=sample-X12345;red\n

image

But when wanting to load these bed files into any instance of igv.js/igv-webapp this isn't convenient as the sample(s) to highlight have to be determined when creating the bed file.

Also, would it be possible to get better docs on the use of gcnv, I only knew about this from my internship at the Broad and using tgg-viewer, and it would be really helpful for sharing this wider as it is very useful for cnv visualisation.

Thanks!

@jrobinso
Copy link
Contributor

@bw2 comments? I suppose the most difficult part of selecting the sample would be hit testing the path but this is solvable. Does there exist any documentation on this track we could point to or add to the wiki?

@helgathorv ping

@jethror1
Copy link
Contributor Author

As an aside I have added in randomly assigning hex codes to sample names for the highlight string in the bed file which we find easier for visualisation than everything being grey, but being able to click on individuals and highlight would better, especially when have larger sample sets:

image

@bw2
Copy link
Contributor

bw2 commented Oct 27, 2021

That sounds like useful feature.
Currently the 2 non-standard config options are:

highlightSamples: dictionary that maps sampleId => color
onlyHandleClicksForHighlightedSamples:  true/false

The reason for onlyHandleClicksForHighlightedSamples is we sometimes want to show users the CNV lines for a particular sample or trio but hide sample ids for the 100s of background samples. This also makes it easier to click on just the samples of interest instead of accidentally clicking the background samples.

Perhaps this feature can have its own boolean config setting like clickToHighlight that's mutually-exclusive with onlyHandleClicksForHighlightedSamples?
or replace onlyHandleClicksForHighlightedSamples with a setting like clickMode with values like ClickToHighlight, ClickOnlySamplesHighlighedByConfig, etc.?

Once that's decided we could put together a gCNV track wiki that also includes the data format docs from
#1055

The click detection logic currently exists @
https://github.com/igvteam/igv.js/blob/master/js/gcnv/gcnvTrack.js#L240-L280
and could be reused for this.

@jethror1
Copy link
Contributor Author

@bw2 has any decision been made on this / rough idea when it would happen? No worries if not, just wanting to know if I should try implement something on our side in the mean time

@bw2
Copy link
Contributor

bw2 commented Nov 18, 2021

@jethror1 I don't have the bandwidth to implement this, so defer to you and Jim on next steps.

@jethror1
Copy link
Contributor Author

I'd be happy to work on implementing it if I can find the time and you're happy with others contributing?

If so @bw2 could you point me to gcnv related functions and what you'd like / suggest to do for it.

@jrobinso
Copy link
Contributor

I'm happy to accept pull requests, but please keep them as focused as possible and change as little as possible, this includes things like file formatting, to help with the code review. Occasionally I get a PR that does something + lots of other things that seemed like improvements, these are impossible to accept. However most PRs are accepted, the gCNV track itself is a contribution from @bw2.

@jethror1
Copy link
Contributor Author

I've taken a look at adding to the gCNV track to add highlight on click. I've add an option to the track config to be named clickToHighlight that accepts either a colour or a keyword any. If set to any, a random colour will be chosen on each click for the line. If a line that has been coloured is clicked again it will remove the highlight colour.

With clickToHighlight=red set:

gcnv_igv_red

With clickToHighlight=any set:

gcnv_igv_random

This has only added ~20 lines to the gCNV track, so hopefully not too much change.

The only thing I think could be better for this specific use case is having the labels appear on hover as oppose to click, so as to know what the sample line is below clicking and highlighting.

Is tooltip displaying on hover already implemented in igv.js, and would it be possible / appropriate to implement here?

Hope this seems okay with you both

@jrobinso
Copy link
Contributor

Very nice! I will defer to @bw2 for comment as he is really the creator and primary user, AFAIK, of this track. Could you prepare a PR to review?

WRT hove we don't support it currently, it would mean (I think) tracking mouse movement continuously and updating the hover text associated with the DOM element. If there is an option to catch an event just before the tooltip is raised that would make implementation easy, but I don't think there is. In any case we don't support it now, I don't really have time to look into it currently.

@bw2
Copy link
Contributor

bw2 commented Nov 22, 2021

I agree, the demo looks great. I doubt hover could be implemented without bogging down the UI since
https://github.com/igvteam/igv.js/blob/master/js/gcnv/gcnvTrack.js#L263-L279
would need to run every time the mouse moves.

@jethror1
Copy link
Contributor Author

No worries, labels on hover is only a nice to have, might take a look at it at some point if I have the time / if it is requested.

I've now opened a PR for you to take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants