aboutsummaryrefslogtreecommitdiff
path: root/gn3/heatmaps
diff options
context:
space:
mode:
Diffstat (limited to 'gn3/heatmaps')
-rw-r--r--gn3/heatmaps/heatmaps.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/gn3/heatmaps/heatmaps.py b/gn3/heatmaps/heatmaps.py
index 3bf7917..88f546d 100644
--- a/gn3/heatmaps/heatmaps.py
+++ b/gn3/heatmaps/heatmaps.py
@@ -14,6 +14,19 @@ def generate_random_data(data_stop: float = 2, width: int = 10, height: int = 30
return [[random.uniform(0,data_stop) for i in range(0, width)]
for j in range(0, height)]
+def generate_random_data2(data_stop: float = 2, width: int = 10, height: int = 30):
+ """
+ This is mostly a utility function to be used to generate random data, useful
+ for development of the heatmap generation code, without access to the actual
+ database data.
+ """
+ return [
+ [{
+ "value": item,
+ "category": random.choice(["C57BL/6J +", "DBA/2J +"])}
+ for item in axis]
+ for axis in generate_random_data(data_stop, width, height)]
+
def heatmap_x_axis_names():
return [
"UCLA_BXDBXH_CARTILAGE_V2::ILM103710672",
@@ -30,13 +43,14 @@ def heatmap_x_axis_names():
# Grey + Blue + Red
def generate_heatmap():
- rows = 20
- data = generate_random_data(height=rows)
- y = (["%s"%x for x in range(1, rows+1)][:-1] + ["X"]) #replace last item with x for now
+ cols = 20
+ y_axis = (["%s"%x for x in range(1, cols+1)][:-1] + ["X"]) #replace last item with x for now
+ x_axis = heatmap_x_axis_names()
+ data = generate_random_data(height=cols, width=len(x_axis))
fig = px.imshow(
data,
- x=heatmap_x_axis_names(),
- y=y,
+ x=x_axis,
+ y=y_axis,
width=500)
fig.update_traces(xtype="array")
fig.update_traces(ytype="array")
@@ -49,6 +63,5 @@ def generate_heatmap():
coloraxis_colorscale=[
[0.0, '#3B3B3B'], [0.4999999999999999, '#ABABAB'],
[0.5, '#F5DE11'], [1.0, '#FF0D00']])
-
fig.write_html("%s/%s"%(heatmap_dir, "test_image.html"))
return fig