igvteam / igv-notebook

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

BAM not found when using path and indexPath #11

Closed SimonDMurray closed 1 year ago

SimonDMurray commented 1 year ago

Hi,

I have recently installed igv-notebook and am trying to locally load BAM files using the path and indexPath.

However, when it loads the the IGViewer, it says "Not found" in a box and there is nothing else plotted (See below) failed-igv

The code I am using is:

import igv_notebook

igv_notebook.init()

b = igv_notebook.Browser(
    {
        "genome": "hg19",
        "locus": "chr22:24,376,166-24,376,456"
    }
)

b.load_track(
    {
        "name": "Local BAM",
        "path": "/home/jovyan/igv_files/gstt1_sample.bam",
        "indexPath": "/home/jovyan/igv_files/gstt1_sample.bam.bai",
        "format": "bam",
        "type": "alignment"
    })

b.zoom_in()

I am running this on a remote Jupyter instance, however it also fails locally. I downloaded the example bam and index using:

wget https://s3.amazonaws.com/igv.org.demo/gstt1_sample.bam
wget https://s3.amazonaws.com/igv.org.demo/gstt1_sample.bam.bai

Using the URL example from the Google Colab Notebook on my Jupyter instance does however work.

I assume I am making some form of mistake so any help would be appreciated!

Thanks, Simon

jrobinso commented 1 year ago

Are you using a Jupyter Notebook or Jupyter Lab server?

jrobinso commented 1 year ago

If you are running a remote server and the files are on your local machine using a file path is not going to work, the Jupyter server has no access to your local file paths.

SimonDMurray commented 1 year ago

Hi,

I am running on a remote jupyter lab instance but the files have been uploaded to the instance.

It is not the case of trying to point to files on my local machine while on a remote instance.

In fact, I tested it on both my local machine with local paths on that machine and my jupyter lab instance with paths on to copies of the same files on that instance.

Both had the same result.

Thanks! Simon

jrobinso commented 1 year ago

Local paths will not work with Jupyter lab, this is documented in the Readme. The file will need to be visible to Jupyter Lab through the file tree, then you can use a URL

For Jupyter servers (Notebook and Lab), local files can be also be loaded via the url property if the file is in the Jupyter startup directory tree.