Subsetting Vcf based on CHROM and POSS
0
0
Entering edit mode
2.5 years ago
AndrMod • 0

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 • 1.1k views
ADD COMMENT
0
Entering edit mode

Hi! Maybe this or this is of interest?

ADD REPLY
0
Entering edit mode
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
ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

with samtools to bgzip the vcf,

bctools, not samtools

ADD REPLY
0
Entering edit mode

CHROM POS

bcftools doesn't know that this line is a header

ADD REPLY

Login before adding your answer.

Traffic: 1666 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6