- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 102 个
- 通用积分
- 35.7816
- 学术水平
- 4 点
- 热心指数
- 7 点
- 信用等级
- 2 点
- 经验
- 778 点
- 帖子
- 53
- 精华
- 0
- 在线时间
- 104 小时
- 注册时间
- 2015-9-5
- 最后登录
- 2021-12-20
|
- # log10函数把等比数列转化为等差数列
- # log10(60) + test$plus/600 处理y轴截断,ggplot2本身不支持坐标轴截断
- # 上面的函数实际是将0:600 的点拟合到 1.78:2.78上[也就是log10(60):log10(600)]
- test$plus_0 <- ifelse(test$plus <600,log10(60) + test$plus/600, log10(test$plus)) -log10(60)
- test$minus_0 <- ifelse(test$minus<600,log10(60) + test$minus/600,log10(test$minus))-log10(60)
- # 这里假设log10(60)为0
- breaks <- (log10(c(600,6000,60000,600000))-log10(60))
- labels <- c("600","6000","60000","600000")
- g.top <- ggplot(test) + geom_bar(aes(x=id,y=plus_0),fill="red",stat="identity")+
- # 调整margin位置
- theme_bw() +theme(plot.margin = unit(c(38,5,-28,6),units="points")) +
- # 设置y轴值,标签
- scale_y_continuous(expand = c(0,0),breaks=breaks,labels=labels) +
- # 去除panel网格线
- theme(panel.grid.major.x = element_blank(),panel.grid.minor.x = element_blank(),panel.grid.minor.y = element_blank())+
- # 删除lable
- labs(y="")
- g.down <- ggplot(test) + geom_bar(aes(x=id,y=minus_0),fill="blue",stat="identity")+
- # 调整margin位置,调整y轴lable位置
- theme_bw() +theme(plot.margin = unit(c(1,5,10,3),units="points"),axis.title.y = element_text(hjust =1.5)) +
- # 逆转y轴,设置y轴值,标签
- scale_y_reverse(expand = c(0,0),breaks=breaks,labels=labels) +
- # 去除panel网格线
- theme(panel.grid.major.x = element_blank(),panel.grid.minor.x = element_blank(),panel.grid.minor.y = element_blank())+
- # 设置lable
- labs(y="Reading Count",x="Chromosome") +
- # 设置lable大小,黑体 加粗
- theme(axis.title.y = element_text(face='bold',color='black',size=10)) +
- theme(axis.title.x = element_text(face='bold',color='black',size=10))
- grid.arrange(g.top,g.down, heights = c(1/2, 1/2))
复制代码
|
-
总评分: 论坛币 + 10
热心指数 + 1
查看全部评分
|