My primary goal is to use Bokeh to plot bied data. The x-axis is position (chromosomal) and the y-axis is frequency.
Data sample:
Position MAF
19020047 0.000200
19020074 0.000200
19020078 0.000200
19020095 0.056310
19020116 0.000599
19020125 0.000200
19020165 0.000799
19020277 0.000200
19020299 0.000200
19020311 0.000200
I accomplished biing by position with pandas groupby, and then plot:
bins = np.linspace(df.Position.min(), df.Position.max(), 1000)
groups = df.groupby(pd.cut(df.Position, bins))
means = groups.mean().MAF
means.plot()
However, I would like to plot it with Bokeh. Is there a way to plot the groupby object directly? So far, I changed the groupby series to a dataframe and tried to plot, I am getting an error about the x-axis being categorical. I changed it to an object per another post, but that did not fix it.
df_means = pd.Series.to_frame(means)
df_means.reset_index(level=0, inplace=True)
df_means['Position'] = df['Position'].astype(object)
x = df_means['Position']
y = df_means['MAF']
output_notebook()
q = figure(plot_width=800, plot_height=400)
q.circle(df_means.index, y, size=1, color="firebrick", alpha=0.5)
q.xaxis.major_label_orientation = pi/4
show(q)
I receive this error:
AttributeError: 'Categorical' object has no attribute 'tolist'
