igvteam / igv-notebook

Module for embedding igv.js in an IPython notebook
MIT License
66 stars 14 forks source link

to_svg() not working #10

Closed KalinNonchev closed 2 years ago

KalinNonchev commented 2 years ago

Hello,

Thank you for the fast reaction here https://github.com/igvteam/igv-notebook/issues/8 I just tested the implementation in Jupyter Notebook and unfortunatly it is not working as desired.

I tried your example notebook BamFiles_Notebook. Run all the cells and exported it as html. Then I opened the html file and in the igv browser the error was "Error accessing resource: data/gstt1_sample.bam.bai Status: 0"

So I guess the visualization was not converted into SVG? I also tried doing it manullay from the browser with "to SVG". It didn't work.

Could you look into this?

Best,

KalinNonchev commented 2 years ago

pull request history https://github.com/igvteam/igv-notebook/pull/9

jrobinso commented 2 years ago

That example is confusing, if you run all the cells you are going to have orphaned "browser" objects in all but the last one, the "to_svg()" function is only going to convert the last one as there is no reference to the previous ones.

KalinNonchev commented 2 years ago

I confirm this logic, but the last cell has the same error for me. Were you able to reproduce "Error accessing resource: data/gstt1_sample.bam.bai Status: 0"?

jrobinso commented 2 years ago

Try, for example, just running the last 2 cells, that is the one after this note "Load BAM file by file path (Jupyter Notebook only)", the b.to_svg(). If you run them all you'll have 1 svg converted browser and 3 "live" igvs exported to your html.

jrobinso commented 2 years ago

The example works for me, see the attached HTML. I ran this from the "binder" container linked from the top of the README. If you can't get it to work (1) confirm you are using the latest release of igv-notebook, and (2) zip and attach the html you are getting here.

BamFiles_Notebook (7).html.zip

jrobinso commented 2 years ago

Also, if you have output saved from previous runs that was saved or check-pointed its still there of course, clear all your output before trying again.

KalinNonchev commented 2 years ago

It is not working. I do confirm that I use the latest version (to_svg would not work otherwise, but it would be nice to have igv_notebook.version option). Here it is minimal example https://easyupload.io/otjj7u (link valid for 7 days)

KalinNonchev commented 2 years ago

Terminal output after trying to transform the visualization to SVG

Traceback (most recent call last): File ".../lib/python3.6/site-packages/ipykernel/comm/manager.py", line 110, in comm_msg comm.handle_msg(msg) File "../lib/python3.6/site-packages/ipykernel/comm/comm.py", line 161, in handle_msg self._msg_callback(msg) File ".../lib/python3.6/site-packages/igv_notebook/svg.py", line 20, in _recv update_display(markup, display_id = display_id, clear=True) File ".../lib/python3.6/site-packages/IPython/core/display.py", line 343, in update_display display(obj, display_id=display_id, kwargs) File ".../lib/python3.6/site-packages/IPython/core/display.py", line 320, in display publish_display_data(data=format_dict, metadata=md_dict, kwargs) File ".../lib/python3.6/site-packages/IPython/core/display.py", line 122, in publish_display_data **kwargs TypeError: publish() got an unexpected keyword argument 'clear'

jrobinso commented 2 years ago

Yes I can see that, there's still a "live" igv instance in the last cell not svg. From the traceback it looks like there might be a difference in your notebook server, it doesn't like the "clear" keyword. Could you try running from the "binder" link at the top of the README? One frustration with developing anything for Jupyter is they change the API regularly with no notice, I implemented this following the documentation but perhaps its not available in older versions. In any event the first step would be to confirm this is a Jupyter or Python version issue, running the examples from the "binder" link would help confirm that.

jrobinso commented 2 years ago

I'm on python version 3.9.1

jrobinso commented 2 years ago

It looks like the offending "clear" keyword is not needed, I removed it. If you want to test to see if this solves the issue you should be able to install from github as follows, or pull and build yourself

pip install git+https://github.com/igvteam/igv-notebook.git

If that works I will push a pypi release, if not I will need to walk backwards through python versions to find the minimum required. So far we know it works with 3.9.1, does not work with 3.6.

Its quite late here in California and I'm quitting for the evening.

KalinNonchev commented 2 years ago

1) I was running jupyter notebook 6.4.8, updated to 6.4.12, but the problem remained. I confirm that the "binder" example works.

2) I switched to python 3.9, this solved the issue.

3) I went back to python 3.6 and install the new build (pip install git+https://github.com/igvteam/igv-notebook.git) - this solved the issue. (I think you can push the new pypi release)

4) Have a nice evening :-) In Zurich we are just starting ;)

jrobinso commented 2 years ago

This is now released as 0.3.1