This is a test version of Biostars. For the public version, visit https://www.biostars.org.
tped files to bed with awk

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

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.

0 answers

No answers yet.

Log in to answer this question.