1、在linux中安装好R

2、准备好画曼哈顿图的R脚本即manhattan.r,manhattan.r内容如下:

  1. #!/usr/bin/Rscript
  2. #example : Rscript plot_manhatom.r XXX.assoc XXX.pdf
  3. argv <- commandArgs()
  4. #define the function to plot the manhatton and quantitle-quantitle plot
  5. plot_manhatton<-function(site_file,save_file){
  6. read.table(site_file,header=T)->data
  7. data<-data[which(data[,5]=="ADD"),]
  8. logp=-log10(data[,9]) #value
  9. chr=data[,1] #chr
  10. position<-data[,3] #position
  11. # xaxis=0
  12. sig=numeric()
  13. lab=numeric()
  14. flogp=numeric();
  15. the_col=c("darkblue","gray"); #chr class
  16. whole_col=c()
  17. xlabel=numeric();
  18. length_add=0
  19. label=numeric();
  20. for(i in 1:22){
  21. position[chr==i]->chr_pos
  22. chr_pos<-chr_pos-chr_pos[1]+17000000
  23. chr_num=length(chr_pos)
  24. cat("For chrosome",i,",Num of SNPs:",chr_num,"\n")
  25. if(length(chr_pos)==0){
  26. next
  27. }
  28. flogp=c(flogp,logp[chr==i])
  29. label=c(label,i)
  30. whole_col=c(whole_col,rep(the_col[i%%2+1],chr_num))
  31. chr_pos=length_add+chr_pos
  32. xlabel=c(xlabel,chr_pos)
  33. length_add=sort(chr_pos,decreasing=T)[1]
  34. lab=c(lab,(chr_pos[1]+length_add)/2)
  35. }
  36. png(save_file,height=500,width=600)
  37. par(mar=c(5,6,4,2))
  38. plot(xlabel,flogp,col=whole_col,axes=F,xlab="",ylab="",ylim=c(0,12),pch=20,cex=0.5,cex.lab=1.2,cex.axis=1.4)#ylim=c(0,6)
  39. significance=-log10(0.05/length(data[,1]))
  40. sig_pos<-xlabel[which(flogp>significance)]
  41. for(i in 1:length(sig_pos)){
  42. sig<-c(sig,which(xlabel>sig_pos[i]-60000 & xlabel<sig_pos[i]+60000))
  43. }
  44. sig<-unique(sig)
  45. cat("significant signal:",sig[10:20],"\n")
  46. points(xlabel[sig],flogp[sig],col="red",pch=20,cex=0.5)
  47. title(xlab="Chromosome",ylab=expression(-log[10]*(p)),cex.lab=1.4)
  48. # title(xlab="Chromosome",ylab="Score",cex.lab=1.8)
  49. # title("GWAS scan for Hair curl", cex.main=2.5)
  50. # yaxis=seq(0,1,by=0.1)
  51. # axis(2,yaxis,yaxis,las=1,cex.axis=1.5,line=-2)
  52. axis(2,las=2,cex.axis=1.4)
  53. #las can change the directory of the axis character
  54. #las=0 always parallel to the axis
  55. #las=2 always horizontal
  56.  
  57. for(i in 1:22){
  58. mtext(label[i],side=1,at=lab[i],las=0,font=1,cex=0.8)
  59. #cex magnified relative to the to the default
  60. }
  61. # mtext("X",side=1,at=x[23],las=0,font=1,cex=1.4)
  62. # mtext("Y",side=1,at=x[24],las=0,font=1,cex=1.4)
  63.  
  64. # axis(1,x,as.character(label),tick=TRUE,font=1)
  65. par(lty=2)
  66. abline(h=significance,cex=1.5,col="red")
  67. #plot the QQ plot
  68. # par(fig=c(0.58,0.92,0.43,0.95),new=TRUE)
  69. # observed <- sort(data[,12])
  70. # logp=-log10(observed)
  71. # expected <- c(1:length(observed))
  72. # lexp <- -(log10(expected / (length(expected)+1)))
  73. # plot(x=lexp,y=logp,pch=19,cex=0.6, xlab="Expected (-logP)", ylab="Observed (-logP)",cex.lab=1.2,cex.axis=1.2)
  74. # abline(0,1,col="red",lwd=2,lty=1)
  75.  
  76. dev.off()
  77. }
  78.  
  79. site_file<-argv[6];print(site_file)
  80. save_file<-argv[7];print(save_file)
  81. plot_manhatton(site_file,save_file)
  82.  
  83. #round(x,digits=3) keep the length of the digit

3、准备好plink跑完后的.assoc.linear文件,比如mydata.assoc.linear

4、在linux中输入以下一个命令:

其中,mydata.png即为我们想要的曼哈顿图(manhattan plot)

  1. Rscript manhattan.r mydata.assoc.linear mydata.png

