I just had to do this also. Since the igv component expects files to be coming from a server, I just used the flask instance running the dash app to serve the files.
YOUR_DATA_DIR
should be the local path. Note that this will expose anything in that directory!
Here’s a toy example.
import dash_bio
from flask import send_from_directory
server=app.server
@server.route('/tracks_bw/<path:path>')
def send_bw(path):
response = send_from_directory(YOUR_DATA_DIR,path)
return response
def make_igv(sample_ids,gene_ids):
igv=dash_bio.Igv(
id='reference-igv',
tracks=[
{'name':'name',
'url':'tracks_bw/MY_TRACK.bw'
} ]
)
return igv
Flask is supposedly known for not being very performant with respect to serving static files, so I suspect you could get a lot of performance improvement by setting up another server like nginx to serve the track data. But for my purposes it was sufficient.