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.
Showing posts with label MEGA. Show all posts
Showing posts with label MEGA. Show all posts

Tuesday, July 16, 2013

Create FASTA sequences for Phased Haplotypes

Here is some Python code I put together to convert a .haps file (and associated .sample file) into a .fasta file with an entry for each haploytpe sequence.  Haplotypes are designated >ID_A and >ID_B for each ID in the .sample file.   The program can easily be modified to accept a list of SNPs or IDs that you would like to extract from the .haps file.  Also, this program removes indels that may be present in the .haps file to avoid alignment issues.  This program was useful to feed haplotype input into phylogenetic tree programs, such as MEGA.  Just run the program by typing python make_fasta.py data.haps in at the commnad prompt and you will get a data.fasta file as output.  Hope it is useful.

How to get Phased Imputed Genotypes for Haplotype Analysis

I wanted to compare haplotypes from a set of cases genotyped on one platform to a set of reference controls genotyped on another platform for a small chromosomal region.  I looked into a few methods to do this and found that phasing the genotypes using SHAPEIT and then imputing off the 1000 Genomes reference panel using IMPUTE2 was the optimal approach to have a set of overlapping genotypes for a haplotype analysis.  Phasing from the .ped and .map files was easy using SHAPEIT.  The command I used with my .ped and .map files was:


Other file types can also be used as direct input to SHAPEIT (ex: .bed/.bim/.fam and .gen/.sample).  Genetic recombination maps can be downloaded here for build36 and build37.  Also the backslashes (\) are not necessary.  They just help organize the code by telling the computer to keep reading the input on the next line.

Once you have your .haps and .sample file generated, you are then ready to impute using IMPUTE2.  I used the command below:


Again the backslashes are just for a cleaner visualization of the code.  It is important when using the 1000 Genomes as your reference panel to have the SNP coordinates in hg19 coordinates.  LiftOver can help you convert from one build to another.  If you need the 1000 Genomes reference panel, it can be downloaded here.  The genetic map file is from the above SHAPEIT download.  Finally, if you want phased imputed results, the -phase command is essential to include.

You should now have your phased imputed genotypes to do whatever you wish with.  I chose to convert the phased imputed genotypes into a .fasta file with entries for each haplotype (see Python script).  Then I created parsimony trees with MEGA and visualized them in HapView.

Tuesday, May 21, 2013

How to Make a Phylogenetic Tree

I wanted to cluster some genetic haplotypes I have into a phylogenetic structure to look for similarities between haplotypes.  I stumbled across the program MEGA.  Molecular Evolutionary Genetics Analysis (MEGA) is a relatively easy to use program that offers a wide variety of cluster building algorithms.  The input data format is relatively easy to generate based on the provided examples and the output trees are quite customizable.  Check it out for yourself.