R/set.dist.r

Defines functions set.dist

Documented in set.dist

# x = une bed.matrix
# map 
set.dist <- function(x, map, verbose =  getOption("gaston.verbose",TRUE)) {
  if(missing(map) || !is.list(map)) 
    stop("This functions needs a genetic map. Please read the manual.")
  for(chr in as.character(unique(x@snps$chr))) {
    MAP <- map[[chr]]
    if( is.null(MAP) ) {
      if(verbose) cat("No map for chromosome", chr, "\n")
      next
    }
    if(verbose) cat("Setting distances for chromosome", chr, "\n")
    w <- which(x@snps$chr == chr)
    f <- approxfun( MAP$pos, MAP$dist, rule = 2)
    x@snps$dist[w] <- f( x@snps$pos[w] )
  }
  x
}

Try the gaston package in your browser

Any scripts or data that you put into this service are public.

gaston documentation built on Dec. 28, 2022, 1:30 a.m.