Bokeh Volcano Plot

This example demonstrates how to create a volcano plot with hover interaction to display values using the Bokeh library.

Python
import numpy as np
from bokeh.plotting import figure, show
from bokeh.models import HoverTool

# Generate random data
np.random.seed(0)
x = np.random.normal(0, 1, 100)
y = np.random.normal(0, 1, 100)

# Calculate log fold change and p-values
log_fold_change = np.log2(x / y)
p_values = -np.log10(np.random.uniform(0, 1, 100))

# Create Bokeh figure
p = figure(title='Volcano Plot', x_axis_label='Log Fold Change', y_axis_label='-log10(p-value)')

# Add scatter plot
p.scatter(log_fold_change, p_values, size=10, color='black', alpha=0.5)

# Add hover tool to display values
hover = HoverTool(tooltips=[('Log Fold Change', '@x'), ('-log10(p-value)', '@y')])
p.add_tools(hover)

# Show the plot
show(p)