Skip to content

Commit

Permalink
Fix Issue rqtl#178: read_cross2 error->warning re no. alleles
Browse files Browse the repository at this point in the history
  • Loading branch information
kbroman committed Dec 8, 2020
1 parent d740b83 commit ae53a5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
- Fix Issue #157, to have `calc_genoprob()` give a better error
message about missing genetic map.

- Fix Issue #178, to have `read_cross2()` give a warning not an error
if incorrect number of alleles.


## qtl2 0.22-11 (2020-07-09)

Expand Down
16 changes: 12 additions & 4 deletions R/read_cross2.R
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,19 @@ function(file, quiet=TRUE)
if("alleles" %in% names(control)) {
output$alleles <- control$alleles
used_control["alleles"] <- TRUE # indicate that we used it
if(n_alleles != length(output$alleles))
stop("length(alleles) [", length(output$alleles),
"] != expected number [", n_alleles, "]")
if(n_alleles != length(output$alleles)) {
if(length(output$alleles) < n_alleles) {
# pad with a bunch of letters
output$alleles <- c(output$alleles,
rep(LETTERS[!(LETTERS %in% output$alleles)], n_alleles))
}
# trim to n_alleles
output$alleles <- output$alleles[seq_len(n_alleles)]
warning("length(alleles) [", length(output$alleles),
"] != expected number [", n_alleles, "]")
}
} else {
output$alleles <- LETTERS[1:n_alleles]
output$alleles <- LETTERS[seq_len(n_alleles)]
}

class(output) <- "cross2"
Expand Down

0 comments on commit ae53a5c

Please sign in to comment.