g2nb / igv-jupyter

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

Problems using files/ to access local .fa file #45

Closed mezarque closed 3 years ago

mezarque commented 3 years ago

Hi there, thanks so much for building this package!

I realize that JS is unable to see information about local files from a path, but it appears that several workarounds have been suggested to pass URLs to allow using a local reference .fa file. I've tried using the localhost:8889 URL from the Jupyter notebook and using "files/", with my "genome.fa" and "genome.fa.fai" files in the same directory as my Jupyter notebook.

The localhost URL causes a popup window that just says "undefined" when I try to b.show() the browser.

It appears that using "files/" allows me to load the file in theory, but when I use b.show(), instead of getting the "undefined" error, my notebook server hangs and then becomes unresponsive. When I look at the Jupyter notebook server log in the shell, it appears that it's throwing a 302 GET error.

Barring getting a local file to work via this workaround, do you have any suggestion for where to host a .fa file that is a URL to be accessible to this package?

tmtabor commented 3 years ago

To help me investigate this issue, are you experiencing this error in JupyterLab, Jupyter Notebook or both?

mezarque commented 3 years ago

I'm running into this error using both JupyterLab and Jupyter Notebook. From my understanding, the error with JupterLab is expected, but the behavior in Jupyter Notebook is not. I'm pretty sure that the install worked successfully, as I'm able to view the hg38 genome as shown in the documentation using web URLs when using this package within a Jupyter Notebook.

tmtabor commented 3 years ago

It took me some time to reproduce this error, but I was finally able to do so in Jupyter Notebook only. I have since checked in a fix. Assuming there are no further issues, it will be pushed to pip next week in release 0.10.2.

In the meantime, if you're comfortable building nbextensions / labextensions from source, you're welcome to check out the most recent code from this repository and verify that the fix works.

Otherwise, in the meantime you should be able to get local files to work in Jupyter Notebook by providing the full absolute URL to the file's endpoint. For example, if you're trying to load hg19.snippet.fasta in the examples/data directory, the full URL might be: http://localhost:8888/files/examples/data/hg19.snippet.fasta.

This will no longer be necessary once running 0.10.2.

mezarque commented 3 years ago

Thanks so much again for looking into this! Unfortunately I just updated via pip and the issue seems to be persisting. I'm wondering if perhaps there's some issue with how I installed the package? I've tried using both "files/genome.fa" and the full absolute path, and both result in the same hanging issue.

I am able to visualized the human genome just fine, as I mentioned, but I did deviate slightly from the original install approach.

When I tried this command from the install instructions: jupyter labextension enable --py igv

I encountered this error: Unrecognized alias: 'py', it will have no effect.

I was able to circumvent this by using jupyter labextension enable igv

But perhaps that is part of the issue?

For some more info, when I call b.show(), it does show the genome viewer, but the genome viewer lacks the alias of the genome. Then my notebook hangs and becomes unresponsive.

tmtabor commented 3 years ago

This could very well be an installation or environment issue. A couple things to check:

If both of those seem correct, then it may be useful as a sanity check to see if you can run the LocalFiles.ipynb example notebook. You can find the notebook here, but you likely will want to first clone the repository so that you have the supporting files to load: git clone https://github.com/igvteam/igv-jupyter.git.

Then you can find the notebook in the igv-jupyter/examples directory. At least for me, that notebook runs without issue on a clean JupyterLab install.

mezarque commented 3 years ago

Thanks for suggesting this! The example works just fine on my setup, and I was able to confirm the labextension and pip freeze methods work as expected as well.

I'm wondering if perhaps this is an issue with the number of contigs in my file? I'm noticing that when one usually uses b.show() for hg19 for example, the initial view shows all of the chromosomes. Perhaps having a large number of contigs (e.g. 300k) causes an issue?

I also don't have a cytoband text file for my genome - do you think that could cause a problem?