Beispiel #1
0
def test_dbmp002_suggestiveline_value(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(dash_bio.ManhattanPlot(dataframe=_data)))

    nested_component_app_callback(app,
                                  dash_duo,
                                  component=dash_bio.ManhattanPlot,
                                  component_data=_data,
                                  data_prop_name='dataframe',
                                  test_prop_name='suggestiveline_value',
                                  test_prop_value=5,
                                  prop_value_type='int',
                                  take_snapshot=True)

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(dash_bio.ManhattanPlot(dataframe=_data)))

    nested_component_app_callback(app,
                                  dash_duo,
                                  component=dash_bio.ManhattanPlot,
                                  component_data=_data,
                                  data_prop_name='dataframe',
                                  test_prop_name='suggestiveline_value',
                                  test_prop_value=9,
                                  prop_value_type='int',
                                  take_snapshot=True)
Beispiel #2
0
def test_dbcl007_hidden_labels(dash_duo):

    app = dash.Dash(__name__)

    data = _mtcars_data
    row_labels = list(_mtcars_data.index)
    col_labels = list(_mtcars_data.columns)

    app.layout = html.Div(
        nested_component_layout(
            dash_bio.Clustergram(data=data,
                                 row_labels=row_labels,
                                 column_labels=col_labels)))

    nested_component_app_callback(
        app,
        dash_duo,
        component=dash_bio.Clustergram,
        component_data=data,
        test_prop_name="hidden_labels",
        test_prop_value="row",
        prop_value_type="string",
    )

    # ensure that row labels are hidden
    assert len(dash_duo.find_elements("g.yaxislayer-above g.y5tick")) == 0
    # ensure that column labels are displayed
    assert len(dash_duo.find_elements("g.xaxislayer-above g.x5tick")) == len(
        col_labels)

    # create a new instance of the app to test hiding of column labels

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(
            dash_bio.Clustergram(data=data,
                                 row_labels=row_labels,
                                 column_labels=col_labels)))

    nested_component_app_callback(
        app,
        dash_duo,
        component=dash_bio.Clustergram,
        component_data=data,
        test_prop_name="hidden_labels",
        test_prop_value="col",
        prop_value_type="string",
    )

    # ensure that column labels are hidden
    assert len(dash_duo.find_elements("g.xaxislayer-above g.x5tick")) == 0
    # ensure that row labels are displayed
    assert len(dash_duo.find_elements("g.yaxislayer-above g.y5tick")) == len(
        row_labels)
