###manhattan plots in qqplot2
library(ggplot2)
setwd("~/ncbi/zm/XPCLR/")
read.table("LW.gene.xpclr.position.txt",header=F,sep=',')->IL
head(IL)
#V1       V2 V3     V4
#1 GRMZM2G059865 1.159389  1   4854
#2 GRMZM5G888250 1.159389  1   9882

ILp<-data.frame(ID=1:dim(IL)[1], chr=factor(IL[,3]), coord=IL[,4], p=IL[,2])

head(ILp)
#ID chr  coord        p
#1  1   1   4854 1.159389
#2  2   1   9882 1.159389

##Position is defined as position on chromosome. Need to add largest position from last marker on previous chr so that markers are ordered correctly along x-axis
chrNum=10
for(i in 1:chrNum){
  ndx<-which(ILp[,2]==i)
  lstMrk<-max(ILp[ndx,3])
  if (i < chrNum) ndx2 <- which(ILp[, 2]==i+1)
  if (i < chrNum) ILp[ndx2, 3] <- ILp[ndx2,3] + lstMrk
}
##Use this little loop to find the midposition of every chromosome so nice chr labels can be added to the plot
bpMidVec <- vector(length=chrNum)
for (i in 1:chrNum){
  ndx <- which(ILp[, 2]==i)
  posSub <- ILp[ndx, 3]
  bpMidVec[i] <- ((max(posSub) - min(posSub))/2) + min(posSub)
}
##Use qplot function in ggplot2 to create Manhattan plot
cbPalette <- c("darkgrey", "#000000","#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7","red")

tiff(filename = "LW.tif",width = 36,height = 18,units ="cm",compression="lzw",bg="white",res=300)
ggplot(ILp) + geom_point(aes(x=coord, y=p,colour=chr),show.legend = FALSE) + scale_color_manual(values=cbPalette)+#brewer(type="seq",palette="Set5")+
  scale_x_continuous(labels=as.character(1:chrNum),breaks=bpMidVec)+theme_bw(base_size=15)+labs(x="Chromosomes",y="XP-CLR score of Landraces and Wild")+ylim(0,152)
dev.off()

manhattan plots in qqplot2的更多相关文章

  1. R语言画全基因组关联分析中的曼哈顿图(manhattan plot)

    1.在linux中安装好R 2.准备好画曼哈顿图的R脚本即manhattan.r,manhattan.r内容如下: #!/usr/bin/Rscript #example : Rscript plot ...

  2. Manhattan distance(for lab)

    Input four integer x1, y1, x2, y2, which is mean that the coordinates of two points A(x1, y1), B(x2, ...

  3. bzoj 3170 manhattan距离

    首先将坐标系顺时针旋转45度,得到一个新的坐标系,这个坐标系 对应的坐标的manhattan距离就是原图中的距离,然后快排,利用前缀和 数组O(N)求所有的答案,然后找最小值就行了,总时间O(Nlog ...

  4. GWAS: 曼哈顿图,QQ plot 图,膨胀系数( manhattan、Genomic Inflation Factor)

    画曼哈顿图和QQ plot 首推R包“qqman”,简约方便.下面具体介绍以下. 一.画曼哈顿图 install.packages("qqman") library(qqman) ...

  5. pytorch visdom可视化工具学习—1—详细使用-3-Generic Plots和Others

    4)Generic Plots 注意,服务器API遵循数据和布局对象的规则,这样您就可以生成自己的任意Plotly可视化: # Arbitrary visdom content trace = dic ...

  6. matplotlib 入门之Sample plots in Matplotlib

    文章目录 Line Plot One figure, a set of subplots Image 展示图片 展示二元正态分布 A sample image Interpolating images ...

  7. 基于Manhattan最小生成树的莫队算法

    点u,v的Manhattan距离:distance(u,v)= |x2-x1|+|y2-y1| Manhattan最小生成树:边权值为两个点Manhattan距离的最小生成树. 普通算法:prim复杂 ...

  8. RLE Plots: relative log expression

    RLE Plots: Visualising Unwanted Variation in High Dimensional Data 参考:RLE Plots: Visualising Unwante ...

  9. Intermediate Python for Data Science learning 1 - Basic plots with matplotlib

    Basic plots with matplotlib from:https://campus.datacamp.com/courses/intermediate-python-for-data-sc ...

随机推荐

  1. springboot跑定时任务

    使用@Scheduled注解实现 1.在启动类上加上@EnableScheduling 开启定时任务 2.新建一个任务类,在方法上添加@Scheduled注解 @Componentpublic cla ...

  2. How to use “cat” command on “find” command's output?

    You can do this with find alone using the -exec action: find /location -size 1033c -exec cat {} + {} ...

  3. P4725 【模板】多项式对数函数

    思路 考虑对ln求导后处理 根据复合函数的求导法则\(g'(f(x))=g'(x)f'(x)\) 得到 \[ \ln F(x) '= \frac{F'(x)}{F(x)} \] 最后对这个式子积分 \ ...

  4. Learning-Python【25】:绑定方法与非绑定方法

    类中定义函数分为了两大类,绑定方法与非绑定方法,它们有一些特殊之处: 1.绑定方法特殊之处:绑定给谁就应该由谁来调用,谁来调用就会将谁当做第一个参数自动传入 绑定给对象的方法:这个在面向对象第一篇第六 ...

  5. Python3学习笔记-回忆并复述是加强记忆的好方式!

    http://bbs.fishc./thread-35584-1-1.html    #Python好好好 操作系统:linux和mac都自带Python解释器 ->-> -> ID ...

  6. VC.重定向标准输出到文件(父进程方式)

    1.libxml2 使用过程中,有时 libxml2里面会报一些错误信息,在 控制台的程序中 这些信息看起来比较乱,不易观察,我想将这些信息重定向到 文件中 1.1.本进程内:试着 将标准输出,标准错 ...

  7. openssl 交叉编译

    建立build文件夹 mkdir build 在build文件夹中建立run.sh文件 cd build touch run.sh chmod 755 run.sh run.sh文件内容如下: #!/ ...

  8. Go语言学习之9 网络协议TCP、Redis与聊天室

    主要内容 1. Tcp编程2. redis使用 1. Tcp编程 (1)简介       Golang是谷歌设计开发的语言,在Golang的设计之初就把高并发的性能作为Golang的主要特性之一,也是 ...

  9. 【转】 RGB各种格式

      转自:https://blog.csdn.net/LG1259156776/article/details/52006457?locationNum=10&fps=1 RGB组合格式 名字 ...

  10. Lab 7-3

    For this lab, we obtained the malicious executable, Lab07-03.exe, and DLL, Lab07-03.dll, prior to ex ...