Welcome to the Genome Toolbox! I am glad you navigated to the blog and hope you find the contents useful and insightful for your genomic needs. If you find any of the entries particularly helpful, be sure to click the +1 button on the bottom of the post and share with your colleagues. Your input is encouraged, so if you have comments or are aware of more efficient tools not included in a post, I would love to hear from you. Enjoy your time browsing through the Toolbox.

Wednesday, May 15, 2013

Transform fastPHASE Output to Haploview Input

After successfully phasing with fastPHASE, I wanted to view the resulting haplotypes in Haploview.  Since I couldn't find any scripts online to convert the hapguess_switch.out file from fastPHASE into the .haps file that Haploview requires, I wrote a brief Python script to do the heavy lifting.


This script is run from the command line by typing python make_haploview_input.py hapguess_switch.out and will produce a hapguess_switch.haps file.  Because of the use of generators, this will only work on Python 2.6 or higher.  You will also need to create a .info file to match the .haps file.  The .info file has the marker loci in the same order as the .haps file and consists of two columns; the first being the marker name and the second being the marker position.

3 comments:

  1. Hi,

    I've copied your code exactly as displayed but I am getting indentation error messages :

    "elif genotypes=="TRUE":
    ^
    IndentationError: unindent does not match any outer indentation level"

    I've tried deleting the spaces and re-inserting them but no success.

    ReplyDelete
    Replies
    1. Sorry about that Danica. Looks like there was an error with formatting when I pasted the code into GitHub. I reformatted things and have updated the above code. Thanks for pointing this out.

      Delete
  2. Hi there
    I have used this code to haps file, could you tell me this haps file belong to which format? there are 6 kinds of format in Haploview.
    regards
    John

    ReplyDelete