diff options
Diffstat (limited to 'gn3/heatmaps.py')
-rw-r--r-- | gn3/heatmaps.py | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/gn3/heatmaps.py b/gn3/heatmaps.py index bf9dfd1..91437bb 100644 --- a/gn3/heatmaps.py +++ b/gn3/heatmaps.py @@ -40,16 +40,15 @@ def trait_display_name(trait: Dict): if trait["db"]["dataset_type"] == "Temp": desc = trait["description"] if desc.find("PCA") >= 0: - return "%s::%s" % ( - trait["db"]["displayname"], - desc[desc.rindex(':')+1:].strip()) - return "%s::%s" % ( - trait["db"]["displayname"], - desc[:desc.index('entered')].strip()) - prefix = "%s::%s" % ( - trait["db"]["dataset_name"], trait["trait_name"]) + return ( + f'{trait["db"]["displayname"]}::' + f'{desc[desc.rindex(":")+1:].strip()}') + return ( + f'{trait["db"]["displayname"]}::' + f'{desc[:desc.index("entered")].strip()}') + prefix = f'{trait["db"]["dataset_name"]}::{trait["trait_name"]}' if trait["cellid"]: - return "%s::%s" % (prefix, trait["cellid"]) + return '{prefix}::{trait["cellid"]}' return prefix return trait["description"] @@ -64,11 +63,7 @@ def cluster_traits(traits_data_list: Sequence[Dict]): def __compute_corr(tdata_i, tdata_j): if tdata_i[0] == tdata_j[0]: return 0.0 - corr_vals = compute_correlation(tdata_i[1], tdata_j[1]) - corr = corr_vals[0] - if (1 - corr) < 0: - return 0.0 - return 1 - corr + return 1 - compute_correlation(tdata_i[1], tdata_j[1])[0] def __cluster(tdata_i): return tuple( @@ -136,8 +131,7 @@ def build_heatmap( traits_order = compute_traits_order(slinked) samples_and_values = retrieve_samples_and_values( traits_order, samples, exported_traits_data_list) - traits_filename = "{}/traits_test_file_{}.txt".format( - TMPDIR, random_string(10)) + traits_filename = f"{TMPDIR}/traits_test_file_{random_string(10)}.txt" generate_traits_file( samples_and_values[0][1], [t[2] for t in samples_and_values], @@ -314,7 +308,7 @@ def clustered_heatmap( vertical_spacing=0.010, horizontal_spacing=0.001, subplot_titles=["" if vertical else x_axis["label"]] + [ - "Chromosome: {}".format(chromo) if vertical else chromo + f"Chromosome: {chromo}" if vertical else chromo for chromo in x_axis_data],#+ x_axis_data, figure=ff.create_dendrogram( np.array(clustering_data), @@ -336,7 +330,7 @@ def clustered_heatmap( col=(1 if vertical else (i + 2))) axes_layouts = { - "{axis}axis{count}".format( + "{axis}axis{count}".format( # pylint: disable=[C0209] axis=("y" if vertical else "x"), count=(i+1 if i > 0 else "")): { "mirror": False, @@ -345,12 +339,10 @@ def clustered_heatmap( } for i in range(num_plots)} - print("vertical?: {} ==> {}".format("T" if vertical else "F", axes_layouts)) - fig.update_layout({ "width": 800 if vertical else 4000, "height": 4000 if vertical else 800, - "{}axis".format("x" if vertical else "y"): { + "{}axis".format("x" if vertical else "y"): { # pylint: disable=[C0209] "mirror": False, "ticks": "", "side": "top" if vertical else "left", @@ -358,7 +350,7 @@ def clustered_heatmap( "tickangle": 90 if vertical else 0, "ticklabelposition": "outside top" if vertical else "outside left" }, - "{}axis".format("y" if vertical else "x"): { + "{}axis".format("y" if vertical else "x"): { # pylint: disable=[C0209] "mirror": False, "showgrid": True, "title": "Distance", |