This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Is it possible to query column of particular sample on VCF?

I would like to extract specific samples from vcf with speed of bcftools query. Is it possible? Here is an example that obviously does not work:

bcftools query -f '%CHROM %POS %Sample1 %Sample2'

vcf

2 answers

bcftools view --samples S1,S2 in.vcf

Bcftools view appears to be very slow for extracting individual samples, e.g. for my 70 gigabit vcf it takes 1.5h to extract one sample.

split per regions, run in parallel, run bcftools concat at the end.

I this case 70 segmets of 600 samples would mean 42 000 jobs, which seems risky. But i will try.

uh ? these are only 70 jobs (70x extract two samples) , unless I didn't understand your question.

I didn't frame the problem correctly. The goal is to make individual VCF for each sample, of which there are 600 which is extremely slow with bcftools view.

I figured i could accomplish my aim with bcftools query and then substract genotypes that are present in my target sample. However, i don't know how to do that.

I will reframe the question and make another post.

I found a viable solution using bcftools +split plugin, e.g.:

bcftools +split file.vcf -Oz -o testDir -i'GT="alt"'

Log in to answer this question.