dash_bio.NeedlePlot Examples and Reference

see NeedlePlot in action.

Graph

An example of a default NeedlePlot component without any extra properties.

import json
import six.moves.urllib.request as urlreq
from dash_docs.utils import DatasetLoader
from six import PY3
import dash
from dash.dependencies import Input, Output
import dash_bio as dashbio
import dash_html_components as html
import dash_core_components as dcc

app = dash.Dash(__name__)

data = DatasetLoader().load(
    'https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/' +
    'needle_PIK3CA.json'
)

if PY3:
    data = data.decode('utf-8')

mdata = json.loads(data)

app.layout = html.Div([
    "Show or hide range slider",
    dcc.Dropdown(
        id='default-needleplot-rangeslider',
        options=[
            {'label': 'Show', 'value': 1},
            {'label': 'Hide', 'value': 0}
        ],
        clearable=False,
        multi=False,
        value=1,
        style={'width': '400px'}
    ),
    dashbio.NeedlePlot(
        id='dashbio-default-needleplot',
        mutationData=mdata
    )
])

@app.callback(
    Output('dashbio-default-needleplot', 'rangeSlider'),
    Input('default-needleplot-rangeslider', 'value')
)
def update_needleplot(show_rangeslider):
    return True if show_rangeslider else False

if __name__ == '__main__':
    app.run_server(debug=True)
Show or hide range slider

Customization

Needle Style

Change the appearance of the needles.

import json
import six.moves.urllib.request as urlreq
from dash_docs.utils import DatasetLoader
from six import PY3
import dash_bio as dashbio

data = DatasetLoader().load('https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/needle_PIK3CA.json')

if PY3:
    data = data.decode('utf-8')

mdata = json.loads(data)

dashbio.NeedlePlot(
    mutationData=mdata,
    needleStyle={
        'stemColor': '#FF8888',
        'stemThickness': 2,
        'stemConstHeight': True,
        'headSize': 10,
        'headColor': ['#FFDD00', '#000000']
    }
)

Domain Style

Change the appearance of the domains.

import json
import six.moves.urllib.request as urlreq
from dash_docs.utils import DatasetLoader
from six import PY3
import dash_bio as dashbio

data = DatasetLoader().load('https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/needle_PIK3CA.json')

if PY3:
    data = data.decode('utf-8')

mdata = json.loads(data)

dashbio.NeedlePlot(
    mutationData=mdata,
    domainStyle={
        'displayMinorDomains': True,
        'domainColor': ['#FFDD00', '#00FFDD', '#0F0F0F', '#D3D3D3']
    }
)

NeedlePlot Properties

Access this documentation in your Python terminal with:
```python

help(dash_bio.NeedlePlot)
```

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.

clickData (list; optional):
An array of the points on the graph that have been clicked with
Plotly.js clickEvents.

domainStyle (dict; default { displayMinorDomains: False, domainColor: [ '#8dd3c7', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', '#fccde5', '#d9d9d9', '#bc80bd', '#ccebc5', '#ffed6f', '#8dd3c7', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', ], textangle: 0,}):
Options for the protein domain coloring.

domainStyle is a dict with keys:

margin (dict; default {t: 100, l: 40, r: 0, b: 40}):
Margins of the plot.

mutationData (dict; default { x: [], y: [], domains: [], mutationGroups: [],}):
The data that are displayed on the plot.

mutationData is a dict with keys:

needleStyle (dict; default { stemColor: '#444', stemThickness: 0.5, stemConstHeight: False, headSize: 5, headColor: [ '#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999', '#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999', '#e41a1c', ], headSymbol: 'circle',}):
Options for the needle marking single site mutations.

needleStyle is a dict with keys:

rangeSlider (boolean; default False):
If True, enables a rangeslider for the x-axis.

xlabel (string; optional):
Title of the x-axis.

ylabel (string; optional):
Title of the y-axis.

Example Data