From e76dea5005501868c9721cd631b716d7e799306e Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 28 Sep 2021 10:20:52 +0300 Subject: 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. --- gn3/heatmaps.py | 9 +++++++-- 1 file 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)) -- cgit v1.2.3