This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How I do lift over a Plink bim file from Hg18 to Hg19.

I've got some very old SNP data from Data Dryad. The BIM files uses coordinates from Hg18, but my dataset uses coordinates from Hg19.

I was wondering if anyone knows how to liftover coordinates in a Plink BIM file?

plink snp

Had you searched, you would find plenty of resources, like here and here and here and here. Google even auto-fill your query for me.

3 answers

Share my script with you. It can do liftover automatically (be careful about chrX and chrY):

# download database and script
wget http://hgdownload.soe.ucsc.edu/admin/exe/linux.x86_64/liftOver
wget http://hgdownload.soe.ucsc.edu/goldenPath/hg18/liftOver/hg18ToHg19.over.chain.gz
wget http://hgdownload.soe.ucsc.edu/goldenPath/hg19/liftOver/hg19ToHg38.over.chain.gz
wget https://raw.githubusercontent.com/Shicheng-Guo/GscPythonUtility/master/liftOverPlink.py
wget https://raw.githubusercontent.com/Shicheng-Guo/Gscutility/master/ibdqc.pl
# rebuild plink file to avoid chromsome-miss-order problem
plink --bfile Th17Set1 --make-bed --out Th17Set1.sort
# space to tab to generate bed files for liftOver from hg18 to hg19
plink --bfile Th17Set1.sort --recode tab --out Th17Set1.tab
# apply liftOverPlink.py to update hg18 to hg19 or hg38
# Only works in BIRC10, Not HPC, Caused by Python version
mkdir liftOver
./liftOverPlink.py -m Th17Set1.tab.map -p  Th17Set1.tab.ped -o Th17Set1.hg19 -c hg18ToHg19.over.chain.gz -e ./liftOver

When I running your scirpt at the end it shows this message: Converting MAP file to UCSC BED file... SUCC: map->bed succ Lifting BED file... sh: ./liftOver: cannot execute binary file Traceback (most recent call last): File "./liftOverPlink.py", line 172, in <module> makesure(liftBed(oldBed, newBed, unlifted, args.chainFile, liftOverPath), File "./liftOverPlink.py", line 64, in liftBed for ln in myopen(params['UNLIFTED']): File "./liftOverPlink.py", line 34, in myopen return open(fn) IOError: [Errno 2] No such file or directory: 'IMMUNO.hg19.bed.unlifted'

How can I solve ?

I have the same problem as you. Have you solved it and how ? my code like this: python liftOverPlink.py --map chr1.map --out lifted --chain hg18ToHg19.over.chain.gz

but shows this: Converting MAP file to UCSC BED file... SUCC: map->bed succ Lifting BED file... sh: 1: liftOver: not found Traceback (most recent call last): File "liftOverPlink.py", line 172, in <module> makesure(liftBed(oldBed, newBed, unlifted, args.chainFile, liftOverPath), File "liftOverPlink.py", line 64, in liftBed for ln in myopen(params['UNLIFTED']): File "liftOverPlink.py", line 34, in myopen return open(fn) IOError: [Errno 2] No such file or directory: 'lifted.bed.unlifted'

Hi did you solve the problem? I am having similar issues.

Thanks

Are you all using python2 or python3? Make sure it is python2. The liftOverPlink.py and rmBadLifts.py scripts will not work properly unless you are using the older version.

Just got a similar issue and it seems that the liftOverPlink script can't execute the liftOver binary file. You need to change the permission of the liftOver file.

I think the safest method is to convert the Plink Format file to VCF Format first, and then we can use CrossMap to perform liftover. The reason is that CrossMap can check the consistency of REF and ALT in a VCF with the new ref genome, while liftover for the bedpe format focuses only on position.

For example, we can use the following codes to lift the Cohort_b37 to the GRCH38 position.

plink --bfile Cohort_b37 --keep-allele-order --recode vcf --out Cohort_b37
CrossMap vcf --chromid l ./hg19ToHg38.over.chain.gz Cohort_b37.vcf $referenceFasta_b38 Cohort_b38.vcf
plink --vcf Cohort_b38.vcf --make-bed --out Cohort_b38

Liftover does not natively process plink formatted files. But you can have a look to this wrapper: https://github.com/sritchie73/liftOverPlink/blob/master/README.md

Log in to answer this question.