This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Subsetting Vcf based on CHROM and POSS

It's been some days that I'm trying to obtain second vcf from a larger one (~40K SNPs). What I want to achieve is to get into this new vcf all the information about non-consecutive 428 sites, of which I have the contig name (CHROM field) and the POS relative to the contig. So far I have tried both with vcftools and the -R command of bcftools, that one with the line

bcftools filter in.vcf -R TabDelimitedListOfCHROMandPOS.txt > out.vcf

where TabDelimitedListOfCHROMandPOS.txt is exactly what it says on the tin: a tab-delimited file with CHROM and POS header containing the information of the variants I wanti in my new vcf - namely, name of the contigs and variant positions. However, the result is

[E::bcf_sr_regions_init] Could not parse the file TabDelimitedListOfCHROMandPOS.txt, using the columns 1,2[,-1]
Failed to read the regions: TabDelimitedListOfCHROMandPOS.txt

Someone can provide some advice on this jazz? I thank you all in advance.

subsetting vcfr vcf
bcftools filter in.vcf -R TabDelimitedListOfCHROMandPOS

you cannot use -R on a plain vcf. Vcf must be bgzipped (or bcf) and indexed.

what is the output of:

$ file TabDelimitedListOfCHROMandPOS.txt

$ head TabDelimitedListOfCHROMandPOS.txt | cat -v

Herethey are:

$ file TabDelimitedListOfCHROMandPOS.txt

TabDelimitedListOfCHROMandPOS.txt: ASCII text

$ head TabDelimitedListOfCHROMandPOS.txt | cat -v

CHROM   POS
NODE_28_length_351_cov_52.603989        95
NODE_63_length_411_cov_32.815086        127
NODE_115_length_250_cov_35.208000       81
NODE_155_length_310_cov_43.019356       315
NODE_157_length_293_cov_37.631401       182
NODE_197_length_289_cov_64.034599       349
NODE_213_length_330_cov_47.336365       61
NODE_213_length_330_cov_47.336365       91
NODE_213_length_330_cov_47.336365       109

As of now I am dealing with samtools to bgzip the vcf, thanks.

with samtools to bgzip the vcf,

bctools, not samtools

CHROM POS

bcftools doesn't know that this line is a header

0 answers

No answers yet.

Log in to answer this question.