R读取VCF文件

作者: 落寞的橙子 | 来源:发表于2019-05-21 02:35 被阅读1次

第一种方法

#参考这个(https://cloud.tencent.com/developer/article/1369842)
library(vcfR)
vcf_file='yourdir/merge.dbsnp.vcf'
vcf <- read.vcfR( vcf_file, verbose = F, checkFile=F )

第二种方法

# read two times the vcf file, first for the columns names, second for the data
tmp_vcf<-readLines("test.vcf")
tmp_vcf_data<-read.table("test.vcf", stringsAsFactors = FALSE)

# filter for the columns names
tmp_vcf<-tmp_vcf[-(grep("#CHROM",tmp_vcf)+1):-(length(tmp_vcf))]
vcf_names<-unlist(strsplit(tmp_vcf[length(tmp_vcf)],"\t"))
names(tmp_vcf_data)<-vcf_names

相关文章

网友评论

    本文标题:R读取VCF文件

    本文链接:https://www.haomeiwen.com/subject/fxvrzqtx.html