Entering edit mode
6.2 years ago
seta
★
1.9k
Hi all,
I have the standard vcf file (VCFv4.2) and would like to replace the ID column of vcf file with the column in the other text file. The text file (without header) is like below:
1 56782 1:56782:T:C
I used the below codes to edit the vcf file:
grep -P '^#' file.vcf > new.vcf
grep -v -P '^#' file.vcf | cut -f3- | paste newpos.txt - >> new.vcf
Although it worked and didn’t return any error, vcf-validator gave me the error. Could you please kindly tell me your way to do such an edit on the vcf file?
Thanks
Which error, also please post a selection of the new VCF. Brief Reminder On How To Ask A Good Question
Hello seta ,
it looks like you are trying to add an ID that contain the CHROM, POS, REF and ALT of the variant. If I'm right than you can
bcftools annotate
for this:That's all. No extra file, no special text processing.
fin swimmer
The
+
is not required if one wishes to override existing ID values, which is what seta wants, I think.Thank you for all your responses. At the moment, I don't access to our cluster and can't paste the error from vcf-validator. But, I think the RamRS's solution works as I have the ID column in the text file and want to replace it with the existing one. I try it.
bcftools annotate -a annotation_file.bed -c ID
can do exactly this, just use a BED file with necessary information (chr, pos, ref, alt). Read the bcftools annotate manual carefully for all caveats and requirements.