From 8e54dacd3da86e7bfcc7a8a424c5a6ce60f98b8c Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Sun, 19 Sep 2021 20:19:20 +0200 Subject: [PATCH] Order data before correlating --- correlation.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/correlation.R b/correlation.R index f3bb536..6814570 100644 --- a/correlation.R +++ b/correlation.R @@ -51,6 +51,10 @@ process_correlation <- function(distances, species_ids, gene_ids, by = "species" ) + # Order data by the reference gene's distance to get a monotonic + # relation. + setorder(data, distance.y) + r_sum <- r_sum + abs(cor(data[, distance.x], data[, distance.y])) }