aboutsummaryrefslogtreecommitdiff
path: root/gn3/heatmaps.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-09-28 10:20:52 +0300
committerBonfaceKilz2021-09-28 11:23:46 +0300
commite76dea5005501868c9721cd631b716d7e799306e (patch)
tree2ce8f2e7b93e4c549ca82a6f0759f2f5d5575394 /gn3/heatmaps.py
parent4a55971a9be54b399c45a53e211df3348df1c52b (diff)
downloadgenenetwork3-e76dea5005501868c9721cd631b716d7e799306e.tar.gz
Provide loci names to heatmap
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Provide the loci names to the heatmaps so that hovering over the heatmap cells displays the associated locus name.
Diffstat (limited to 'gn3/heatmaps.py')
-rw-r--r--gn3/heatmaps.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/gn3/heatmaps.py b/gn3/heatmaps.py
index 9c10ba3..adbfbc6 100644
--- a/gn3/heatmaps.py
+++ b/gn3/heatmaps.py
@@ -230,7 +230,8 @@ def build_heatmap(traits_names, conn: Any):
for order in traits_order),
y_label="Traits",
x_axis=chromosome_names,
- x_label="Chromosomes")
+ x_label="Chromosomes",
+ loci_names=get_loci_names(organised, chromosome_names))
def compute_traits_order(slink_data, neworder: tuple = tuple()):
"""
@@ -351,6 +352,7 @@ def process_traits_data_for_heatmap(data, trait_names, chromosome_names):
def generate_clustered_heatmap(
data, clustering_data, image_filename_prefix, x_axis=None,
x_label: str = "", y_axis=None, y_label: str = "",
+ loci_names: Sequence[Sequence[str]] = tuple(),
output_dir: str = TMPDIR,
colorscale=((0.0, '#0000FF'), (0.5, '#00FF00'), (1.0, '#FF0000'))):
"""
@@ -369,9 +371,12 @@ def generate_clustered_heatmap(
np.array(clustering_data), orientation="right", labels=y_axis))
hms = [go.Heatmap(
name=chromo,
+ x=loci,
y=y_axis,
z=data_array,
- showscale=False) for chromo, data_array in zip(x_axis, data)]
+ showscale=False)
+ for chromo, data_array, loci
+ in zip(x_axis, data, loci_names)]
for i, heatmap in enumerate(hms):
fig.add_trace(heatmap, row=1, col=(i + 2))