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/snpsel documentation built on June 8, 2021, 10:29 p.m.