see OncoPrint in action.
An example of a default OncoPrint component without any extra properties.
import json
import urllib.request as urlreq
from dash import Dash, html, Input, Output, callback
import dash_bio as dashbio
app = Dash(__name__)
data = urlreq.urlopen(
'https://git.io/oncoprint_dataset3.json'
).read().decode('utf-8')
data = json.loads(data)
app.layout = html.Div([
dashbio.OncoPrint(
id='dashbio-default-oncoprint',
data=data
),
html.Div(id='default-oncoprint-output')
])
@callback(
Output('default-oncoprint-output', 'children'),
Input('dashbio-default-oncoprint', 'eventDatum')
)
def update_output(event_data):
if event_data is None or len(event_data) == 0:
return 'There are no event data. Hover over or click on a part \
of the graph to generate event data.'
event_data = json.loads(event_data)
return [
html.Div('{}: {}'.format(
key,
str(event_data[key]).replace('<br>', '\n')
))
for key in event_data.keys()]
if __name__ == '__main__':
app.run(debug=True)
Change the color of specific mutations, as well as the background color.
import json
import urllib.request as urlreq
import dash_bio as dashbio
data = urlreq.urlopen(
'https://git.io/oncoprint_dataset3.json'
).read().decode('utf-8')
data = json.loads(data)
dashbio.OncoPrint(
data=data,
colorscale={
'MISSENSE': '#e763fa',
'INFRAME': '#E763FA'
},
backgroundcolor='#F3F6FA'
)
Change the height and width of the component, and adjust the spacing between adjacent tracks.
import json
import urllib.request as urlreq
import dash_bio as dashbio
data = urlreq.urlopen(
'https://git.io/oncoprint_dataset3.json'
).read().decode('utf-8')
data = json.loads(data)
dashbio.OncoPrint(
data=data,
height=800,
width=500,
padding=0.25
)
Show or hide the legend and/or overview heatmap.
import json
import urllib.request as urlreq
import dash_bio as dashbio
data = urlreq.urlopen(
'https://git.io/oncoprint_dataset3.json'
).read().decode('utf-8')
data = json.loads(data)
dashbio.OncoPrint(
data=data,
showlegend=False,
showoverview=False
)
Access this documentation in your Python terminal with:
```pythonhelp(dash_bio.OncoPrint)
```
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 to the component.
eventDatum
(dict; optional):
A Dash prop that returns data on clicking, hovering or resizing the
viewer.
data
(list; optional):
Input data, in CBioPortal format where each list entry is a dict
consisting of ‘sample’, ‘gene’, ‘alteration’, and ‘type’.
padding
(number; default 0.05
):
Adjusts the padding (as a proportion of whitespace) between two
tracks. Value is a ratio between 0 and 1. Defaults to 0.05 (i.e., 5
percent). If set to 0, plot will look like a heatmap.
colorscale
(boolean | dict; optional):
If not None, will override the default OncoPrint colorscale. Default
OncoPrint colorscale same as CBioPortal implementation. Make your own
colrscale as a {‘mutation’: COLOR} dict. Supported mutation keys are
[‘MISSENSE, ‘INFRAME’, ‘FUSION’, ‘AMP’, ‘GAIN’, ‘HETLOSS’, ‘HMODEL’,
‘UP’, ‘DOWN’] Note that this is NOT a standard plotly colorscale.
backgroundcolor
(string; default 'rgb(190, 190, 190)'
):
Default color for the tracks, in common name, hex, rgb or rgba format.
If left blank, will default to a light grey rgb(190, 190, 190).
range
(list; default [None, None]
):
Reset windowing to user preset on initial range or data change.
showlegend
(boolean; default True
):
Toogles whether or not to show a legend on the right side of the plot,
with mutation information.
showoverview
(boolean; default True
):
Toogles whether or not to show a heatmap overview of the tracks.
width
(number | string; optional):
Width of the OncoPrint. Will disable auto-resizing of plots if set.
height
(number | string; default 500
):
Height of the OncoPrint. Will disable auto-resizing of plots if set.
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.