From cc5b66470f84fcc416a2f62c3fcec0a8208c27cd Mon Sep 17 00:00:00 2001 From: "Eric C. Anderson" Date: Tue, 19 Dec 2023 10:08:08 -0700 Subject: [PATCH] Check for end_pos - start_pos < 1 in rec rates --- R/check_rec_rates_formatting.R | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/R/check_rec_rates_formatting.R b/R/check_rec_rates_formatting.R index 940c24d..e4076cf 100644 --- a/R/check_rec_rates_formatting.R +++ b/R/check_rec_rates_formatting.R @@ -29,6 +29,14 @@ check_rec_rates_formatting <- function(rr) { slice(1) %>% filter(start_pos != 1) + # finally, check to make sure that the end_pos is at least one greater than the start + # pos in each bin + bin_probs <- tmp %>% + filter(end_pos - start_pos < 1) + + + + # Bark some informative errors if any of the above tibbles is not empty if(nrow(cl_tib) > 0) { stringy <- paste("\t- Chrom:", cl_tib$chrom, "\n") err <- paste("* end_pos of right-most bin not 1 greater than chromosome length for chromosomes: \n", @@ -42,6 +50,12 @@ check_rec_rates_formatting <- function(rr) { msg <- paste(msg, err, sep = "") Flag <- TRUE } + if(nrow(bin_probs) > 0) { + stringy <- paste("\t- Chrom:", bin_probs$chrom, "start_pos:", bin_probs$start_pos, " end_pos:", bin_probs$end_pos, "\n") + err <- paste("* end_pos of these bins is not at least 1 greater than start_pos: \n", paste(stringy, collapse = "")) + msg <- paste(msg, err, sep = "") + Flag <- TRUE + } if(nrow(one_starts) > 0) { stringy <- paste("\t- Chrom:", one_starts$chrom, "\n") err <- paste("* Left-most bin start position is not 1 for these chromosomes: \n", paste(stringy, collapse = ""))