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".

2 comments:

  1. Hi
    This is getting better with plink2, which has "--record HV" option. It produces correct .info file, and uses "0" instead of "-9" for missing phenotypes. There are still some issues with indels, see https://groups.google.com/forum/#!topic/plink2-users/efCweNQY2kk for discussion.

    ReplyDelete
  2. With plink v1.09:

    plink --file --recode HV --snps-only just-acgt --out

    ReplyDelete