how to plot in bokeh

40 views Asked by At

Hi there I'm quite new to Python plotting in general but somehow I can get the gist of things from examples; however, I couldn't find anything useful/helpful to understand how to use bokeh to plot a UMAP.

After experimenting with some tutorial all I get is a single dot, whereas I should have a UMAP based on the NumPy array I'm using. See below for an example

umap_proj

array([[  9.467572  ,   1.3644829 ],
       [  9.608901  ,   1.2682369 ],
       [  0.2737476 ,   6.213452  ],
       [  3.2541463 ,  10.000814  ],
       [ 23.634834  ,   3.198842  ],
       [ 23.586329  ,   3.2471323 ],
       [  3.6388707 ,   5.290971  ],
       [  0.07268663,   5.7849684 ],
       [  0.20859158,   5.7292304 ],
       [  0.84385896,   5.0269856 ],
       [ 11.656524  ,  15.852114  ],
       [ 11.690001  ,  15.9092865 ],
       [  4.307997  ,   9.4132395 ],
       [  4.315025  ,   9.4042425 ],
       [  4.57423   ,  12.418981  ],
       [  4.3381214 ,  13.442026  ],
       [  9.221395  ,   0.99569064],
       [  9.417851  ,   1.2935886 ],
       [  4.0001864 ,  14.564397  ],
       [  9.4523325 ,   2.5142562 ],
       [  0.18032   ,   5.607879  ],
       [  0.20974386,   5.5906544 ],
       [  8.327373  , -13.634082  ],
       [  4.436351  ,  14.6661625 ],
       [  4.439193  ,  14.614582  ],
...
       [  8.337706  , -13.553178  ],
       [  4.1751633 ,   5.5536766 ],
       [  4.110508  ,   5.5729456 ],
       [ 14.518264  ,   7.623279  ],
       [  9.572984  , -13.1281595 ]], dtype=float32)

This is how my array looks like, but I really cannot figure out how to specify to Python to use it for plotting using the figure and circles functions of bokeh. Here the libraries I'm importing:

EDIT TO SHOW ALL COMMANDS

import numpy as np
import pandas as pd
import plotly.express as px
import bokeh.plotting as bp

from bokeh.plotting import figure, show
from umap import UMAP

umap = pd.read_csv("SGDP_bi_snps_norm-2.eigenvec", sep="\t")
umap.rename(columns={"#IID": "#ID"}, inplace=True)

loc = pd.read_csv("loc_fix_python-order.txt")

eigenval = pd.read_csv("SGDP_bi_snps_norm-2.eigenval", header=None)
pve = round(eigenval / (eigenval.sum(axis=0))*100, 2)
pve.head()

umap.sort_values('#ID', inplace=True)
umap.insert(loc=1, column='#LOC', value=loc)
umap.rename(columns={'#ID': 'ID', '#LOC': 'LOC'}, inplace=True)

regions_umap = umap.iloc[:, 2:12]

umap_plot = UMAP(n_components=2, init="random", random_state=15)
umap_proj = umap_plot.fit_transform(regions_umap)
umap_proj.view()

fig = figure(title='SGDP UMAP')
fig.circle(umap_proj[1], umap_proj[2])

Any input on how to start is much appreciated, and sorry for the basic question but I cannot figure it out!

P.S. in plotly works just fine

0

There are 0 answers