Skip to content

Commit d979b06

Browse files
authored
Merge pull request #68 from wwoskie/add-zero-bin-length-check
Add check for zeros in user provided bin.length
2 parents 096bb38 + 9c97196 commit d979b06

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

R/optimize_reference_set.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,15 @@ select.reference.set <- function(test.counts, reference.counts, bin.length = NUL
6262

6363
if (!is.matrix(reference.counts)) stop('The reference sequence count data must be provided as a matrix')
6464
if (nrow(reference.counts) != length(test.counts)) stop("The number of rows of the reference matrix must match the length of the test count data\n")
65-
if (is.null(bin.length)) bin.length <- rep(1, length(test.counts))
66-
65+
if (is.null(bin.length)) {
66+
bin.length <- rep(1, length(test.counts))
67+
} else {
68+
# If using user's bin.length, check for zeros and stop execution and stop if any present
69+
zero.counts <- sum(bin.length == 0)
70+
if (zero.counts > 0) {
71+
stop(paste0("bin.length contains ", zero.counts, " zero", ifelse(zero.counts > 1, "s", ""), ". This causes NAs in correlation computing. All bin lengths must be positive"))
72+
}
73+
}
6774

6875
n.ref.samples <- ncol(reference.counts)
6976

0 commit comments

Comments
 (0)