diff --git a/R/extraction_1KG.R b/R/extraction_1KG.R index afcaae47454d920485dd59902600877a3a6ff4d2..cf43320d2d7ea37d186e0f97d97f918f319cd8eb 100644 --- a/R/extraction_1KG.R +++ b/R/extraction_1KG.R @@ -129,6 +129,9 @@ get_vcf <- function(chrom, start, end, pop = NA, path = "", web = TRUE) { vcf <- utils::read.delim( text = gsub("##", "!", txt), header = TRUE, comment.char = "!", stringsAsFactors = FALSE) + # Discard multi-allelic markers. + vcf <- vcf[grep(",", vcf$ALT, invert = TRUE), ] + # Throw error if SNP not found if (nrow(vcf) < 1) { msg <- paste("SNP ", chrom, ":", start, "-", end, " not found", sep = "") @@ -140,10 +143,7 @@ get_vcf <- function(chrom, start, end, pop = NA, path = "", web = TRUE) { # Assign the standard column names and sample identifiers. colnames(vcf)[1] <- "CHROM" - # Discard multi-allelic markers. - vcf <- vcf[grep(",", vcf$ALT, invert = TRUE), ] - - # Select the genotype columns that belong to a particular population. + # Select the genotype columns that belong to a particular population. if (pop %in% pops) { vcf <- vcf[,c(rep(TRUE, 9), pops == pop)] } else if (pop %in% superpops) {