jamesbang

V1

2022/09/02阅读：320主题：雁栖湖

# 🤣 CMplot | 完美复刻Nature上的曼哈顿图（一）

## 22. 用到的包

``rm(list = ls())library(CMplot)``

## 33. 示例数据

``data(pig60K)data(cattle50K) ``

Note! 示例数据中的前三列分别是`SNP`的名称、染色体和位置，

## 44. GWAS结果展示

``CMplot(pig60K,       type="p",       plot.type="m",       LOG10=TRUE,       threshold=NULL,       file="jpg",       memo="",       dpi=300,       file.output=F,       verbose=F,       width=14,height=6,       chr.labels.angle=0)``

`"d"`SNP density plot
`"c"`circle-Manhattan plot
`"m"` → **Manhattan plot ** ✅ `"q"` → **Q-Q plot ** ✅ `"b"` → **both circle-Manhattan, Manhattan and Q-Q plots **

## 55. 修改细节

#### 5.1 更改颜色

``CMplot(pig60K,       col = c("#3E0A52", "#423D77","#3F678B",               "#468C8D", "#5FB47F", "#9FD55C","#F9E956"),       type="p",       plot.type="m",       LOG10=TRUE,       threshold=NULL,       file="jpg",       memo="",       dpi=300,       file.output=F,       verbose=F,       width=14,height=6,       chr.labels.angle=0)``

#### 5.2 标注基因

`balabala`......

``SNPs <- pig60K[pig60K[,5] < (0.05 / nrow(pig60K)), 1]genes <- paste("GENE", 1:length(SNPs), sep="_")CMplot(pig60K[,c(1:3,5)],       plot.type="m",       LOG10=TRUE,       col= c("#3E0A52", "#423D77","#3F678B",               "#468C8D", "#5FB47F", "#9FD55C","#F9E956"),       highlight = SNPs,       highlight.col = NULL,       highlight.cex = 1,       highlight.pch = c(15:17),        highlight.text = genes,             highlight.text.col = "black",       threshold = 0.05/nrow(pig60K),       amplify = FALSE,       file = "jpg",       memo = "",       dpi = 300,       file.output = F,       verbose = F,       width = 14,height = 6)``

#### 5.3 更改阈值线的颜色和类型

``CMplot(pig60K[,c(1:3,5)],       plot.type="m",       LOG10=TRUE,       col= c("#3E0A52", "#423D77","#3F678B",               "#468C8D", "#5FB47F", "#9FD55C","#F9E956"),       highlight = SNPs,       highlight.col = NULL,       highlight.cex = 1,       highlight.pch = c(15:17),        highlight.text = genes,             highlight.text.col = "black",       threshold = 0.05/nrow(pig60K),       threshold.lty = 2,        threshold.col = "black",       threshold.lwd = 3,       amplify = FALSE,       file = "jpg",       memo = "",       dpi = 300,       file.output = F,       verbose = F,       width = 14,height = 6)``

## 66. 更进一步

``CMplot(pig60K[,c(1:3,5)],       plot.type="m",       LOG10=TRUE,       col= c("#3E0A52", "#423D77","#3F678B",               "#468C8D", "#5FB47F", "#9FD55C","#F9E956"),       chr.den.col=c("darkgreen", "yellow", "red"),       highlight = SNPs,       highlight.col = NULL,       highlight.cex = 1,       highlight.pch = c(15:17),        highlight.text = genes,             highlight.text.col = "black",       threshold = 0.05/nrow(pig60K),       threshold.lty = 2,        threshold.col = "black",       threshold.lwd = 3,       amplify = FALSE,       file = "jpg",       memo = "",       dpi = 300,       file.output = F,       verbose = F,       width = 14,height = 6)``

##### jamesbang
V1

wx🔍: Grassssss 卷起来了