R/read_tabix.R

Defines functions get_region_tabix

Documented in get_region_tabix

#' Load raw data from tabix indexed intensity file
#'
#' @import data.table

get_region_tabix <- function(chr, start, end, f_path, snppos = NA) {
  a <- fread(cmd = paste0("tabix ", f_path, " ", chr, ":", start, "-", end), header = F)
  colnames(a) <- c("chr", "position", "end", "LRR", "BAF", "LRRadj")

  # Turn NaN into standard NAs
  a[LRR == "NaN", LRR := NA][BAF == "NaN", BAF := NA]

  # filter SNPs if required
  if (!is.na(snppos)) a <- a[snp_name %in% snp_pos$snp_name, ]

  setorder(a, position)
  return(a)
}
SinomeM/QCtreeCNV documentation built on Dec. 5, 2023, 4:06 p.m.