This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Filtering specific columns (SAMPLE IDs) in a VCF file using BCFtools

I would like to filter variants from a VCF file for only specific samples. I have a file (sample_file.txt) that contains a single column of the required Sample IDs.

I used this command:

 ./bcftools view --force-samples sample_file.txt  file.vcf > output.vcf

But I get this error:

Failed to read from sample_file.txt: unknown file type

Should the sample file also contain any header information?

Running the command to view the head of the sample file gives me this:

 head sample_file.txt

GTEX-111CU 
GTEX-111FC
GTEX-111VG
GTEX-111YS
GTEX-1122O
GTEX-1128S
GTEX-117YX
GTEX-11DXX
GTEX-11DZ1
GTEX-11EI6

Further, I would also like to generate a genotype matrix with GT attribute. Is there any command for this?

vcf bcf snp rna-seq software error

1 answer

you want:

 ./bcftools view --samples-file sample_file.txt  file.vcf > output.vcf

Log in to answer this question.