def test_dbpu004_no_tracks(dash_duo): app = dash.Dash(__name__) TWOBIT_URL = os.path.join(app.get_asset_url(''), "pileup", "chr17_little.2bit") app.layout = html.Div( simple_app_layout( dash_bio.Pileup(id=_COMPONENT_ID, range={ "contig": 'chr17', "start": 7512284, "stop": 7512644 }, reference={ "label": _GENOME, "url": TWOBIT_URL }), )) dash_duo.start_server(app) # Check that the genome loaded dash_duo.wait_for_text_to_equal('.reference>.track-label', _GENOME) # Check that reference track loaded tracks = dash_duo.find_elements('.reference') assert len(tracks) == 1 # track-label and track-content assert tracks[0].text == _GENOME
def layout(): return html.Div(id='pileup-body', className='app-body', children=[ html.Div(id='pileup-control-tabs', className='control-tabs', children=[ dcc.Tabs( id='pileup-tabs', value='data', children=[ dcc.Tab( label='Data', value='data', children=html.Div(className='control-tab', children=[ dcc.Graph( id='pileup-dashbio-volcanoplot', figure=dash_bio.VolcanoPlot( dataframe=DE_dataframe, effect_size='log2FoldChange', title="Differentially Expressed Genes", genomewideline_value=-np.log10(0.05), p='padj', snp='SNP', gene='Gene', ) ) ]) ), dcc.Tab( label='About', value='what-is', children=html.Div(className='control-tab', children=[ html.H4(className='what-is', children='What is pileup.js?'), dcc.Markdown( """ The Dash pileup.js component is a high-performance genomics data visualization component developed originally by the Hammer Lab (https://github.com/hammerlab/pileup.js). pileup.js supports visualization of genomic file formats, such as vcfs, bam, and bigbed files. pileup.js additionally allows flexible interaction with non-standard data formats. Users can visualize GA4GH JSON formatted alignments, features and variants. Users can also connect with and visualize data stored in GA4GH formatted data stores. """ ) ]) ) ] ) ]), dcc.Loading(parent_className='dashbio-loading', id='pileup-output', children=html.Div([ dash_bio.Pileup( id=_COMPONENT_ID, range=HOSTED_CASE_DICT['rna-differential']['range'], reference=REFERENCE, tracks=HOSTED_CASE_DICT['rna-differential']['tracks'], ) ])), ])
def return_pileup(genome): if HOSTED_GENOME_TRACKS.get(genome) is None: raise Exception("No tracks for genome %s" % genome) return (html.Div([ dashbio.Pileup(id='default-pileup', range=HOSTED_GENOME_TRACKS[genome]['range'], reference=HOSTED_GENOME_TRACKS[genome]['reference'], tracks=HOSTED_GENOME_TRACKS[genome]['tracks']) ]))
def test_dbpu002_json(dash_duo): app = dash.Dash(__name__) TWOBIT_URL = os.path.join(app.get_asset_url(''), "pileup", "chr17_little.2bit") # read in JSON as string: local file dir_path = os.path.dirname(os.path.realpath(__file__)) file = os.path.join(dir_path, "assets", "pileup", "alignments.ga4gh.chr17.1-250.json") with open(file, "r") as f: json = re.sub(r'\s+', '', f.read()) pileup_label = 'bam file in GA4GH json' tracks = [{ 'viz': 'pileup', 'label': pileup_label, 'source': 'alignmentJson', 'sourceOptions': json }] app.layout = html.Div( simple_app_layout( dash_bio.Pileup(id=_COMPONENT_ID, range={ "contig": 'chr17', "start": 7512284, "stop": 7512644 }, reference={ "label": _GENOME, "url": TWOBIT_URL }, tracks=tracks), )) dash_duo.start_server(app) # Check that the genome loaded dash_duo.wait_for_text_to_equal('.reference>.track-label', _GENOME) # Check that reference track loaded tracks = dash_duo.find_elements('.reference') assert len(tracks) == 1 # track-label and track-content assert tracks[0].text == _GENOME # Check that pileup track loaded tracks = dash_duo.find_elements('.pileup') assert len(tracks) == 1 # track-label and track-content # gear and track name should be printed assert pileup_label in tracks[0].text assert _GEAR_ICON in tracks[0].text
def layout(app): HOSTED_CASE_DICT = rna_differential(app) return html.Div( id="pileup-body", className="app-body", children=[ html.Div( id="pileup-control-tabs", className="control-tabs", children=[ dcc.Tabs( id="pileup-tabs", value="data", children=[ dcc.Tab( label="Volcano plot", value="data", children=html.Div( className="control-tab", children=[ "Effect Size", dcc.RangeSlider( id="pileup-volcanoplot-input", min=df_min, max=df_max, step=None, marks={ i: {"label": str(i)} for i in range(df_min, df_max + 1, 2) }, value=[-1, 1], ), html.Br(), dcc.Graph( id="pileup-dashbio-volcanoplot", figure=dash_bio.VolcanoPlot( dataframe=DE_dataframe, margin=go.layout.Margin(l=0, r=0, b=0), legend={ "orientation": "h", "yanchor": "bottom", "y": 1.02, "bgcolor": "#f2f5fa", }, effect_size="log2FoldChange", effect_size_line=[-1, 1], title="Differentially Expressed Genes", genomewideline_value=-np.log10(0.05), p="padj", snp="SNP", gene="Gene", ), ), ], ), ), dcc.Tab( label="About this tutorial", value="description", children=html.Div( className="control-tab", children=[ html.H4( className="description", children="""Visualizing RNA-seq data with pileup.js and volcano plots""", ), dcc.Markdown( """ In this example, we use the pileup.js and volcano plot components from dash-bio to visualize two RNA-sequencing (RNA-seq) samples from two conditions. RNA-seq allows us to learn how the expression of genes changes between different samples of interest. Here, we are looking at RNA-seq from two samples that are taken from two different mouse cell types. We refer to these different cell types as basal and luminal cell types. On the right, we use pileup.js to visualize aligned reads from RNA-seq samples. On the left, we have a volcano plot, that visualizes the magnitude of change in gene expression between the two samples. On the x-axis, the `Effect Size` indicates the log2 fold change in expression between the two conditions. On the y-axis, `-log10(p)` indicates the -log10(p-value) for each gene. This p-value, along with the effect size, can help determine whether each gene is significantly differentially expressed between the conditions of interest. To explore a gene, you can click on a gene in the volcano plot. After clicking on a gene, the genomic region overlapping that gene will show up in the pileup.js browser on the right. Now, you can investigate RNA-seq alignments at each gene of interest. You may notice that genes with a negative effect size in the volcano plot have more RNA-seq reads in the top sample (the basal cell type), while genes with a positive effect size have more reads in the bottom sample (the luminal cell type). """ ), ], ), ), dcc.Tab( label="About pileup.js", value="what-is", children=html.Div( className="control-tab", children=[ html.H4( className="what-is", children="What is pileup.js?", ), dcc.Markdown( """ The Dash pileup.js component is a high-performance genomics data visualization component developed originally by the Hammer Lab (https://github.com/hammerlab/pileup.js). pileup.js supports visualization of genomic file formats, such as vcf, bam, and bigbed files. pileup.js additionally allows flexible interaction with non-standard data formats. Users can visualize GA4GH JSON formatted alignments, features and variants. Users can also connect with and visualize data stored in GA4GH formatted data stores. """ ), ], ), ), ], ) ], ), dcc.Loading( parent_className="dashbio-loading", id="pileup-output", children=html.Div( [ dash_bio.Pileup( id=_COMPONENT_ID, range=HOSTED_CASE_DICT["range"], reference=REFERENCE, tracks=HOSTED_CASE_DICT["celltype"], ) ] ), ), ], )
def test_dbpu001_reference(dash_duo): app = dash.Dash(__name__) TWOBIT_URL = os.path.join(app.get_asset_url(''), "pileup", "chr17_little.2bit") pileup_label = 'bam file' feature_label = 'features' tracks = [{ 'viz': 'scale', 'label': 'Scale' }, { 'viz': 'location', 'label': 'Location' }, { 'viz': 'genes', 'label': 'genes', 'source': 'bigBed', 'sourceOptions': { 'url': 'http://www.biodalliance.org/datasets/ensGene.bb' } }, { 'viz': 'variants', 'label': 'variants', 'source': 'vcf', 'sourceOptions': { 'url': os.path.join(app.get_asset_url(''), "pileup", "snv.chr17.vcf") } }, { 'viz': 'pileup', 'label': pileup_label, 'source': 'bam', 'sourceOptions': { 'url': os.path.join(app.get_asset_url(''), "pileup", "synth3.normal.17.7500000-7515000.bam"), 'indexUrl': os.path.join(app.get_asset_url(''), "pileup", "synth3.normal.17.7500000-7515000.bam.bai") } }, { 'viz': 'features', 'label': feature_label, 'source': 'bigBed', 'sourceOptions': { 'url': os.path.join(app.get_asset_url(''), "pileup", "chr17.22.10000-21000.bb") } }] app.layout = html.Div( simple_app_layout( dash_bio.Pileup(id=_COMPONENT_ID, range={ "contig": 'chr17', "start": 7512284, "stop": 7512644 }, reference={ "label": _GENOME, "url": TWOBIT_URL }, tracks=tracks), )) dash_duo.start_server(app) # Check that the genome loaded dash_duo.wait_for_text_to_equal('.reference>.track-label', _GENOME) # Check that reference track loaded tracks = dash_duo.find_elements('.reference') assert len(tracks) == 1 # track-label and track-content assert tracks[0].text == _GENOME # check dropdown menu tracks = dash_duo.find_elements('.controls') assert "chr17" in tracks[0].text # Check that pileup track loaded tracks = dash_duo.find_elements('.pileup') assert len(tracks) == 1 # track-label and track-content # gear and track name should be printed assert pileup_label in tracks[0].text assert _GEAR_ICON in tracks[0].text # Take a Percy snapshot to check that tracks are rendered correctly dash_duo.percy_snapshot('test-pileup_reference', convert_canvases=True) # Check that feature track loaded tracks = dash_duo.find_elements('.features') assert len(tracks) == 1 # track-label and track-content # gear and track name should be printed assert feature_label in tracks[0].text assert _GEAR_ICON in tracks[0].text