see Igv in action.
An example of a default Igv component without any extra properties.
Select the genome to display below.
from dash import Dash, html, dcc, Input, Output, callback
import dash_bio as dashbio
app = Dash(__name__)
HOSTED_GENOME_DICT = [
{'value': 'mm10', 'label': 'Mouse (GRCm38/mm10)'},
{'value': 'rn6', 'label': 'Rat (RGCS 6.0/rn6)'},
{'value': 'gorGor4', 'label': 'Gorilla (gorGor4.1/gorGor4)'},
{'value': 'panTro4', 'label': 'Chimp (SAC 2.1.4/panTro4)'},
{'value': 'panPan2', 'label': 'Bonobo (MPI-EVA panpan1.1/panPan2)'},
{'value': 'canFam3', 'label': 'Dog (Broad CanFam3.1/canFam3)'},
{'value': 'ce11', 'label': 'C. elegans (ce11)'}
]
app.layout = html.Div([
dcc.Loading(id='default-igv-container'),
html.Hr(),
html.P('Select the genome to display below.'),
dcc.Dropdown(
id='default-igv-genome-select',
options=HOSTED_GENOME_DICT,
value='ce11'
)
])
# Return the IGV component with the selected genome.
@callback(
Output('default-igv-container', 'children'),
Input('default-igv-genome-select', 'value')
)
def return_igv(genome):
return html.Div([
dashbio.Igv(
id='default-igv',
genome=genome,
minimumBases=100,
)
])
if __name__ == '__main__':
app.run(debug=True)
Select a genome using an identifier string (e.g. “hg19”). A list of pre-defined genomes hosted by IGV can be found here.
import dash_bio as dashbio
dashbio.Igv(
id='genome-igv',
genome='ce11'
)
Add a reference dictionary which can be used to specify the genomic data added to the IGV component, and add tracks to display features such as annotations, genome variants, alignments, and quantitative data.
For more information on reference options, visit the IGV
wiki here.
Multiple tracks can be added to a single reference by creating a list of dicts, each of which correspond to a single track. For more information on Track Types and Track Configurations, visit the IGV
wiki here.
import dash_bio as dashbio
dashbio.Igv(
id='reference-igv',
reference={
'id': 'ASM985889v3',
'name': 'Sars-CoV-2 (ASM985889v3)',
'fastaURL': 'https://s3.amazonaws.com/igv.org.genomes/covid_ASM985889v3/GCF_009858895.2_ASM985889v3_genomic.fna',
'indexURL': 'https://s3.amazonaws.com/igv.org.genomes/covid_ASM985889v3/GCF_009858895.2_ASM985889v3_genomic.fna.fai',
'order': 1000000,
'tracks': [
{
'name': 'Annotations',
'url': 'https://s3.amazonaws.com/igv.org.genomes/covid_ASM985889v3/GCF_009858895.2_ASM985889v3_genomic.gff.gz',
'displayMode': 'EXPANDED',
'nameField': 'gene',
'height': 150,
'color': 'rgb(176,141,87)'
}
]
},
)
The initial genomic location displayed on the viewer. This can be a string or a list of strings. In the example below, the locus is “chrV”.
import dash_bio as dashbio
dashbio.Igv(
id='locus-igv',
genome='ce11',
locus=['chrV', 'chrII']
)
Minimum window size in base pairs when zooming in.
import dash_bio as dashbio
dashbio.Igv(
id='bases-igv',
genome='ce11',
minimumBases='10'
)
Access this documentation in your Python terminal with:
```pythonhelp(dash_bio.Igv)
```
Our recommended IDE for writing Dash apps is Dash Enterprise’s
Data Science Workspaces,
which has typeahead support for Dash Component Properties.
Find out if your company is using
Dash Enterprise.
id
(string; optional):
The ID of this component, used to identify dash components in
callbacks. The ID needs to be unique across all of the components in
an app.
style
(dict; optional):
Generic style overrides on the plot div.
className
(string; optional):
className of the component div.
genome
(string; optional):
String identifier defining genome (e.g. “hg19”). See
https://github.com/igvteam/igv.js/wiki/Reference-Genome for
details and list of supported identifiers. Note: One (but only one) of
either genome or reference properties must be set. If both are set,
the genome property will be ignored.
reference
(dict; optional):
Object defining reference genome. see
https://github.com/igvteam/igv.js/wiki/Reference-Genome Note: One
(but only one) of either genome or reference properties must be set.
If both are set, the genome property will be ignored.
locus
(string; optional):
Initial genomic location(s). Either a string or an array of strings.
If an array a viewport is created for each location.
minimumBases
(number; optional):
Minimum window size in base pairs when zooming in.
tracks
(list; optional):
Array of configuration objects defining tracks initially displayed
when app launches. see
https://github.com/igvteam/igv.js/wiki/Tracks-2.0.
loading_state
(dict; optional):
Object that holds the loading state object coming from dash-renderer.
loading_state
is a dict with keys:
component_name
(string; optional):
Holds the name of the component that is loading.
is_loading
(boolean; optional):
Determines if the component is loading or not.
prop_name
(string; optional):
Holds which property is loading.