Published
Edited
Jul 26, 2021
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
// choose your dataset
//////////////////////////////
// csv_string = FileAttachment("10K_random.csv").text()
// csv_string = FileAttachment("1M_random.csv").text()
csv_string = FileAttachment("ccle_data_observable.csv").text()
Insert cell
Insert cell
run_clustergrammer = {
py`
import micropip
micropip.install(['clustergrammer2_core==0.3.0'])
`
var run_clustergrammer = py`
import micropip
import pandas as pd
import scipy
import sklearn
import statsmodels
import matplotlib
import json
from io import StringIO
from clustergrammer2_core import net

from sklearn.manifold import TSNE


def run_clustergrammer(csv_string):
df = pd.read_csv(StringIO(csv_string), sep=",", index_col=0)

X_embedded = TSNE(n_components=2).fit_transform(df.transpose())

rows = ['row-' + str(x) for x in range(X_embedded.shape[0])]
cols = ['col-' + str(x) for x in range(X_embedded.shape[1])]

df_tsne = pd.DataFrame(X_embedded, index=rows, columns=cols)

# net.load_df(df)
net.load_df(df_tsne)



# Z-Score Data
#########################
# net.normalize(axis='row', norm_type='zscore')

net.cluster()
return json.dumps(net.viz)
run_clustergrammer
`
return run_clustergrammer
}
Insert cell
network = JSON.parse(run_clustergrammer(csv_string))
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more