aboutsummaryrefslogtreecommitdiff
path: root/gn3/heatmaps
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2021-08-12 17:21:44 +0300
committerMuriithi Frederick Muriuki2021-08-12 17:21:44 +0300
commit36044483d365a907a9da6ad8a7b3f0dfb0a918e2 (patch)
treebddde66aea13ecb8d77353056c5c7f083c4261f6 /gn3/heatmaps
parent3420e378a614f1ecec85f633cd9f202764a54eda (diff)
downloadgenenetwork3-36044483d365a907a9da6ad8a7b3f0dfb0a918e2.tar.gz
Initialise heatmap generation module
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/heatmaps/heatmaps.py: Initialise the module with some code to be used to test out plotly features on the command-line. * guix.scm: Add `python-plotly` and `python-pandas` as dependencies.
Diffstat (limited to 'gn3/heatmaps')
-rw-r--r--gn3/heatmaps/heatmaps.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/gn3/heatmaps/heatmaps.py b/gn3/heatmaps/heatmaps.py
new file mode 100644
index 0000000..3bf7917
--- /dev/null
+++ b/gn3/heatmaps/heatmaps.py
@@ -0,0 +1,54 @@
+import random
+import plotly.express as px
+
+#### Remove these ####
+
+heatmap_dir = "heatmap_images"
+
+def generate_random_data(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 [[random.uniform(0,data_stop) for i in range(0, width)]
+ for j in range(0, height)]
+
+def heatmap_x_axis_names():
+ return [
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM103710672",
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM2260338",
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM3140576",
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM5670577",
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM2070121",
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM103990541",
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM1190722",
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM6590722",
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM4200064",
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM3140463"]
+#### END: Remove these ####
+
+# 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
+ fig = px.imshow(
+ data,
+ x=heatmap_x_axis_names(),
+ y=y,
+ width=500)
+ fig.update_traces(xtype="array")
+ fig.update_traces(ytype="array")
+ # fig.update_traces(xgap=10)
+ fig.update_xaxes(
+ visible=True,
+ title_text="Traits",
+ title_font_size=16)
+ fig.update_layout(
+ 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