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?
2 Answers
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.
-
$\begingroup$ Nice, +1. It would be great if you could expand this to include an example command the OP could run, the steps needed etc. The Stack Exchange sites have very strict guidelines about what is an answer (that's why I've been bugging you so) and ideally, we want that an answer provide all the needed information to solve the question asked. In other words, please don't post pointers (not even very helpful ones like this) as answers. Either just post a comment, or flesh the pointer into a full answer. $\endgroup$– terdon ♦May 30, 2017 at 16:09
-
$\begingroup$ Maybe is just me, but his answer seems fine, even to SE standard, but it's just me. $\endgroup$– nuinMay 30, 2017 at 19:43
-
$\begingroup$ @nuin agreed, which is why I upvoted. I just think it would be even better with more detail, that's all. $\endgroup$– terdon ♦May 30, 2017 at 22:34
-
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 awk
script 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