Edinburgh-Genome-Foundry / DnaFeaturesViewer

:eye: Python library to plot DNA sequence features (e.g. from Genbank files)
https://edinburgh-genome-foundry.github.io/DnaFeaturesViewer/
MIT License
578 stars 89 forks source link

Pop-up in bokeh plot #21

Open EulleSA opened 4 years ago

EulleSA commented 4 years ago

Thanks for the library. I would like to know if in your code it is possible to generate popup by clicking on the bokeh web plots so that the user can view more information about the plot.

Zulko commented 4 years ago

Hey, there is no feature for a proper popup, sorry, however GraphicFeatures can have an "html" attribute which indicates what appears when you hover the feature in Bokeh (I don't use the Bokeh backend that much to be honnest).

zchen15 commented 3 years ago

Hi Zulko, I am having the following issues with these lines of code

import dna_features_viewer as dfv
import bokeh
import bokeh.plotting
bokeh.io.output_notebook()

features = [
    dfv.GraphicFeature(
        start=5, end=20, strand=+1, color="#ffd700", label="Small feature"
    ),
    dfv.GraphicFeature(
        start=20,
        end=500,
        strand=+1,
        color="#ffcccc",
        label="Gene 1 with a very long name",
    ),
    dfv.GraphicFeature(
        start=400, end=700, strand=-1, color="#cffccc", label="Gene 2"
    ),
    dfv.GraphicFeature(
        start=600, end=900, strand=+1, color="#ccccff", label="Gene 3"
    )
]
for f in features:
    f.linecolor='green'
    f.box_color='orange' # box color is not being changed??
    f.label_link_color='#ccccff' # label link color is note being changed??

record = dfv.GraphicRecord(sequence_length=1000, features=features)
record.plot()

bokeh.plotting.show(out) # bokeh figure is not being output to notebook because it is formatted as html doc

First, the label_link_color and box_color do not seem to be changed even though I specify it in graphic features. This is particularly annoying when working with jupyter notebook dark theme as I cannot see the lines.

Second, the bokeh plot output is not being properly displayed. The error statement is saying this is some kind of html doc and not a bokeh figure handle.

I prefer to output bokeh plots to the notebook or as bokeh figure so I can add other glyphs or customized toolbars as needed. I can export this to html by myself in bokeh later if needed.

I am using dna_features_viewer 3.0.3

Please let me know if there is a sufficient work around for these issues!

Thank so for this plotting library