# Remapping genomic coordinates to account for indels

I'm interested in obtaining coding sequences of my favourite gene in all individuals from the 1000Genomes (and similar projects). I use GATK to get the right subset of variants, vcf-consensus to map these variants onto the reference genome and finally samtools to extract the individual exons. This works fine if the variants are SNPs but if there are any indels, this changes the coordinates of exons and I end up getting the wrong region. Is there any generic way of remapping genomic coordinates to account for the changes created by indels?

I think that you need a LiftOver Chain file to transform your coordinates. You can obtain such a file using bcftools consensus with the -c parameter:

-c, --chain <file>         write a chain file for liftover


Then you can use it to transform coordinates in various genomic formats using CrossMap.

• Maybe is just me, but his answer seems fine, even to SE standard, but it's just me. – nuin May 30 '17 at 19:43
• @nuin agreed, which is why I upvoted. I just think it would be even better with more detail, that's all. – terdon May 30 '17 at 22:34
• No hard feelings. – nuin May 31 '17 at 2:42

If the goal is to extract the consensus sequence for given regions, this is how it works in 2019.

bgzip and index your vcf file.

$$bgzip -c input.vcf > input.vcf.gz$$ tabix input.vcf.gz


Create a regions.txt which contains one region per line in the format chr:from-to. If you have already a bed file, you can use this little awkscript to create it:

$$awk '{print 1":"2+1"-"$$3}' input.bed > regions.txt


Now run this combination of samtools and bcftools:

\$ samtools faidx -r regions.txt genome.fa|bcftools consensus input.vcf.gz -o consensus.fa