Rename sample id in vcf header
1
0
Entering edit mode
5.2 years ago
tothepoint ▴ 940

I have different vcf file with header

 # #CHROM    POS ID  REF ALT QUAL    FILTER  INFO    FORMAT  **20**

I tried to follow this post: Change sample names in vcf

but not able to succeed.

I want to change this 20 in header file from the vcf with different naming.

Any lead will be highly appreciated.

vcf bcftools • 4.6k views
ADD COMMENT
1
Entering edit mode
5.2 years ago
tothepoint ▴ 940

After little-bit of homework I found one way of doing this. I am posting this way if anyone could get help in future.

Extracted the header by

bcftools view --header-only raw_variants.vcf | sed 's/##contig=<ID=/##contig=<ID=chr/' | sed 's/##contig=<ID=chrMT/##contig=<ID=chrM/' > hello.vcf

Followed by

hello.vcf -> hello

Edited the name accordingly and run:

tabix -r hello raw_variants.vcf > raw7.vcf.gz

or

bcftools reheader -h hello raw_variants.vcf > output.vcf

Works well for me.

ADD COMMENT

Login before adding your answer.

Traffic: 1922 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