How I do lift over a Plink bim file from Hg18 to Hg19.
3
0
Entering edit mode
7.6 years ago
devenvyas ▴ 760

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 • 14k views
ADD COMMENT
1
Entering edit mode

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.

ADD REPLY
6
Entering edit mode
5.0 years ago
Shicheng Guo ★ 9.6k

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
ADD COMMENT
0
Entering edit mode

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 ?

ADD REPLY
1
Entering edit mode

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'

ADD REPLY
0
Entering edit mode

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

Thanks

ADD REPLY
0
Entering edit mode

The http://hgdownload.soe.ucsc.edu/admin/exe/linux.x86_64/liftOver is the executable version and should be defined after -e $PATH to the location of the liftOver executable

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

Hi,

What commands did you type?

ADD REPLY
1
Entering edit mode
18 months ago
jxcao9812 ▴ 10

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
ADD COMMENT
0
Entering edit mode
7.6 years ago
ml.endale • 0

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

ADD COMMENT

Login before adding your answer.

Traffic: 1579 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6