R/fitQtl2.R

#' @rdname fitDefault
#' @export
fitQtl2 <- function(driver,
                    target,
                    ...) {

  if(is.null(rownames(driver)))
    rownames(driver) <- seq_len(nrow(driver))
  
  out <- qtl2::fit1(driver, target, ...)
  
  # Replace lod names with LR
  names(out) <- stringr::str_replace(names(out), "lod", "LR")
  names(out) <- stringr::str_replace(names(out), "_LR", "LR")

  # Rescael to make them likelihoods (or likelihood ratios)
  out$LR <- out$LR * log(10)
  out$indLR <- out$indLR * log(10)
  
  # Add df for later use
  out$df <- ncol(driver) - 1
  
  # Residuals
  fitted <- rep(NA, length(target))
  names(fitted) <- if(is.matrix(target)) {
    rownames(target)
  } else {
    names(target)
  }
  fitted[names(out$fitted)] <- out$fitted
  out$resid <- target - fitted
  
  out
}
fboehm/qtl2mediate documentation built on June 18, 2019, 8:27 p.m.