美文网首页计算机@linux_python_R 技术帖
ggplot2画SNPs在染色体中的分布

ggplot2画SNPs在染色体中的分布

作者: 生信编程日常 | 来源:发表于2020-06-08 23:22 被阅读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更方便的在图中展现出来。

    欢迎关注!


    相关文章

      网友评论

        本文标题:ggplot2画SNPs在染色体中的分布

        本文链接:https://www.haomeiwen.com/subject/lrcjtktx.html