aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-12-21 13:04:51 +0300
committerFrederick Muriuki Muriithi2021-12-24 14:36:15 +0300
commit2d3b6eae6953d5e4b00f21b5ffd683271d0f76bc (patch)
tree01666c588a9b1f43a9fe2dd3c294d0ea7e2070c8
parent0508fc422c033cfff8bbea118f85282212d236e4 (diff)
downloadgenenetwork3-2d3b6eae6953d5e4b00f21b5ffd683271d0f76bc.tar.gz
Fix sorting
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Update the sorting algorithm, for literature and tissue correlations so that it sorts the results by the correlation value first then by the p-value next.
-rw-r--r--gn3/computations/partial_correlations.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py
index dbcbe29..1e4a646 100644
--- a/gn3/computations/partial_correlations.py
+++ b/gn3/computations/partial_correlations.py
@@ -717,19 +717,30 @@ def partial_correlations_entry(# pylint: disable=[R0913, R0914, R0911]
def __make_sorter__(method):
- def __sort_6__(row):
- return row[6]
-
- def __sort_3__(row):
+ def __compare_lit_or_tiss_correlation_values_(row):
+ # Index Content
+ # 0 trait name
+ # 1 N
+ # 2 partial correlation coefficient
+ # 3 p value of partial correlation
+ # 6 literature/tissue correlation value
+ return (row[6], row[3])
+
+ def __compare_partial_correlation_p_values__(row):
+ # Index Content
+ # 0 trait name
+ # 1 partial correlation coefficient
+ # 2 N
+ # 3 p value of partial correlation
return row[3]
if "literature" in method.lower():
- return __sort_6__
+ return __compare_lit_or_tiss_correlation_values_
if "tissue" in method.lower():
- return __sort_6__
+ return __compare_lit_or_tiss_correlation_values_
- return __sort_3__
+ return __compare_partial_correlation_p_values__
sorted_correlations = sorted(
all_correlations, key=__make_sorter__(method))