R语言画全基因组关联分析中的曼哈顿图(manhattan plot)的更多相关文章

  1. 全基因组关联分析(Genome-Wide Association Study,GWAS)流程

    全基因组关联分析流程: 一.准备plink文件 1.准备PED文件 PED文件有六列,六列内容如下: Family ID Individual ID Paternal ID Maternal ID S ...

  2. 全基因组关联分析(GWAS)的计算原理

    前言 关于全基因组关联分析(GWAS)原理的资料,网上有很多. 这也是我写了这么多GWAS的软件教程,却从来没有写过GWAS计算原理的原因. 恰巧之前微博上某位小可爱提问能否写一下GWAS的计算原理. ...

  3. GWAS 全基因组关联分析 | summary statistic 概括统计 | meta-analysis 综合分析

    有很多概念需要明确区分: 人有23对染色体,其中22对常染色体autosome,另外一对为性染色体sex chromosome,XX为女,XY为男. 染色体区带命名:在标示一特定的带时需要包括4项:① ...

  4. 【GWAS文献解读】疟原虫青蒿素抗药性的全基因组关联分析

    英文名:Genetic architecture of artemisinin-resistant Plasmodium falciparum 中文名:疟原虫青蒿素抗药性的全基因组关联分析 期刊:Na ...

  5. GWAS | 全基因组关联分析 | Linkage disequilibrium (LD)连锁不平衡 | 曼哈顿图 Manhattan_plot | QQ_plot | haplotype phasing

    现在GWAS已经属于比较古老的技术了,主要是碰到严重的瓶颈了,单纯的snp与表现的关联已经不够,需要具体的生物学解释,这些snp是如何具体导致疾病的发生的. 而且,大多数病找到的都不是个别显著的snp ...

  6. 全基因组关联分析(GWAS):为何我的QQ图那么飘

    前段时间有位小可爱问我,为什么她的QQ图特别飘,如果你不理解怎样算飘,请看下图: 理想的QQ图应该是这样的: 我当时的第一反应是:1)群体分层造成的:2)表型分布有问题.因此让她检查一下数据的群体分层 ...

  7. 一行命令学会全基因组关联分析(GWAS)的meta分析

    为什么需要做meta分析 群体分层是GWAS研究中一个比较常见的假阳性来源. 也就是说,如果数据存在群体分层,却不加以控制,那么很容易得到一堆假阳性位点. 当群体出现分层时,常规手段就是将分层的群体独 ...

  8. 全基因组关联分析(GWAS)扫不出信号怎么办(文献解读)

    假如你的GWAS结果出现如下图的时候,怎么办呢?GWAS没有如预期般的扫出完美的显著信号,也就没法继续发挥后续研究的套路了. 最近,nature发表了一篇文献“Common genetic varia ...

  9. 全基因组关联分析学习资料(GWAS tutorial)

    前言 很多人问我有没有关于全基因组关联分析(GWAS)原理的书籍或者文章推荐. 其实我个人觉得,做这个分析,先从跑流程开始,再去看原理. 为什么这么说呢,因为对于初学者来说,跑流程就像一个大黑洞,学习 ...

随机推荐

  1. UEFI+GPT引导实践篇(二):UEFI引导安装64位Win7/Win8

    下文是在联想Y480笔记本上以UEFI方式启动安装Windows8的全过程,安装Windows7过程基本相同.注意,如果你的电脑硬盘是MBR分区结构,安装过程中将要删除硬盘上所有数据,请安装前备份硬盘 ...

  2. ZAM 3D 制作简单的3D字幕 流程(二)

    原地址:http://www.cnblogs.com/yk250/p/5663907.html 文中表述仅为本人理解,若有偏差和错误请指正! 接着 ZAM 3D 制作简单的3D字幕 流程(一) .本篇 ...

  3. Geodatabase数据模型

    1  Geodatabase概念 Geodatabase是ArcInfo8引入的一种全新的面向对象的空间数据模型,是建立在DBMS之上的统一的.智能的空间数据模型.“统一”是指,Geodatabase ...

  4. python多进程提高cpu利用率

    cpu参数: 1个物理cpu,2个逻辑cpu(超线程),单核 具体 http://blog.csdn.net/dba_waterbin/article/details/8644626   物理CPU. ...

  5. java简单的二分法排序

    二分法排序的思路:数据元素要按顺序排列,对于给定值 x,从序列的中间位置开始比较,如果当前位置值等于 x,则查找成功:若 x 小于当前位置值,则在数列的前半段中查找:若 x 大于当前位置值则在数列的后 ...

  6. Oracle诡异结果调查备忘 - A investigation memo of weird Oracle database search results

    最近需要维护一个差不多十多年前开发的ASP.Net程序,遇到了各种奇奇怪怪的问题,把其中比较难查明的问题记录如下: 问题一: 同样的SQL查询在不同服务器上查询结果不同.在QA环境下,结果完全正常,而 ...

  7. Linux 用户和用户组管理

    Linux 用户和用户组管理 Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统. 用户的账号一方面可以帮助 ...

  8. ThinkPad W520 在 Windows Server 2012 / R2 中安装驱动

    1.安装Intel Chipset Device Software (INF Update Utility).2.安装ThinkPad ACPI电源管理驱动.3.安装电源管理软件.4.安装英特尔核芯显 ...

  9. Media Queries详解

    Media Queries直译过来就是“媒体查询”,在我们平时的Web页面中head部分常看到这样的一段代码:  <link href="css/reset.css" rel ...

  10. java 静态代码块 构造块 构造方法

    class className{ static{ }//静态代码块 { }//构造代码块 public className(){} //构造方法 }