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

igv.js and Jupyter notebooks? #222

Closed
paul-shannon opened this issue Jul 20, 2016 · 13 comments
Closed

igv.js and Jupyter notebooks? #222

paul-shannon opened this issue Jul 20, 2016 · 13 comments

Comments

@paul-shannon
Copy link

Has anyone wrapped up igv.js as an ipython widget, for use in Jupyter notebooks?

@jrobinso
Copy link
Contributor

Not to my knowledge. Will keep this open and take it as a request. Happy to entertain a pull request.

@jrobinso
Copy link
Contributor

Resolved, see https://github.com/igvteam/igv.js-jupyter

@jrobinso
Copy link
Contributor

@paul-shannon Old thread, but are you using igv.js in a Jupyter workbook? I don't think it works any longer. I've been trying to learn enough to bring it up to date but I can't even get the official widget cookie-cutter code to work. So I'm not optimistic.

@paul-shannon
Copy link
Author

paul-shannon commented Dec 20, 2018 via email

@jrobinso
Copy link
Contributor

Don't spend any time on it but the code might be instructive, doesn't have to work. I actually did get our project working, I had configuration problems.

@paul-shannon
Copy link
Author

paul-shannon commented Dec 20, 2018 via email

@jrobinso
Copy link
Contributor

jrobinso commented Dec 20, 2018 via email

@paul-shannon
Copy link
Author

paul-shannon commented Dec 20, 2018 via email

@jrobinso
Copy link
Contributor

Hi Paul, our current extension, as you know, supports python -> igv.js communication, but not the other way. How do you query igv.js for the current region in trenaviz?

@paul-shannon
Copy link
Author

paul-shannon commented Dec 20, 2018

When I worked this out for igvShiny there was not yet a javascript API in igv.js to query the current region. So (maybe even with advice from you) I did it this way:

igvWidget.on('locuschange', function (referenceFrame, chromLocString){
    Shiny.setInputValue("currentGenomicRegion", chromLocString, {priority: "event"});
    });

This then shows up in R as input$currentGenomicRegion upon which reactive code can be written. I did something similar in python with the backbone protocol.

For igvR the locusChange event sets javascript global state which R can later query via the websocket communication channel upon which igvR depends.

@jrobinso
Copy link
Contributor

jrobinso commented Dec 20, 2018

I see. I need something simple to build and maintain and am trying to avoid backbone and importing ipywidgets, partly because I have too many projects to contemplate learning and then supporting that. However, I just discovered a simple way to do this with just javascript and core jupyter, this works beautifully from a cell, so its promising.

%%javascript
 igv.browser.on('locuschange', function (referenceFrame, label) {
                 var str = "locus=\"" + label + "\""
                 console.log(str)
                        IPython.notebook.kernel.execute(str)
                    });

@paul-shannon
Copy link
Author

Nice solution!

@jrobinso
Copy link
Contributor

This also looks promising, maybe a little less of a hack: https://jupyter-notebook.readthedocs.io/en/stable/comms.html

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

No branches or pull requests

2 participants