Dash Bio Volcano Plot

Hi,

I am trying to use the dash bio volcano plot, however I believe something is wrong with the code. The documentation states that any column can be used for P or EFFECTSIZE, by assigning a string of the column name to effect_size and p variables. However, dash does not allow this and requires me to have the columns in my dataframe be EFFECTSIZE and P.

Is there anyway to fix this?

Here is the portion of my code:

def update_volcanoplot(effects):
    return dashbio.VolcanoPlot(
        dataframe=df,
        effect_size='log2FoldChange',
        p='padj',
        genomewideline_value=2.5,
        effect_size_line=effects
    )

And the error:
KeyError: “Column EFFECTSIZE not found in ‘x’ data.frame”

Thanks!

This seems to be working for me (by making a few changes to the example code at VolcanoPlot | Dash for Python Documentation | Plotly) using dash-bio 1.0.2

(For a short while I thought it wasn’t working because I didn’t spot there were two calls to dashbio.VolcanoPlot in that code and both need to have effect_size= specified)

2 Likes

Thank you so much! That fixed my issue. By any chance, do you have an idea of how to change the name “SNP” that gets displayed when highlighting over.a datapoint in the volcano plot?

The documentation states SNP needs to be there to highlight points on the graph and I do want users to be able to hover and see information. However, I don’t have SNP data and would like another data to show, except in the hover it still states “SNP” instead of the column I selected from my dataset.

Thanks for all your help!

This is the correct code for anyone with a similar issue:

app.layout = html.Div([
    'log2FoldChange',
    dcc.RangeSlider(
        id='default-volcanoplot-input',
        min=-5,
        max=5,
        step=0.05,
        marks={i: {'label': str(i)} for i in range(-5, 5)},
        value=[-4.5, 1]
    ),
    html.Br(),
    html.Div(
        dcc.Graph(
            id='dashbio-default-volcanoplot',
            figure=dashbio.VolcanoPlot(
                dataframe=df,
                effect_size='log2FoldChange',
                p='padj',
                snp='pvalue'
            )
        )
    )
])

@callback(
    Output('dashbio-default-volcanoplot', 'figure'),
    Input('default-volcanoplot-input', 'value')
)
def update_volcanoplot(effects):
    return dashbio.VolcanoPlot(
        dataframe=df,
        effect_size='log2FoldChange',
        p='padj',
        snp='pvalue',
        genomewideline_value=2.5,
        effect_size_line=effects
    )