aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
Diffstat (limited to 'gn3')
-rw-r--r--gn3/api/heatmaps.py18
-rw-r--r--gn3/heatmaps.py25
2 files changed, 23 insertions, 20 deletions
diff --git a/gn3/api/heatmaps.py b/gn3/api/heatmaps.py
index f053241..eea3ebe 100644
--- a/gn3/api/heatmaps.py
+++ b/gn3/api/heatmaps.py
@@ -15,15 +15,9 @@ def clustered_heatmaps():
"message": "You need to provide at least one trait name."
}), 400
conn, _cursor = database_connector()
- _heatmap_file, heatmap_fig = build_heatmap(traits_names, conn)
-
- # stream the heatmap data somehow here.
- # Can plotly actually stream the figure data in a way that can be used on
- # remote end to display the image without necessarily being html?
- # return jsonify(
- # {
- # "query": heatmap_request,
- # "output_png": heatmap_fig.to_image(format="png"),
- # "output_svg": heatmap_fig.to_image(format="svg")
- # }), 200
- return jsonify({"output_filename": _heatmap_file}), 200
+ def setup_trait_fullname(trait):
+ name_parts = trait.split(":")
+ return "{dataset_name}::{trait_name}".format(
+ dataset_name=trait[1], trait_name=trait[0])
+ traits_fullnames = [parse_trait_fullname(trait) for trait in traits_names]
+ return jsonify(build_heatmap(traits_fullnames, conn)), 200
diff --git a/gn3/heatmaps.py b/gn3/heatmaps.py
index c4fc67d..205a3b3 100644
--- a/gn3/heatmaps.py
+++ b/gn3/heatmaps.py
@@ -199,17 +199,26 @@ def build_heatmap(traits_names, conn: Any):
zip(traits_ids,
[traits[idx]["trait_fullname"] for idx in traits_order]))
- return generate_clustered_heatmap(
- process_traits_data_for_heatmap(
+ # return generate_clustered_heatmap(
+ # process_traits_data_for_heatmap(
+ # organised, traits_ids, chromosome_names),
+ # clustered,
+ # "single_heatmap_{}".format(random_string(10)),
+ # y_axis=tuple(
+ # ordered_traits_names[traits_ids[order]]
+ # for order in traits_order),
+ # y_label="Traits",
+ # x_axis=chromosome_names,
+ # x_label="Chromosomes")
+ return {
+ "clustering_data": clustered,
+ "heatmap_data": process_traits_data_for_heatmap(
organised, traits_ids, chromosome_names),
- clustered,
- "single_heatmap_{}".format(random_string(10)),
- y_axis=tuple(
+ "traits": tuple(
ordered_traits_names[traits_ids[order]]
for order in traits_order),
- y_label="Traits",
- x_axis=chromosome_names,
- x_label="Chromosomes")
+ "chromosomes": chromosome_names
+ }
def compute_traits_order(slink_data, neworder: tuple = tuple()):
"""