This is a test version of Biostars. For the public version, visit https://www.biostars.org.
filter out subset of samples from vcf file

I have a very big compressed vcf file with over 8000 samples. I wanted to extract out data for those samples whose name start with first three characters "TMS" so that I can have a new vcf file with those samples and their variants data only. Could anyone help me out with the vcftools or bcftools command to accomplish this? Thanks

snp rna-seq sequencing

1 answer

gunzip -c in.vcf.gz | grep "#CHROM" -m 1  | cut -f 10- | tr "\t" "\n" | grep ^TMS > samples.txt

bcftools view --samples-file  samples.txt  in.vcf.gz

zgrep "#CHROM"... ;)

Thanks Pierre. I am able to extract out the samples. All works fine.

If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted.

Upvote|Bookmark|Accept

Log in to answer this question.