Question: Filter VCF by sample?
2
gravatar for cmdcolin
3.1 years ago by
cmdcolin1.2k
United States
cmdcolin1.2k wrote:

I was trying to filter VCF files by sample using vcftools, and I'm testing on the 1000 genomes datasets

If I try to filter by CEU samples for example, I can try this

vcftools --gzvcf ALL.chr1.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz --recode --out CEU --keep CEU.tsv

Where CEU.tsv contains the sample IDs that are from the CEU population

The thing is that this appears to include variants where there are no variations in the kept samples. I tried settings --min-alleles also, but this didn't seem to fix it.

This operation is also pretty slow...any faster ways to do it?

vcftools 1000genomes • 2.2k views
ADD COMMENTlink modified 3.1 years ago by trausch1.4k • written 3.1 years ago by cmdcolin1.2k
2
gravatar for trausch
3.1 years ago by
trausch1.4k
Germany
trausch1.4k wrote:

BCFtools should work

bcftools view --force-samples -o ceu.vcf.gz -O z --samples-file CEU.tsv --min-ac 1 input.vcf.gz

ADD COMMENTlink written 3.1 years ago by trausch1.4k

Thanks again for this answer. Finding my own questions in a google search now 2 years later. Note that a relatively recent version of bcftools should be used e.g. the one from htslib simple because the options like --min-ac don't exist in the old 0.1.19 from the samtools package. If someone just wants a single sample you can just use bcftools view -s HG00096 --min-ac 1 100genomes.vcf.gz where --min-ac makes sure that there is at least 1 non-reference allele in the resulting output for that sample

ADD REPLYlink modified 11 months ago • written 11 months ago by cmdcolin1.2k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 968 users visited in the last hour