Deleted:bokeh is showing question mark insted of table id
0
1
Entering edit mode
5.3 years ago

i'm using this notebook to create a volcano plot. every thing is ok but when i hover over circles in the plot i get question marks insted of row names. the data is like

enter image description here

filan   C1_1    C2_2    C3_3    DHF_1   DHF_2   DHF_3
B5DEL7  1.090499775 1.086909871 0.76203966  0.181394264 0.256439611 0.229528536
Q7TMZ5  1.50292661  1.303648069 0.813031161 0.228957799 0.267887808 0.248759305
Q9Z252  1.166141378 0.959763948 0.940509915 0.352063418 0.352604465 0.386476427
Q6IMF3  0.952723998 0.314914163 3   0.346934017 0.612478535 0.39764268
D3ZSF3  0.526789734 0.564914163 0.934844193 0.550244812 0.697195192

the code is

 data = pd.read_table("/home/data.txt",
                         header = 0,
                         index_col = 0)

    source = ColumnDataSource(
        data = dict(
            names = data.index,

        )
    )

        p = figure(plot_width=900, plot_height=900,
                   title = "Volcano Plot",
                   x_axis_label = "Fold change",
                   y_axis_label = "P-value (-log10)",
                   background_fill_color="lightgrey",
                   tools="crosshair,save,pan,wheel_zoom,box_zoom,reset,hover",
                   v_symmetry=True,
                   match_aspect=True,
                   x_range=(-10,10))
        p.background_fill_color = "white"

        m2 = plt.cm.ScalarMappable(cmap=plt.cm.get_cmap("Spectral_r"),
                                  norm=plt.Normalize(vmin=np.min(fold), vmax=np.max(fold)))




        rgba2 = m2.to_rgba(fold)
        mycolors2 = [colors.rgb2hex(c) for c in rgba2]

        p.scatter(x = fold,
                  y = -np.log(pvalue),
                  radius = np.abs(fold)/10,
                  fill_color = mycolors2,
                  fill_alpha = 0.9,
                  line_color = "white")

        hover = p.select(dict(type=HoverTool))
        hover.tooltips = [("Probe id", "@names"),
                        ("Fold change","$x"),
                        ("P-value (-log10)","$y")]

i'm using this tutorial http://slideviewer.herokuapp.com/url/ahmedmoustafa.io/notebooks/microarray.ipynb#/

this code works in my environment.it means it's not related to environment or os or browser.

import numpy as np
import pandas as pd
import bokeh.plotting as bk
from bokeh.models import HoverTool

my_df = pd.DataFrame(
    {
        "Column1": [7,19,16],
        "Column2": ["Age","Age","Notage"],
        "Rows": ["Row1", "Row2", "Row3" ]
    }
)
source = bk.ColumnDataSource(my_df)
hover = HoverTool(
    tooltips = [
        ("index1", "@Column1")
    ]
)

p = bk.figure(
    tools=[hover],
    x_range=list(my_df["Rows"].values),
)

p.vbar(
    x="Rows",
    width=0.4,
    top="Column1",
source=source
)

bk.show(p)

source of the code: https://stackoverflow.com/questions/48464465/bokeh-tooltip-not-showing-values-when-using-a-pandas-dataframe

python volcano plot bokeh • 2.0k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2589 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6