vcftools的使用小结

计算等位基因频率

--freq计算等位基因频率

vcftools --vcf test.vcf --freq --out output

对来自chr1的每一个位点统计其基因频率

vcftools --gzvcf combined200.vcf.gz --freq --chr chr1 --out chr1_analysis

计算Fst

使用--weir-fst-pop进行Fst计算

vcftools --vcf test.vcf --weir-fst-pop population1.txt --weir-fst-pop population2.txt --out pop1VSpop2

转换为plink格式

使用--plink进行文件转换

vcftools --vcf test.vcf --plink --chr 1 --out output_in_plink

转换plink格式的报错解决

当使用plink转换vcf为ped、map报错:

Writing PLINK PED and MAP files ... Error:  Could not open temporary file.报错

这时可以先用-tped转换,再转换为plink格式。

vcftools --vcf test.vcf --plink-tped --out test

转换为ped、map格式的命令:

plink --tfile test --recode --out test

转换为bim、bed、fam格式的命令:

plink --tfile test --make-bed --out test

比较两个vcf文件

比较2个VCF文件,看哪些个体或者位点是2个文件共享的。指定第二个文件要用--diff --gzdiff or --diff-bcf

vcftools --vcf test1.vcf --diff test2.vcf --out compare

根据id保留或去除vcf文件的样本

#保留
vcftools --vcf in.vcf --recode --recode-INFO-all --stdout  --keep id.txt   > out.vcf
#去除
vcftools --vcf in.vcf --recode --recode-INFO-all --stdout  --remove id.txt   > out.vcf

只保留1号和10号

vcftools --vcf in.vcf --recode --recode-INFO-all --stdout  --indv  1 --indv  10  > out.vcf

基因型数据转换为012格式

用 vcftools 生成 012 矩阵:

vcftools --vcf test.genotypes_no_missing_IDs.vcf --012 --out snp_matrix

后缀为 .012 的 012 基因型矩阵文件,每行为样本,列为基因型。缺失基因型用 -1 表示。
第一列为索引,并不是真实的样本名,在接下来的步骤中需要替换。

0    0    0    0    0    0    0    0    0
1    0    0    0    0    0    0    0    0
2    0    0    1    1    1    1    1    1
3    0    0    0    0    0    0    0    0
4    0    0    0    0    0    0    0    0
5    1    1    1    0    0    1    1    1
6    1    1    1    0    0    0    0    0
7    0    0    0    0    0    0    0    0
8    1    1    1    0    0    0    0    0
9    0    0    0    0    0    0    0    0

后缀为 .012.indv 的样本信息文件。
后缀为 .012.pos 的 SNP 位点坐标文件。

参考链接

VCF格式的学习及对VCF文件的统计
收集vcftools所有用法
vcf文件与vcftools(二)
vcf格式解读
vcftools去除或保留vcf文件中的样品
如何将基因型数据转为 012 格式
vcftools报错的解决方式

  • 1
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值