增强型热图绘制R(superheat, heatmap.2, pheatmap)

目录

 

superheat

heatmap.2 

Pheatmap


superheat

superheat热图用于生成和自定义热图, 散点图,箱形图,条形图,折线图和箱形图可以与热图的列和行相邻绘制,从而增加了一层信息。

# plot a heatmap of the numerical iris variables
# cluster by species and plot Sepal.Length on the right
# save the superheat object to access the membership vectors
sh <- superheat(X = iris[,-c(1, 5)],
                yr = iris[,1],
                yr.axis.name = "Sepal.Length",
                membership.rows = iris$Species)
sh$membership.rows

 

superheat(mtcars,
          # normalize variables
          scale = T,
          # order rows/cols based on heirarchical clustering
          pretty.order.rows = TRUE,
          pretty.order.cols = TRUE,
          # plot miles per gallon next to the rows
          yr = mtcars$mpg,
          yr.axis.name = "miles per gallon",
          # plot correlation with mpg above columns
          yt = cor(mtcars)[, "mpg"],
          yt.plot.type = "bar",
          yt.axis.name = "correlation with mpg",
          # increase size of left labels
          left.label.size = 0.45)


 

heatmap.2 

可以绘制颜色差别明显的热图,并将颜色键中的对称点从0更改为1,具体可以用

library(gplots)
x = matrix(sample(seq(-1,3,by=.1),100,replace=TRUE),ncol=10)
# plot. We want -1 to 0.8 being red, 0.8 to 1.2 being black, 1.2 to 3 being green.
heatmap.2(x, col=redgreen, breaks=c(-1,0.8,1.2,3))

Pheatmap

绘制以特定点为对称点的colorbar

bk <- c(seq(0.6,0.9,by=0.01),seq(1.0,1.4,by=0.01)) #设置不对称colorbar
library(pheatmap)

pheatmap(t(value), scale="none",cluster_row =T,cluster_cols = T,
         display_numbers = sig.mat,
         color = c(colorRampPalette(colors = c("blue","white"))(length(bk)/2),colorRampPalette(colors = c("white","red"))(length(bk)/2)),
         angle_col = c('45'),
         border=FALSE,
         breaks = bk)

绘制颜色对比鲜明的热图时,breaks变换一下

pheatmap(t(value), scale="none",cluster_row =T,cluster_cols = T,
         display_numbers = sig.mat,
        color = c(colorRampPalette(colors = c("green","black"))(length(bk)/2),colorRampPalette(colors = c("black","red"))(length(bk)/2)),
        # color=colorRampPalette(c("green","black","red"))(length(bk)),
         angle_col = c('45'),
         border=FALSE,
         breaks = bk)

 


 只展示三种颜色

pheatmap(t(value), scale="none",cluster_row =T,cluster_cols = T,
         display_numbers = sig.mat,
         color=colorRampPalette(c("green","black","red"))(3),
         angle_col = c('45'),
         border=FALSE,
         breaks = c(0.6,0.95,1.05,1.4))

Ref:

https://www.it1352.com/533253.html

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值