score icon indicating copy to clipboard operation
score copied to clipboard

Liftover error: Reference allele does not match the reference

Open ktg25 opened this issue 1 year ago • 6 comments

Hi,

I am new to using bcftools +liftover, I want to liftOver from hg38 to hg19. However, I get the error: "Error: the reference allele GT does not match the reference NN at..."

I converted my data from bed/bim/fam to VCF using PLINK. I then ran: bcftools +liftover -Ov input_vcf.vcf -- -s human_1kg_v37.fasta -f GCA_000001405.15_GRCh38_no_alt_analysis_set.fna -c hg38ToHg19.over.chain.gz | bcftools sort -Ov -o chr22_vcf_hg19.vcf

Please could you let me know how I can resolve this error?

Thank you

ktg25 avatar Sep 16 '24 19:09 ktg25

PLINK does not generate conforming VCFs. You might want to try to fix your VCF with BCFtools/fixref (bcftools +fixref) and BCFtools/norm (bcftools norm --check-ref x) to make sure that your VCF file is conforming

freeseek avatar Sep 17 '24 02:09 freeseek

Hi @freeseek - I am getting a similar error when trying to liftOver plugin from canFam3 to canFam4:

bcftools  plugin liftover -oZ ${canFam3_vcf} -o canFam_liftOver.vcf.gz -- -f ${canFam4_fasta} -c ${chain_file} -s ${canFam4_fasta} --reject canFam3-reject.vcf.gz  --reject-type b --write-src

Error: the reference allele G does not match the reference A at chr1:14391559

when I look in chr1:14391559 on canFam3 and the same position on canFam4

I can confirm the ref bases are different, but the canFam3 VCF has the correct ref base:

chr1    14391559        1:14391559:G:A  G       A

So I'm not sure how to resolve this. Any advice would be appreciated.

indapa avatar Apr 01 '25 20:04 indapa

canFam3 has a G at position chr1:14391559 while canFam4 has A at position chr1:14391559. Maybe the issue here is that you should use:

-f ${canFam4_fasta} -c ${chain_file} -s ${canFam3_fasta}

In your comment you seem to have the same fasta file for options -s and -f

freeseek avatar Apr 01 '25 21:04 freeseek

hi @freeseek Ah, that was a typo, my corrected command line was this

bcftools  plugin liftover -oZ ${canFam3_vcf}  -o canFam_liftOver.vcf.gz -- -f ${canFam4_fasta} -c ${chain_file} 
-s ${canFam3_fasta} --reject canFam3-reject.vcf.gz  --reject-type b --write-src

And I get a different error

Error: the reference allele T does not match the reference C at chr1:47169768

When I run bcftools norm check-ref option, I get a list of mismatched sites to canFam3 fasta. and chr1:47169768 is on the list


bcftools norm --check-ref w  -f ${canFam3_fasta}  ${canFam3_vcf}  -oU -o /dev/null 2& > mismatch-checkref.txt

It looks like I need to either remove these sites from my VCF or fix the PLINK file that generated this VCF

indapa avatar Apr 02 '25 17:04 indapa

Notice that if you created the VCF using PLINK this will not work correctly as PLINK does not create compliant VCF files. You will need to use an alternative strategy. BCFtools/convert might help

freeseek avatar Apr 08 '25 07:04 freeseek

I removed the mismatched ref allele sites and then the liftover worked just fine. I didn't fully appreciate that PLINK doesn't generate compliant VCFs

indapa avatar Apr 08 '25 16:04 indapa