ggplot2画SNPs在染色体中的分布
2020-06-08 本文已影响0人
生信编程日常
如果想找到的功能SNPs在染色体上的展现出来分布,可以用ggplot2用一下的方式画出来(如果SNPs很少的话估计没效果):
as <- read.table('~/snps.txt', header = T)
as$chr <- factor(as$chr, c(as.character(seq(1,22)),'X'))
ggplot() +
geom_point(data = as, aes(x= chr, y=pos/1000000), color = '#B15BFF', shape = 95, size = 5, alpha = 0.2) +
labs(title = 'Distribution of SNPs across all chromosome', x = 'Chromosome', y = 'Chromosomal Position(Mb)') +
theme_bw() +
theme(plot.title = element_text(hjust = 0.5), plot.subtitle = element_text(hjust = 0.5)) +
guides(color = guide_legend(title = FALSE))
这里是用点图来实现的,geom_point()中点的形状shape=95时,就是线的形状。然后将所在位置转为高度,将其除以1000000更方便的在图中展现出来。
欢迎关注!