aboutsummaryrefslogtreecommitdiff
path: root/gn3/heatmaps.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-09-17 10:32:23 +0300
committerFrederick Muriuki Muriithi2021-09-17 10:32:23 +0300
commite17540bf8a57837fcf3241ea0b694250b53294fc (patch)
treeeac352f5550152ab837fc3c9a4b20968b9341048 /gn3/heatmaps.py
parent78871ef396f394c54072960e985476e418220fe3 (diff)
downloadgenenetwork3-e17540bf8a57837fcf3241ea0b694250b53294fc.tar.gz
Fix some layout issues and update colorscale
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Update the plot layouts and size to display the dendrogram and individual chromosome heatmaps side by side * Update the colour scale to begin with the grays rather than absolute black
Diffstat (limited to 'gn3/heatmaps.py')
-rw-r--r--gn3/heatmaps.py32
1 files changed, 28 insertions, 4 deletions
diff --git a/gn3/heatmaps.py b/gn3/heatmaps.py
index bf69d9b..2859dde 100644
--- a/gn3/heatmaps.py
+++ b/gn3/heatmaps.py
@@ -344,7 +344,7 @@ def generate_clustered_heatmap(
x_label: str = "", y_axis = None, y_label: str = "",
output_dir: str = TMPDIR,
colorscale = (
- (0.0, '#3B3B3B'), (0.4999999999999999, '#ABABAB'),
+ (0.0, '#5D5D5D'), (0.4999999999999999, '#ABABAB'),
(0.5, '#F5DE11'), (1.0, '#FF0D00'))):
"""
Generate a dendrogram, and heatmaps for each chromosome, and put them all
@@ -367,6 +367,33 @@ def generate_clustered_heatmap(
for i, hm in enumerate(hms):
fig.add_trace(hm, row=1, col=(i + 2))
+ fig.update_layout(
+ {
+ "width": 1500,
+ "height": 800,
+ "xaxis": {
+ "mirror": False,
+ "showgrid": True
+ }
+ })
+
+ x_axes_layouts = {
+ "xaxis{}".format(i+1 if i > 0 else ""): {
+ "mirror": False,
+ "showticklabels": True if i==0 else False,
+ "ticks": "outside" if i==0 else ""
+ }
+ for i in range(num_cols)}
+
+ fig.update_layout(
+ {
+ "width": 4000,
+ "height": 800,
+ "yaxis": {
+ "mirror": False,
+ "ticks": ""
+ },
+ **x_axes_layouts})
fig.update_traces(
showlegend=False,
colorscale=colorscale,
@@ -375,9 +402,6 @@ def generate_clustered_heatmap(
showlegend=True,
showscale=True,
selector={"name": x_axis[-1]})
- fig.update_layout(
- coloraxis_colorscale=colorscale
- )
image_filename = "{}/{}.html".format(output_dir, image_filename_prefix)
fig.write_html(image_filename)
return image_filename, fig