View plink GWA results as genome browser track

This R script will parse plink‘s GC adjusted output to a GFF file that can be uploaded as genome browser track file. Just adjust the pathname at the beginning…

script

 1:
 2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
10:
11:
12:
13:
14:
15:
16:
17:
19:
trait <- c("e:/QT_10s.qassoc.adjusted")
gff <- c("browser position chr5:1-1000000\n")
gff <- paste(gff,'browser hide all\n',sep="")
gff <- paste(gff,'browser pack refGene encodeRegions\n',sep="")
gff <- paste(gff,'browser full altGraph\n',sep="")
gff <- paste(gff,'track type=wiggle_0 name="',trait,'" description="26/6/08" visibility=full maxHeightPixels=30 autoScale=off viewLimits=0:8 color=0,100,200 yLineMark=7 yLineOnOff=off',sep="")
write.table(gff,file=paste(d1,trait,".gff",sep=""),row.names=FALSE,col.names=FALSE,dec=".",quote=FALSE,append=FALSE)
restab <- read.fwf(file=trait,widths=c(4,12,rep(11,8)),skip=1)
restab <- restab[,1:4]
names(restab) <- c("CHR","SNP","UNADJ","GC") 
restab[,"SNP"]<-gsub(" ","",as.character(restab[,"SNP"]))
restab[,1] <- paste("chr",restab[,1],sep="")
restab <- merge(restab,SNP, by.x="SNP", by.y="Name", all.x = FALSE, all.y = FALSE)
restab[,"Position2"] <- restab[,"Position"]+1
restab[,"GC"] <- format.pval(-log10(restab[,"GC"]),digits=1)
restab$Chromosome <- as.numeric(as.character(restab$Chromosome))
restab<-restab[order(restab$Chromosome,restab$Position),]
write.table(restab[,c("CHR","Position","Position2","GC")],file=paste(trait,".gff",sep=""),sep="\t",row.names=FALSE,col.names=FALSE,dec=".",quote=FALSE,,append=TRUE)