R/lengthChromosome.r

lengthChromosome <- function (chr, units = c("bases", "cM"), build = 37) {
    units <- match.arg(units)
    if(!(build %in% 35:38))
      stop("Argument 'build' should be 35, 36, 37 or 38")

    x <- if(build == 35) Fantasio::cytobands.b35
         else if(build == 36) Fantasio::cytobands.b36
         else if(build == 37) Fantasio::cytobands.b37
         else if(build == 38) Fantasio::cytobands.b38

    x$end <- if(units == "bases") x$end.bp else x$end.cM

    tapply(x$end, x$chr, function(a) tail(a,1) )[ as.character(chr) ]
}
genostats/FEstim documentation built on Feb. 3, 2023, 7:33 p.m.