diff --git a/R/calc_het.R b/R/calc_het.R index 7cd09022..414ef72a 100644 --- a/R/calc_het.R +++ b/R/calc_het.R @@ -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 #' @@ -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) diff --git a/man/calc_het.Rd b/man/calc_het.Rd index 1d1bfa15..22b8a533 100644 --- a/man/calc_het.Rd +++ b/man/calc_het.Rd @@ -25,6 +25,13 @@ The result is a vector of estimated heterozygosities \description{ Calculate heterozygosites, by individual or by marker } +\details{ +\code{calc_het()} looks at the genotype names (the 2nd +dimension of the dimnames of the input \code{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 +} \examples{ iron <- read_cross2(system.file("extdata", "iron.zip", package="qtl2")) p <- calc_genoprob(iron, err=0.002) @@ -36,3 +43,6 @@ het_ind <- calc_het(p) het_mar <- calc_het(p, "marker") } +\seealso{ +\code{\link[=calc_raw_het]{calc_raw_het()}}, \code{\link[=calc_geno_freq]{calc_geno_freq()}} +}