Introduction Clustergrammer_Widget2 0.6.1

In [1]:
import numpy as np
import pandas as pd
import clustergrammer_widget2
from clustergrammer import *
net = Network()
In [2]:
net.load_file('rc_two_cats.txt')
net.cluster()
df = net.export_df()
In [3]:
# df.sum(axis=1)
In [4]:
net.load_df(df)
net.cluster()
net_json = net.export_viz_to_widget()

Visualize Example Gene Expression Toy Dataset

In [5]:
w = clustergrammer_widget2.ExampleWidget(network=net_json)
w
In [6]:
w = clustergrammer_widget2.ExampleWidget(network=net_json)
w

Visualize Random Matrix

In [7]:
# generate random matrix
num_rows = 1000
num_cols = 1000
np.random.seed(seed=100)
mat = np.random.rand(num_rows, num_cols)

# make row and col labels
rows = range(num_rows)
cols = range(num_cols)
rows = [str(i) for i in rows]
cols = [str(i) for i in cols]

# make dataframe 
df = pd.DataFrame(data=mat, columns=cols, index=rows)
print(df.shape)
(1000, 1000)
In [8]:
df.head()
Out[8]:
0 1 2 3 4 5 6 7 8 9 ... 990 991 992 993 994 995 996 997 998 999
0 0.543405 0.278369 0.424518 0.844776 0.004719 0.121569 0.670749 0.825853 0.136707 0.575093 ... 0.616522 0.947579 0.906472 0.965094 0.337621 0.656403 0.291456 0.150869 0.036932 0.597964
1 0.027732 0.382237 0.953251 0.222199 0.305126 0.819320 0.578470 0.027617 0.954388 0.312139 ... 0.630891 0.478955 0.140795 0.329110 0.775616 0.633031 0.105247 0.980898 0.364798 0.778565
2 0.259444 0.023003 0.654407 0.969216 0.698952 0.032054 0.003295 0.122310 0.729892 0.743647 ... 0.243378 0.935069 0.458539 0.943485 0.252805 0.205672 0.300088 0.352887 0.602199 0.478208
3 0.076735 0.568912 0.400118 0.308898 0.928405 0.234978 0.901869 0.843908 0.627951 0.858074 ... 0.068109 0.494339 0.130206 0.538030 0.574568 0.078321 0.847301 0.793289 0.348319 0.966167
4 0.769620 0.043597 0.191514 0.121186 0.760843 0.623838 0.462855 0.728147 0.939783 0.267626 ... 0.645082 0.220585 0.017549 0.155266 0.977466 0.237092 0.768674 0.650803 0.861580 0.108839

5 rows × 1000 columns

In [9]:
net.load_df(df)
net.cluster()
net_json = net.export_viz_to_widget()
w = clustergrammer_widget2.ExampleWidget(network=net_json)
w
In [10]:
import ipywidgets 
In [11]:
ipywidgets.__version__
Out[11]:
'7.4.1'
In [ ]:
 
In [ ]: