Dash Bio

To install, run the following commands below in your Terminal/Command Line:

pip install dash-bio==0.7.1

Dash is a web application framework that provides pure Python abstraction
around HTML, CSS, and JavaScript.

Dash Bio is a suite of bioinformatics components that make it simpler to
analyze and visualize bioinformatics data and interact with them in a Dash
application.

The source can be found on GitHub at plotly/dash-bio.

These docs are using Dash Bio version 0.7.1.

>>> import dash_bio 
>>> print(dash_bio.__version__)
0.7.1

AlignmentChart

An alignment chart.

import dash_bio as dashbio
import urllib.request as urlreq

data = DatasetLoader().load(
    'https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/alignment_viewer_p53.fasta'
).decode('utf-8')

component = dashbio.AlignmentChart(
    id='my-dashbio-alignmentchart',
    data=data
)

More AlignmentChart Examples and Reference

Circos

A circular ideogram with arcs representing links between genes

import dash_bio as dashbio
import json
import six.moves.urllib.request as urlreq

from dash_docs.utils import DatasetLoader

data = DatasetLoader().load(
    "https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/" +
    "circos_graph_data.json"
).decode("utf-8")

circos_graph_data = json.loads(data)

component = dashbio.Circos(
    id='my-dashbio-circos',
    layout=circos_graph_data['GRCh37'],
    tracks=[{
        'type': 'CHORDS',
        'data': circos_graph_data['chords'],
        'opacity': 0.7,
        'color': {'name': 'color'},
        'config': {
            'tooltipContent': {
                'source': 'source',
                'sourceID': 'id',
                'target': 'target',
                'targetID': 'id',
                'targetEnd': 'end'
            }
        }
    }]
)

More Circos Examples and Reference

Clustergram

A heatmap with dendrograms to display clustering of data such as gene expression data.

import dash_bio as dashbio
import pandas as pd
import dash_core_components as dcc

df = pd.read_csv(
    'https://raw.githubusercontent.com/plotly/dash-bio-docs-files' +
    '/master/clustergram_mtcars.tsv',
    sep='   ', skiprows=4
).set_index('model')

data = df.values

component = dcc.Graph(figure=dashbio.Clustergram(
    data=data,
    color_threshold={'row': 150,
                     'col': 700},
    column_labels=list(df.columns.values),
    row_labels=list(df.index),
    hidden_labels=['row'],
    width=600
))

More Clustergram Examples and Reference

FornaContainer

A secondary structure visualization for RNA molecules.

import dash_bio as dashbio

sequences = [{
    'sequence': 'AUGGGCCCGGGCCCAAUGGGCCCGGGCCCA',
    'structure': '.((((((())))))).((((((()))))))',
    'options': {
        'applyForce': True,
        'circularizeExternal': True,
        'avoidOthers': True,
        'labelInterval': 5,
        'name': 'PDB_01019'
    }
}]

component = dashbio.FornaContainer(
    id='my-dashbio-fornacontainer',
    sequences=sequences
)

More FornaContainer Examples and Reference

Ideogram

A visual representation and analysis tool for chromosome bands.

import dash_bio as dashbio

component = dashbio.Ideogram(
    id='my-dashbio-ideogram',
    chrHeight=250
)

More Ideogram Examples and Reference

Igv

A visual representation and analysis tool for chromosome bands.

import dash_bio as dashbio

component = dashbio.Igv(
    id='my-dashbio-igv',
    genome="ce11",
    minimumBases=100,
    locus="chrV"
)

More Igv Examples and Reference

ManhattanPlot

A plot that can be used to display the results of genomic studies sorted out by chromosome. Perfect for Genome Wide Association Studies (GWAS).

import dash_bio as dashbio
import pandas as pd
import dash_core_components as dcc

df = pd.read_csv(
    'https://raw.githubusercontent.com/plotly/dash-bio-docs-files/' +
    'master/tests/dashbio_demos/sample_data/manhattan_data.csv'
)

component = dcc.Graph(figure=dashbio.ManhattanPlot(
    dataframe=df
))

More ManhattanPlot Examples and Reference

Molecule2dViewer

A 2D rendering of molecular structures.

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

data = DatasetLoader().load(
    "https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/" +
    "mol2d_buckminsterfullerene.json"
).decode("utf-8")

model_data = json.loads(data)

component = dashbio.Molecule2dViewer(
    id='my-dashbio-molecule2dviewer',
    modelData=model_data
)

More Molecule2dViewer Examples and Reference

