美文网首页
寻找密度图峰值ggpmisc安装与使用

寻找密度图峰值ggpmisc安装与使用

作者: pumpkinC | 来源:发表于2022-12-27 13:04 被阅读0次

    ggpmisc安装

    conda install -c conda-forge r-ggpmisc
    

    寻找峰值:
    输入文件:


    image.png

    R脚本:

    library(ggplot2)
    library(ggpmisc)
    
    
    mytheme2 <- theme_bw() + theme(legend.title=element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.title.x=element_blank(), axis.text.x=element_text(size=5,angle=0), axis.text.y=element_text(size=5,angle=0),  legend.position="none",legend.key.size = unit(0.8,'cm'), legend.text = element_text(size=5,angle=0), strip.text.x = element_text(size = 5), strip.text.y = element_text(size = 3))
    
    
    data1 <- read.table("CCvsEURtype.info.lst", header = TRUE, sep="\t")
    
    p1 <-  ggplot(data1, aes(x =Dis)) +  geom_density()
    
    pb <- ggplot_build(p1)
    
    p2 <- p1 +
          stat_peaks(data = pb[['data']][[1]], aes(x = x, y = density), colour = "red", size = 1) +
          stat_peaks(data = pb[['data']][[1]], aes(x = x, y = density),  geom = "text",  angle = 0,  hjust = -0.1, colour = "red", size = 1.5) +
          mytheme2 + xlab("Types") + ylab("density")
    
    ggsave(file="GeneticDis.density.pdf", plot=p2, width = 4, height = 3)
    

    结果:


    image.png

    相关文章

      网友评论

          本文标题:寻找密度图峰值ggpmisc安装与使用

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