Showing posts with label genetic. Show all posts
Showing posts with label genetic. Show all posts

Monday, July 12, 2010

Convert PLINK file for Haploview

Suppose you have test.bim, test.bed, and test.fam for PLINK.
1) generate ped/map files
plink --noweb --bfile test --recode --alleleACGT --prune --out gene
This will generate a ped file, gene.ped, coded by letters (instead of numbers) and a map file, gene.map, including marker information.
The "--prune" option removes individuals with missing phenotype. If you don't use "--prune", you may need to update the ped file accordingly because in PLINK ped file, -9 is used for missing while in Haploview/Linkage ped file, 0 is used for missing. Here are some suggestion command lines in R:
----------------------------------------------------------------------------
ped = read.table("gene.ped")
ped[,6]==-9 -> x
ped[x, 6]=0
write.table(ped, file="gene.ped2", row.names=F, col.names=F, quote=F)
----------------------------------------------------------------------------
2) convert map file to contain only marker and position
cut -f 2,4 gene.map > gene.map2
The generated gene.ped and gene.map2 can be input into Haploview as "Linkage format".