How To Show The Name Of Genes On Manhattan Plot
2
5
Entering edit mode
12.8 years ago
Sara ▴ 130

Hi,

I draw Manhattan plot in R but I like to show also the name of genes on it (http://www.genetics.org/content/187/2/367/F2.large.jpg) ? how can i do that ?

many thanks in advance

gwas visualization r • 14k views
ADD COMMENT
8
Entering edit mode
12.8 years ago
Thomas ▴ 760

In relation to the above comments I just wanted to add a small example of a manhatten plot with addition of rs number (or genes) in R:

generation of a data set

pval<-runif(100000, 0, 1); logPval<--log(pval,base=10); pos=1:100000; chr<-paste("chr",rep(1:20,ea=5000),sep=""); rsID<-paste("rs",1:100000,sep=""); data<-as.data.frame(cbind(chr,pos,rsID,pval,logPval));

vectors that defines color

vek<-as.numeric(gsub(data$chr,pattern="chr",replacement=""))%%2

vector that defines which dot should have a rs number (all with pval<0.0001)

vek2<-ifelse(as.numeric(as.character(data[,"pval"]))<0.0001,T,F)

plotting

plot(x=as.numeric(data$pos),y=as.numeric(as.character(data$logPval)),col=c("red","blue")[as.factor(vek)])

adding the text

text(labels=as.character(data$rsID[vek2]),x=as.numeric(data$pos)[vek2],y=as.numeric(as.character(data$logPval))[vek2],pos=4,cex=0.8)

ADD COMMENT
5
Entering edit mode
12.8 years ago
Sander Timmer ▴ 710

If I look at this plot I would almost think that these are placed there by hand.

I'm not sure how your Manhattan plot looks like right now (did you use any package?) but Getting Genetics Done has quite some nice code examples about making a Manhattan plot and QQ plot in R using ggplot2

If you are willing to leave R you could also look at WGA viewer which can plot your Manhattan plot and add different data tracks next to it.

If you're just interested in showing the association later for a specific region I would recommend using LocusZoom, that tool can plot gene names + locations and adds LD information to a locus of interest.

ADD COMMENT
3
Entering edit mode

@Sander - Thanks for the link to my code. I've also used LocusZoom and found it useful. You can probably d/l a local copy and mod the code to add text to the plot.

@Sarah - It shouldn't be hard to add the text in R using a text() command after creating the plot using the code in http://gettinggeneticsdone.blogspot.com/2011/04/annotated-manhattan-plots-and-qq-plots.html. You could even join your list of SNPs to a list of genes (as in http://gettinggeneticsdone.blogspot.com/2011/06/mapping-snps-to-genes-for-gwas.html ) and then automatically add gene labels if p is less than a threshold.

ADD REPLY
0
Entering edit mode

I'd agree with Stephen that adding using text is probably the easiest way to do it. Unless you do this everyday and need a function to do it repeatedly, it's probably the best time investment.

ADD REPLY

Login before adding your answer.

Traffic: 2594 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6