From c8dde0f03e90296d82fa148664c525d2bd010aaa Mon Sep 17 00:00:00 2001 From: Vincent LAVILLE <vincent.laville@pasteur.fr> Date: Wed, 23 Jan 2019 13:16:34 +0100 Subject: [PATCH] Update extraction_1KG.R --- R/extraction_1KG.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/extraction_1KG.R b/R/extraction_1KG.R index afcaae4..cf43320 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) { -- GitLab