aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-09-28 10:15:43 +0300
committerBonfaceKilz2021-09-28 11:23:46 +0300
commit4a55971a9be54b399c45a53e211df3348df1c52b (patch)
tree56204a994144e01109a1c8d186385966f20f9659 /tests
parent767eb96db12476f741bb5197bda7555c29e79b55 (diff)
downloadgenenetwork3-4a55971a9be54b399c45a53e211df3348df1c52b.tar.gz
Retrieve loci names ordered by chromosomes
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/heatmaps.py: implement function * tests/unit/test_heatmaps.py: add test Add a function to retrieve the loci names from the traits, ordered by chromosomes, in alphabetical order. This is useful to provide the user with more information on hovering over the heatmap cells: each cell will now display the locus name, trait name and value associated with it.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_heatmaps.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/unit/test_heatmaps.py b/tests/unit/test_heatmaps.py
index b54e2f3..7b66688 100644
--- a/tests/unit/test_heatmaps.py
+++ b/tests/unit/test_heatmaps.py
@@ -2,6 +2,7 @@
from unittest import TestCase
from gn3.heatmaps import (
cluster_traits,
+ get_loci_names,
get_lrs_from_chr,
export_trait_data,
compute_traits_order,
@@ -214,3 +215,17 @@ class TestHeatmap(TestCase):
[0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]],
[[0.5, 0.579, 0.5],
[0.5, 0.5, 0.5]]])
+
+ def test_get_loci_names(self):
+ """Check that loci names are retrieved correctly."""
+ for organised, expected in (
+ (organised_trait_1,
+ (("rs258367496", "rs30658298", "rs31443144", "rs32285189",
+ "rs32430919", "rs36251697", "rs6269442"),
+ ("rs31879829", "rs36742481", "rs51852623"))),
+ ({**organised_trait_1, **organised_trait_2},
+ (("rs258367496", "rs30658298", "rs31443144", "rs32285189",
+ "rs32430919", "rs36251697", "rs6269442"),
+ ("rs31879829", "rs36742481", "rs51852623")))):
+ with self.subTest(organised=organised):
+ self.assertEqual(get_loci_names(organised, (1, 2)), expected)