Molecule3dViewer

A 3D visualization of biomolecular structures.

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

model_data = DatasetLoader().load(
    'https://raw.githubusercontent.com/plotly/dash-bio-docs-files/' +
    'master/mol3d/model_data.js'
)
styles_data = DatasetLoader().load(
    'https://raw.githubusercontent.com/plotly/dash-bio-docs-files/' +
    'master/mol3d/styles_data.js'
)

model_data = json.loads(model_data)
styles_data = json.loads(styles_data)

component = dashbio.Molecule3dViewer(
    id='my-dashbio-molecule3dviewer',
    modelData=model_data,
    styles=styles_data,
    backgroundOpacity='0'
)

More Molecule3dViewer Examples and Reference

NeedlePlot

A combination of a bar chart and a scatter plot, for data that are both categorical and continuous.

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

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

mdata = json.loads(data)

component = dashbio.NeedlePlot(
    id='my-dashbio-needleplot',
    mutationData=mdata
)

More NeedlePlot Examples and Reference

NglMoleculeViewer

A comprehensive 3D molecule visualizer for visualizing multiple molecules and chains in a variety of representations.

import dash_bio as dashbio
import dash_bio_utils.ngl_parser as ngl_parser

data_path =  "https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/"
component = dashbio.NglMoleculeViewer(
    id='my-dashbio-nglmoleculeviewer',
    data=[ngl_parser.get_data(data_path=data_path,
                              pdb_id='1BNA',
                              color='red',
                              reset_view=True,
                              local=False)]
)

More NglMoleculeViewer Examples and Reference

OncoPrint

A chart that can be used to visualize multiple genomic alternations with an interactive heatmap.

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

data = DatasetLoader().load(
    "https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/" +
    "oncoprint_dataset3.json"
).decode("utf-8")

data = json.loads(data)

component = dashbio.OncoPrint(
    id='my-dashbio-oncoprint',
    data=data
)

More OncoPrint Examples and Reference

Pileup

An interactive in-browser track viewer.

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

data = DatasetLoader().load(
    "https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/" +
    "pileup.synth4.tumor.chr1.4930000-4950000.json"
).decode("utf-8")

component = dashbio.Pileup(
    id='my-dashbio-pileup',
    range={
        'contig': 'chr1',
        'start': 4930382,
        'stop': 4946898
    },
    reference={
        'label': 'hg19',
        'url': 'https://hgdownload.cse.ucsc.edu/goldenPath/hg19/bigZips/hg19.2bit'
    },
    tracks=[
        {'viz': 'coverage',
         'label': 'alignments',
         'source': 'alignmentJson',
         'sourceOptions': data
         },
        {'viz': 'pileup',
         'label': 'alignments',
         'source': 'alignmentJson',
         'sourceOptions': data
         }
    ]
)

More Pileup Examples and Reference

SequenceViewer

A sequence viewer.

import dash_bio as dashbio
import dash_bio_utils.protein_reader as protein_reader
import six.moves.urllib.request as urlreq
from dash_docs.utils import DatasetLoader

data = DatasetLoader().load(
    "https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/" +
    "sequence_viewer_P01308.fasta"
).decode("utf-8")

seq = protein_reader.read_fasta(datapath_or_datastring=data, is_datafile=False)[0]['sequence']
component = dashbio.SequenceViewer(
    id='my-dashbio-sequenceviewer',
    sequence=seq
)

More SequenceViewer Examples and Reference

Speck

A 3D WebGL molecule viewer.

import dash_bio as dashbio
import dash_bio_utils.xyz_reader as xyz_reader
import six.moves.urllib.request as urlreq
from dash_docs.utils import DatasetLoader

data = DatasetLoader().load(
    "https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/speck_methane.xyz"
).decode("utf-8")

data = xyz_reader.read_xyz(datapath_or_datastring=data, is_datafile=False)

component = dashbio.Speck(
    id='my-dashbio-speck',
    view={'resolution': 600},
    data=data
)

More Speck Examples and Reference

VolcanoPlot

A graph that can be used to identify clinically meaningful markers in genomic experiments.

import dash_bio as dashbio
import pandas as pd
import dash_core_components as dcc

df = pd.read_csv(
    'https://raw.githubusercontent.com/plotly/dash-bio-docs-files' +
    '/master/volcano_data1.csv'
)

component = dcc.Graph(figure=dashbio.VolcanoPlot(
    dataframe=df
))

More VolcanoPlot Examples and Reference