tped files to bed with awk
0
0
Entering edit mode
3.0 years ago
storm1907 ▴ 30

Hello, I have Plink tped files in the following format:

>       chr1:183189 0   183189  G   C
>       chr1:609407 0   609407 G   C

That are needed to be converted in bed format (chr, start, end, name), but without plink --tfile command (the latest generates binary file, that is unusable for downstream analysis). The best option is awk, but I do not know, how to write proper code in this case. Any suggestions?

Thank you!

plink • 519 views
ADD COMMENT
1
Entering edit mode

For OP text, to extract chromosome and coordinates:

$ awk -F ':|\t' -v OFS="\t" '{print $1,$2,$4}' test.txt 

chr1    183189  183189
chr1    609407  609407


$ sed -r 's/^(.*):([0-9]+)\t[0-9]+\t([0-9]+)\t[A-Za-z].*/\1\t\2\t\3/g' test.txt                                                                                    

chr1    183189  183189
chr1    609407  609407

Please be mindful of 0 based indexing of bed files. I am not sure if original file is zero based or not. Adjust coordinates accordingly.

ADD REPLY

Login before adding your answer.

Traffic: 2701 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