最近在做圈状曼哈顿
但介于最近做的图还未发表文章
先给出之前已经发表了的文章的图的代码
library(tidyverse)
library(data.table)
results_log = fread("DTC10-300.txt")
select = dplyr::select
d1 = results_log %>% select(Trait,Chr,Marker,Pos,p)
summary(d1)
d1 = d1 %>% drop_na(p)
table(results_log$Trait)
##########曼哈顿图
#manhattan(d1,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
#tiff("y1-曼哈顿图.tiff")
#manhattan(d1,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
#dev.off()
########qq图
#qq(d1$p, main = "Q-Q plot of GWAS p-values : log")
#tiff("y1-QQ图.tiff")
#qq(d1$p, main = "Q-Q plot of GWAS p-values : log")
#dev.off()
library(ggplot2)
d1$Chr<-factor(d1$Chr,levels = unique(d1$Chr))
chr_len<-d1 %>%
group_by(Chr) %>%
summarise(chr_len = max(Pos))
chr_len
chr_pos<-chr_len %>%
mutate(total = cumsum(as.numeric(chr_len)) - chr_len) %>%
select(-chr_len)
Snp_pos<-chr_pos %>%
left_join(d1) %>%
arrange(Chr,Pos) %>%
mutate(Poscum = Pos + total)
library(ggsci)
library(randomcoloR)
set.seed(100)
palette <- randomColor(count = 60) #随机生成60种颜色,其实里面有重复的
palette <- distinctColorPalette(60) #差异明显的60种
x_axis<- Snp_pos %>% group_by(Chr) %>% summarize(center = (max(Poscum)+min(Poscum))/2)
x_axis$Chr<-sort(c(paste0(seq(