语言 ggplot 画热图 P值

R语言 ggplot 画热图 P值

print(temp)
数据矩阵
#使用reshape2包中melt函数将矩阵转换为ggplot需要的data.frame。
#注意:若是所有行名列名都是数字就会转换成matrix
下面展示一些 代码

// 使用scales包中melt函数将矩阵转换为ggplot需要的data.frame
library(reshape2)
temp_1<-melt(temp)
// ggplot画图
ggplot(temp_1, aes(as.factor(Var1), Var2)) + 
  	geom_tile(aes(fill = value),colour = "white") + 
  	scale_fill_gradient(name="p-value", low = "red",high = "white",breaks=c(0,0.05,1)) +
  	theme(axis.text.x = element_text(vjust = 0.5, hjust = 0.5, angle = 90))+
  	coord_fixed(ratio=1)+
  	theme(axis.text= element_text(size = 5,family="ARL"))+
  	theme(plot.margin = unit(c(0.1,0,0,0), unit="mm"))+
  	labs(x = "position", y = "motif", title = "difference distribution")+ ##调整坐标轴名字
  	theme(plot.title = element_text(size = 8,hjust = 0.5,family = "ARL" ))+
  	theme(legend.key.width=unit(3,'mm'),legend.key.height=unit(1,'cm'))+
  	theme(legend.title = element_text(size = 8)) #调整legend title的字号

做出的图大概是这样,我是将p值大于0.05都调成白色,然后有个简单的排序
在这里插入图片描述

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值