Skip to content

Commit

Permalink
calc_het: stop if genotype labels are length two (Issue rqtl#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbroman committed Aug 24, 2023
1 parent 83301f7 commit 322315c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions R/calc_het.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
#' Alternatively, this can be links to a set of cluster sockets, as
#' produced by [parallel::makeCluster()].
#'
#' @details `calc_het()` looks at the genotype names (the 2nd
#' dimension of the dimnames of the input `probs`), which must be
#' two-letter names, and assumes that when the two letters are
#' different it's a heterozygous genotype while if they're the
#' same it's a homozygous genotype
#'
#' @seealso [calc_raw_het()], [calc_geno_freq()]
#'
#' @return
#' The result is a vector of estimated heterozygosities
#'
Expand Down Expand Up @@ -55,6 +63,11 @@ calc_het <-
# determine which columns are het
het_col <- vector("list", n_chr)
geno <- dimnames(probs)[[2]]

if(any(nchar(geno) != 2)) {
stop("calc_het requires genotypes to have two-letter names")
}

for(chr in seq_len(n_chr)) {
a1 <- substr(geno[[chr]], 1, 1)
a2 <- substr(geno[[chr]], 2, 2)
Expand Down
10 changes: 10 additions & 0 deletions man/calc_het.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 322315c

Please sign in to comment.