g2nb / igv-jupyter

Extension for Jupyter which integrates igv.js
MIT License
154 stars 14 forks source link

BigWig files visualization using built-in Jupyter server #9

Closed NemanjaVucic90 closed 5 years ago

NemanjaVucic90 commented 6 years ago

Hey guys,

if I understood well, indexed files including BigWig could not be visualized using the built-in Jupyter server. I saw that @jfear reported some bug regarding bam files in jupyter notebook so I am interested how did he manage to do that?

Cheers, Nemanja

jrobinso commented 6 years ago

Hi, I'm not sure, perhaps @jfear will answer. However, the problem as I understand it is the lack of support for "range" requests by default. You should be able to modify the juptyter server to support range-byte requests. We have done that for flask in another project (igv.js-flask). I do not know enough about jupyter to provide guidance beyond that, but a web search for "Range byte support in jupyter web server" should turn up something.

If you solve it could you respond here?

On Wed, Jan 24, 2018 at 5:36 AM, NemanjaVucic90 notifications@github.com wrote:

Hey guys,

if I understood well, indexed files including BigWig could not be visualized using the built-in Jupyter server. I saw that @jfear https://github.com/jfear reported some bug regarding bam files in jupyter notebook so I am interested how did he manage to do that?

Cheers, Nemanja

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/igvteam/igv.js-jupyter/issues/9, or mute the thread https://github.com/notifications/unsubscribe-auth/AA49HHM_wNEUvEzZeNZR8qsFesb1oZZSks5tNzHsgaJpZM4RrQ_Q .

jfear commented 6 years ago

Hey all,

I have not needed this for a while, and cannot remember having to do anything special. I tracked down an old notebook and see that I was running igv==v0.1.1 with this following code.

from igv import IGV, Reference, Track

igv_tracks = IGV(locus="chr2L:100-10,000", 
                reference=Reference(id='dm6', fastaURL='//localhost:8989/reference/dm6-noextra.fasta'),
                tracks=[Track(name='Genes', type='annotation', format='gff', 
                                        url='//localhost:8989/reference/dmel-all-r6.09.chr.sort.gtf',
                                        index_url='//localhost:8989/reference/dmel-all-r6.09.chr.sort.gtf.idx',
                                        display_mode='EXPANDED', height=20),
                             Track(name='A6', type='alignment', format='bam', 
                                        url='//localhost:8989/tada/bam/A6.bam',
                                        index_url='//localhost:8989/tada/bam/A6.bam.bai',
                                       display_mode='SQUISHED', colorBy='strand'),
                       ])

igv_tracks

I was also able to get search_tracks to work.

igv_tracks.search_tracks('chr2L:19,474,598-19,475,177')

Let me know if you cannot get this to work, or if this does not answer you question.

NemanjaVucic90 commented 6 years ago

@jfear thanks for the advice but unfortunately I haven't succeeded. Here's my snippet

screen shot 2018-01-24 at 7 08 21 pm

@jrobinso I'll get back if I succeed enabling range-byte requests in default jupyter notebook server.

jrobinso commented 6 years ago

Leave this issue open, when I find some time I'll look into it. I think there should be a solution, but web googling so far hasn't turned up anything.

NemanjaVucic90 commented 6 years ago

Thanks @jrobinso. Have you tried visualizing bigWig files, I saw only bam files in the examples. When I add bigWig file to the track from my local dir it doesn't show this error but it takes forever to load 500MB file, eventually if and when it loads in the plot this track is blank.

jrobinso commented 6 years ago

What webserver are you using to serve the bigwig?

On Wed, Jan 24, 2018 at 10:44 AM, NemanjaVucic90 notifications@github.com wrote:

Thanks @jrobinso https://github.com/jrobinso. Have you tried visualizing bigWig files, I saw only bam files in the examples. When I add bigWig file to the track from my local dir it doesn't show this error but it takes forever to load 500MB file, eventually if and when it loads in the plot this track is blank.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/igvteam/igv.js-jupyter/issues/9#issuecomment-360233343, or mute the thread https://github.com/notifications/unsubscribe-auth/AA49HIPiseh_T1iytg4Db5Yuh14NG7wpks5tN3oDgaJpZM4RrQ_Q .

