Switch ref/alt alleles vcf file
0
2
Entering edit mode
2.6 years ago
mdstep ▴ 20

My model system uses a reference genome from a population that is likely highly derived. I have whole genome sequencing data from two other pops, one (we can call PopB) is likely derived from the other (PopA), and both sets of reads were aligned to the reference. In short I want to take a set of polymorphisms that are fixed/nearly fixed in PopA (that are absent in the reference) and flip which allele is considered the reference in both sets of data. Multiple tests I want to do require the identification ancestral state/assumes ref=ancestral which is not the case in about 15% of the variants. I was able to simply make a list of Chromosome/positions that I want to flip the ref/alt definitions but I don't know of a way to use this list to actually flip them. I'd appreciate any help.

SNP vcf sequencing • 1.8k views
1
Entering edit mode

Hello mdstep,

if you have already a list of positions and REF/ALT alleles you want to switch, you could try something like this:

1. The list must be one of the support types by bcftools annotate and must contain an ID
2. Use this list and bcftools annotate to fill the ID column in the vcf file, you want to switch REF/ALT
3. Use bcftools +fixref file.bcf -Ob -o out.bcf -- -i List_of_1.vcf.gz to switch REF/ALT based on the ID

fin swimmer

0
Entering edit mode

I cant find too much documentation on this flipping from a list, the steps here are not super clear. I know how to flip ref alt in python, but I would like to be able to do it in bcftools for speed.

1. Its not really clear what you mean by list, but have used bcftools annotate before. Do you mean just prepare a gzipped tab indexed set of info fields for SNPS that should be flipped like this?

annotate_file_example.gz:

#CHROM  POS     ID      REF     ALT
6       29910247        my_fav_snp_to_flip        A       T


The run: bcftools +fixref big_vcf_with_unflipped_aleles.vcf.gz -- -i annotate_file_example.gz > big_vcf_with_unflipped_aleles.vcf

I just get

Expected the -f option

0
Entering edit mode

Sorry, I didn't specify, it's all in VCF format.

Traffic: 504 users visited in the last hour
FAQ
API
Stats

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