Beispiel #3
0
def test_dbcl003_row_col_thresholds(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(nested_component_layout(
        dash_bio.Clustergram(
            data=_data
        )
    ))

    nested_component_app_callback(
        app,
        dash_duo,
        component=dash_bio.Clustergram,
        component_data=_data,
        test_prop_name='color_threshold',
        test_prop_value=json.dumps({'row': 250, 'col': 700}),
        prop_value_type='dict',
        take_snapshot=True
    )

    # there should be two clusters, i.e., two traces, for the column dendrogram
    # plus one trace for the background
    assert len(dash_duo.find_elements(
        'g.subplot.x2y2 > g.plot g.trace.scatter')) == 3

    # three clusters for the row dendrogram, plus one for the background
    assert len(dash_duo.find_elements(
        'g.subplot.x4y4 > g.plot g.trace.scatter')) == 4
Beispiel #4
0
def test_dbcl005_row_annotations(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(nested_component_layout(
        dash_bio.Clustergram(
            data=_data
        )
    ))

    nested_component_app_callback(
        app,
        dash_duo,
        component=dash_bio.Clustergram,
        component_data=_data,
        test_prop_name='row_group_marker',
        test_prop_value=json.dumps(
            [{'group': 2, 'annotation': 'cluster two',
              'color': 'rgb(248, 62, 199)'}]),
        extra_props={'color_threshold': {'row': 250, 'col': 700}},
        prop_value_type='list',
        take_snapshot=True
    )

    # the annotation has shown up
    assert len(dash_duo.find_elements('g.subplot.x6y6')) == 1

    # the annotation is the correct color
    dash_duo.wait_for_style_to_equal(
        'g.subplot.x6y6 g.plot g.lines > path', 'stroke', 'rgb(248, 62, 199)')
Beispiel #5
0
def test_dbcl003_row_col_thresholds(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(dash_bio.Clustergram(data=_data)))

    nested_component_app_callback(
        app,
        dash_duo,
        component=dash_bio.Clustergram,
        component_data=_data,
        test_prop_name="color_threshold",
        test_prop_value=json.dumps({
            "row": 250,
            "col": 700
        }),
        prop_value_type="dict",
        take_snapshot=True,
    )

    # there should be 9 traces for the column dendrogram
    # plus one trace for the background
    assert len(
        dash_duo.find_elements(
            "g.subplot.x2y2 > g.plot g.trace.scatter")) == 10

    # 30 traces for the row dendrogram, plus one for the background
    assert len(
        dash_duo.find_elements(
            "g.subplot.x4y4 > g.plot g.trace.scatter")) == 31
Beispiel #6
0
def test_dbcl005_row_annotations(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(dash_bio.Clustergram(data=_data)))

    nested_component_app_callback(
        app,
        dash_duo,
        component=dash_bio.Clustergram,
        component_data=_data,
        test_prop_name="row_group_marker",
        test_prop_value=json.dumps([{
            "group": 2,
            "annotation": "cluster two",
            "color": "rgb(248, 62, 199)"
        }]),
        extra_props={"color_threshold": {
            "row": 250,
            "col": 700
        }},
        prop_value_type="list",
        take_snapshot=True,
    )

    # the annotation has shown up
    assert len(dash_duo.find_elements("g.subplot.x6y6")) == 1

    # the annotation is the correct color
    dash_duo.wait_for_style_to_equal("g.subplot.x6y6 g.plot g.lines > path",
                                     "stroke", "rgb(248, 62, 199)")
Beispiel #7
0
def test_dbvp006_test_layout_props(dash_duo):
    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(
            dash_bio.VolcanoPlot(
                dataframe=_data,
                width=600,
                legend={
                    'x': 0.85,
                    'orientation': 'h',
                    'yanchor': 'bottom',
                    'y': 1.02,
                    'bgcolor': '#f2f5fa'
                },
                xaxis={"color": "red"},
                yaxis={"color": "blue"},
                template="simple_white",
            )))

    nested_component_app_callback(app,
                                  dash_duo,
                                  component=dash_bio.VolcanoPlot,
                                  component_data=_data,
                                  test_prop_name='plot_bgcolor',
                                  test_prop_value='pink',
                                  prop_value_type='string',
                                  data_prop_name='dataframe',
                                  take_snapshot=True)
Beispiel #8
0
def test_dbcl002_cluster_by_row_or_col(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(nested_component_layout(
        dash_bio.Clustergram(
            data=_data
        )
    ))

    nested_component_app_callback(
        app,
        dash_duo,
        component=dash_bio.Clustergram,
        component_data=_data,
        test_prop_name='cluster',
        test_prop_value='row',
        prop_value_type='string'
    )

    assert len(dash_duo.find_elements('g.subplot.x2y2')) == 0
    assert len(dash_duo.find_elements('g.subplot.x4y4')) == 1

    # create a new instance of the app to test column clustering

    app = dash.Dash(__name__)

    app.layout = html.Div(nested_component_layout(
        dash_bio.Clustergram(
            data=_data
        )
    ))

    nested_component_app_callback(
        app,
        dash_duo,
        component=dash_bio.Clustergram,
        component_data=_data,
        test_prop_name='cluster',
        test_prop_value='col',
        prop_value_type='string',
        take_snapshot=True
    )

    assert len(dash_duo.find_elements('g.subplot.x4y4')) == 0
    assert len(dash_duo.find_elements('g.subplot.x2y2')) == 1
Beispiel #9
0
def test_dbmp005_highlight_color(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(dash_bio.ManhattanPlot(dataframe=_data)))

    nested_component_app_callback(app,
                                  dash_duo,
                                  component=dash_bio.ManhattanPlot,
                                  component_data=_data,
                                  data_prop_name='dataframe',
                                  test_prop_name='highlight_color',
                                  test_prop_value='rgb(76, 184, 254)',
                                  prop_value_type='string',
                                  take_snapshot=True)
Beispiel #10
0
def test_dbvp005_effect_size_line_value(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(dash_bio.VolcanoPlot(dataframe=_data)))

    nested_component_app_callback(app,
                                  dash_duo,
                                  component=dash_bio.VolcanoPlot,
                                  component_data=_data,
                                  test_prop_name='effect_size_line',
                                  test_prop_value=json.dumps([-0.5, 1.5]),
                                  prop_value_type='list',
                                  data_prop_name='dataframe',
                                  take_snapshot=True)
Beispiel #11
0
def test_dbvp004_genomewideline_value(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(dash_bio.VolcanoPlot(dataframe=_data)))

    nested_component_app_callback(app,
                                  dash_duo,
                                  component=dash_bio.VolcanoPlot,
                                  component_data=_data,
                                  test_prop_name='genomewideline_value',
                                  test_prop_value=4,
                                  prop_value_type='int',
                                  data_prop_name='dataframe',
                                  take_snapshot=True)
Beispiel #12
0
def test_dbvp002_points_color(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(dash_bio.VolcanoPlot(dataframe=_data)))

    nested_component_app_callback(app,
                                  dash_duo,
                                  component=dash_bio.VolcanoPlot,
                                  component_data=_data,
                                  test_prop_name='col',
                                  test_prop_value='rgb(12, 254, 42)',
                                  prop_value_type='string',
                                  data_prop_name='dataframe',
                                  take_snapshot=True)
def test_dbcl001_colorscale(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(dash_bio.Clustergram(data=_data)))

    nested_component_app_callback(
        app,
        dash_duo,
        component=dash_bio.Clustergram,
        component_data=_data,
        test_prop_name='color_map',
        test_prop_value=json.dumps([[0, 'blue'], [0.5, 'yellow'], [1,
                                                                   'pink']]),
        prop_value_type='list',
        path_to_test_prop='["data"][2]["colorscale"]',
        take_snapshot=True)
Beispiel #14
0
def test_dbcl001_colorscale(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(dash_bio.Clustergram(data=_data)))

    nested_component_app_callback(
        app,
        dash_duo,
        component=dash_bio.Clustergram,
        component_data=_data,
        test_prop_name="color_map",
        test_prop_value=json.dumps([[0, "blue"], [0.5, "yellow"], [1,
                                                                   "pink"]]),
        prop_value_type="list",
        path_to_test_prop='["data"][41]["colorscale"]',
        take_snapshot=True,
    )
Beispiel #15
0
def test_dbmp003_genomewide_color(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        nested_component_layout(dash_bio.ManhattanPlot(dataframe=_data)))

    nested_component_app_callback(app,
                                  dash_duo,
                                  component=dash_bio.ManhattanPlot,
                                  component_data=_data,
                                  data_prop_name='dataframe',
                                  test_prop_name='genomewideline_color',
                                  test_prop_value='rgb(209, 171, 251)',
                                  prop_value_type='string')

    dash_duo.wait_for_style_to_equal(
        '#test-graph svg:nth-child(3) g.layer-above g.shapelayer > path:nth-child(2)',
        'stroke', 'rgb(209, 171, 251)')
def test_dbcl006_df_input_row_cluster(dash_duo):

    app = dash.Dash(__name__)

    # run the same test as dbcl002 (row clustering) where table of
    # observations (data argument) is left as a DataFrame
    assert isinstance(_mtcars_data, pd.DataFrame)
    app.layout = html.Div(
        nested_component_layout(dash_bio.Clustergram(data=_mtcars_data)))

    nested_component_app_callback(app,
                                  dash_duo,
                                  component=dash_bio.Clustergram,
                                  component_data=_data,
                                  test_prop_name='cluster',
                                  test_prop_value='row',
                                  prop_value_type='string')

    assert len(dash_duo.find_elements('g.subplot.x2y2')) == 0
    assert len(dash_duo.find_elements('g.subplot.x4y4')) == 1