NemanjaVucic90 commented 6 years ago

I am using custom jupyter notebook web server but as I can see it has HTTP range requests enabled

screen shot 2018-01-25 at 11 44 54 am
jrobinso commented 6 years ago

OK, well bigwig should work, see http://igv.org/web/examples/api.html#. Select "Encode BigWig" from the Tracks menu.

Would it be possible to share a small bigwig that isn't working? Also, any errors in the javascript console?

On Thu, Jan 25, 2018 at 2:46 AM, NemanjaVucic90 notifications@github.com wrote:

I am using custom jupyter notebook web server but as I can see it has HTTP range requests enabled

[image: screen shot 2018-01-25 at 11 44 54 am] https://user-images.githubusercontent.com/17168657/35384384-6e4553a2-01c5-11e8-8809-8a6cdbdf8bb9.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/igvteam/igv.js-jupyter/issues/9#issuecomment-360430373, or mute the thread https://github.com/notifications/unsubscribe-auth/AA49HE4eP5Ml5Ny4rS02XmjiM9r_8nGRks5tOFuggaJpZM4RrQ_Q .

NemanjaVucic90 commented 6 years ago

I get something like this

screen shot 2018-01-25 at 5 46 55 pm

I've uploaded bigWig file that i used here

NemanjaVucic90 commented 6 years ago

Here's the region I am trying to get from IGV local app

screen shot 2018-01-25 at 5 57 04 pm
jrobinso commented 6 years ago

If you get that message it means the server ignored the range header, so its not going to work. What version of Jupyter are you using?

On Thu, Jan 25, 2018 at 8:58 AM, NemanjaVucic90 notifications@github.com wrote:

Here's the region I am trying to get from IGV local app [image: screen shot 2018-01-25 at 5 57 04 pm] https://user-images.githubusercontent.com/17168657/35401294-615ae2b8-01f9-11e8-95d0-81738ccf7ad6.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/igvteam/igv.js-jupyter/issues/9#issuecomment-360530124, or mute the thread https://github.com/notifications/unsubscribe-auth/AA49HNQHTzIsbGHs4laV687DuCZClJ1pks5tOLLLgaJpZM4RrQ_Q .

NemanjaVucic90 commented 6 years ago

I am using Jypyter Notebook v5.0.0

jrobinso commented 6 years ago

It might help to update to 5.1, but I can't guarantee it. We don't have the resources or expertise to help with Jupyter issues, however, we did verify that your bw file can be successfully viewed with igv.js in a notebook. Try loading the following URL

https://data.broadinstitute.org/igvdata/test/data/bigwig/_1_BT474_treat_pileup.bdg.sorted.bw

NemanjaVucic90 commented 6 years ago

Hey @jrobinso finally, it worked. I updated jupyter notebook to v5.3.1 but I am not quite sure that was the reason. Sometimes I still get the "Error accessing resource:" but when I move wig track or zoom in/out error disappears and the file gets loaded almost immediately. I have one more question, is it possible to increase resolution of the output window and that of separate tracks in terms of height? Cheers, Nemanja

jrobinso commented 6 years ago

Track options for igv.js are described here: https://github.com/igvteam/igv.js/wiki/Tracks

To map these options to jupyter (pythong) properties see the Track class in https://github.com/igvteam/igv.js-jupyter/blob/master/igv/__init__.py

On Mon, Jan 29, 2018 at 6:19 AM, NemanjaVucic90 notifications@github.com wrote:

Hey @jrobinso https://github.com/jrobinso finally, it worked. I updated jupyter notebook to v5.3.1 but I am not quite sure that was the reason. Sometimes I still get the "Error accessing resource:" but when I move wig track or zoom in/out error disappears and the file gets loaded almost immediately. I have one more question, is it possible to increase resolution of the output window and that of separate tracks in terms of height? Cheers, Nemanja

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/igvteam/igv.js-jupyter/issues/9#issuecomment-361259083, or mute the thread https://github.com/notifications/unsubscribe-auth/AA49HGzzOZjoFSXTkYW01EkLWJ25pdVoks5tPdNfgaJpZM4RrQ_Q .

jrobinso commented 5 years ago

This is no longer an issue with the latest Jupyter notebook.