vcftools

vcftools

原文日期: 2017-04-12
来源: https://github.com/wlz0726/wlz0726.github.io


VCF 文件操作工具

安装

1
2
3
4
5
6
7
8
9
10
11
# macOS
brew install vcftools

# Ubuntu/Debian
sudo apt-get install vcftools

# 源码编译
git clone https://github.com/vcftools/vcftools.git
cd vcftools
make
make install

基本信息统计

1
2
3
4
5
6
7
8
9
10
11
# 总体统计
vcftools --vcf input.vcf --freq

# 每个样本的缺失率
vcftools --vcf input.vcf --missing-indv

# 每个位点的缺失率
vcftools --vcf input.vcf --missing-site

# 等位基因频率
vcftools --vcf input.vcf --allele-freq

过滤

按质量过滤

1
2
3
4
5
6
7
8
9
10
11
# 最小质量值
vcftools --vcf input.vcf --minQ 30 --recode --recode-INFO-all --out filtered

# 最大缺失率
vcftools --vcf input.vcf --max-missing 0.9 --recode --out filtered

# 最小 MAF
vcftools --vcf input.vcf --maf 0.05 --recode --out filtered

# 最大 MAF
vcftools --vcf input.vcf --max-maf 0.95 --recode --out filtered

按深度过滤

1
2
3
4
5
# 最小深度
vcftools --vcf input.vcf --min-meanDP 10 --recode --out filtered

# 最大深度
vcftools --vcf input.vcf --max-meanDP 100 --recode --out filtered

格式转换

1
2
3
4
5
6
7
8
9
10
11
# VCF → PLINK
vcftools --vcf input.vcf --plink --out output

# VCF → BEAGLE
vcftools --vcf input.vcf --beagle --out output

# VCF → EIGENSTRAT
vcftools --vcf input.vcf --eigenstrat --out output

# VCF → PED
vcftools --vcf input.vcf --ped --out output

提取子集

按样本

1
2
3
4
5
# 从文件读取样本列表
vcftools --vcf input.vcf --keep samples.txt --recode --out subset

# 移除样本
vcftools --vcf input.vcf --remove samples.txt --recode --out subset

按区域

1
2
3
4
5
# 染色体
vcftools --vcf input.vcf --chr 1 --recode --out chr1

# 区域
vcftools --vcf input.vcf --chr 1 --from-bp 1000000 --to-bp 2000000 --recode --out region

按位点

1
2
# 从文件读取位点列表
vcftools --vcf input.vcf --snps snps.txt --recode --out subset

群体遗传统计

1
2
3
4
5
6
7
8
# 核苷酸多样性 (Pi)
vcftools --vcf input.vcf --window-pi 10000 --out pi

# Fst (群体分化)
vcftools --vcf input.vcf --weir-fst-pop pop1.txt --weir-fst-pop pop2.txt --out fst

# Tajima's D
vcftools --vcf input.vcf --TajimaD 10000 --out tajima

此文档为 GitHub 博客自动归档