好久沒(méi)寫(xiě)博文了,分享一個(gè)為T(mén)ASSEL結(jié)果繪制曼哈頓圖的代碼:
# 加載需要的包
library(data.table) # 用于快速讀取大文件
library(CMplot) # 用于繪制圖形
# 讀取數(shù)據(jù)
Tassl.Res <- fread("mlm_output17.txt", header = T, sep = "\t")
Tassl.Res[1:5, 1:8] # 查看數(shù)據(jù)前5行,前8列忽洛。
# 提取 Mean_LS 性狀的結(jié)果腻惠,由于 Maker 較多,只繪制 Pvalue < 0.05 的 Maker
Pdat <- Tassl.Res[Tassl.Res$Trait=="Mean_LS"&Tassl.Res$p<0.05,c(2,3,4,7)]
# unique(Tassl.Res$Trait) # 查看所有的性狀
# 繪制曼哈頓圖
# 使用 threshold 系列參數(shù)欲虚,繪制了兩組閾值線(xiàn)集灌,并指定了線(xiàn)型及顏色
# 輸出出 dpi=600 的 tiff 格式圖片
CMplot(
Pdat, type = "p", plot.type = "m", LOG10 = TRUE, signal.cex = c(1, 1),
threshold = c(1e-5,4.43e-7), threshold.col = c("lightgrey", "red"),
threshold.lty = c(1,2), file="tiff", memo="Mean_LS", dpi=600,
file.output=TRUE, verbose=TRUE, width=14, height=6
)
# 繪制 QQ-plot
CMplot(
Tassl.Res[Tassl.Res$Trait=="Mean_LS", c(2,3,4,7)],
plot.type = "q", box = FALSE,file = "jpg", memo = "", dpi = 300,
conf.int = TRUE, conf.int.col = NULL, threshold.col = "red", threshold.lty = 2,
file.output = TRUE, verbose = TRUE, width = 6, height = 6
)
結(jié)果如下:
Tassel 結(jié)果曼哈頓圖
QQ-Plot
QQ 圖的結(jié)果有點(diǎn)異常,請(qǐng)忽略复哆。
歡迎大家大家關(guān)注「小劉哥」公眾號(hào)欣喧,進(jìn)行交流。