R/subset_vcf.R

Defines functions subset_vcf

#' @export
#' @author CainĂ£ Max Couto-Silva

subset_vcf <- function(vcf, ids, out) {
  # Create temporary file to store list of individuals
  tmp <- paste0(gsub(" ", "_", Sys.time()), "_tmp.txt")
  writeLines(ids, tmp)
  # Run Plink to remove them
  plink2 (
    `--vcf` = vcf,
    `--keep` = tmp,
    `--export` = "vcf bgz",
    `--out` = out
    )
  # Remove temporary file
  unlink(tmp)
}
cmcouto-silva/gt documentation built on June 6, 2021, 7:14 p.m.