This Python script facilitates lifting of genetic data files (Plink format MAP, PED) from one Human genome build version to another using the liftOver tool .
It can liftover from easily between multiple builds available. E.g Hg19, Hg18, GRCH36 and others.
wget http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/liftOver
export PATH=$PATH:/~liftOver PATH
The script converts input files to BED format, performs lifting, and converts back to the original format, providing a seamless transition between genome versions.
python liftover_python_umich_update.py -m old.map -p old.ped -c chain_file -o new.prefix-m, --map: Input MAP file containing genetic marker information (required).-p, --ped: Input PED file containing genotype information (optional).-- CHAIN: Liftover Chain File.-o, --prefix: Prefix for output files (required).--LIFTOVER_BIN: Lifover Binaries.
usage(): Prints the usage information of the script.die(msg): Prints error message and exits the script.myopen(fn): Opens a file and handles gzip format if applicable.map2bed(fin, fout): Converts MAP file to BED format.liftBed(fin, fout, unlifted): Lifts BED file usingliftOvertool.bed2map(fin, fout): Converts BED file back to MAP format.liftPed(fin, fout, fOldMap): Lifts PED file.
- The script parses command-line arguments.
- Converts MAP to BED format.
- Performs lifting using
liftOver. - LIFTOVER_BIN
$ wget https://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/liftOver
$ chmod +x ./filePath/liftOver
$ ./filePath/liftOver- Converts lifted files back to original formats.
- Ensure that the
liftOvertool is installed and accessible in the system path. - Ensure that you get the appropriate chain file (that conversts one build to another) from https://hgdownload2.soe.ucsc.edu/downloads.html
- Plink genotype files can be recoded from binary (bed, bim and fam) to text (map and ped) formats
plink --bfile {prefix} --recode --out {output_file_name}
To re-obtain binary formats we do:
plink --file {} --recode --make-bed --out {output_file_name}