vec <- function(x) { v <- rep("",le) xx <- unlist(x) lx <- length(xx) l1 <- lx%/%2 l2 <- 1:l1 lg <- 2*l2 lu <- lg-1 ux <-xx[lu] gx <-xx[lg] ma <- match(ux,fields) v[ma] <- gx return(v) } ancestorSNPsAA <- read.table(paste("/seppdata/sepp/linkage/release_new/ALL.wgs.phase1_intergrated_calls.20101123.snps_indels_svs.sites.vcf",sep=""),header = FALSE, sep = "\t", quote = "",as.is = TRUE,skip=28) infoA <- ancestorSNPsAA$V8 fields <- c("LDAF","AVGPOST","RSQ","ERATE","THETA","CIEND","CIPOS","END","HOMLEN","HOMSEQ","SVLEN","SVTYPE","AC","AN","DEL","GT","DS","GL","AA","AF","AMR_AF","ASN_AF","AFR_AF","EUR_AF","VT","SNPSOURCE") le <- length(fields) LL <- sapply(strsplit(infoA,";"), function(x) strsplit(x,"=")) LL1 <- sapply(LL,vec) annotationA <- cbind(ancestorSNPsAA$V1,ancestorSNPsAA$V2,ancestorSNPsAA$V3,ancestorSNPsAA$V4,ancestorSNPsAA$V5,t(LL1)) colN <- c("CHROM","POS","ID","REF","ALT","LDAF","AVGPOST","RSQ","ERATE","THETA","CIEND","CIPOS","END","HOMLEN","HOMSEQ","SVLEN","SVTYPE","AC","AN","DEL","GT","DS","GL","AA","AF","AMR_AF","ASN_AF","AFR_AF","EUR_AF","VT","SNPSOURCE") colnames(annotationA) <- colN save(annotationA,file="annotationA.Rda") annotationAChr1 <- annotationA[which(annotationA[,1]=="1"),] save(annotationAChr1,file="annotationAChr1.Rda")