如何在R上获取此热图以不对数据进行归一化?

时间:2019-11-23 11:56:19

标签: r heatmap normalization

我正在尝试在R中的热图上显示一些数据,以比较细胞周期蛋白类型和身体部位的表达水平。如果查看下面的数据,您会发现大脑中细胞周期蛋白A1的表达与大脑中细胞周期蛋白A2的表达相同。 enter image description here 但是,当我们查看热图时,它们将显示为不同的颜色。 enter image description here我尝试使用scale参数按列进行归一化(默认值似乎是行),但这只会导致任何数据的差异都不会显示为空白(例如,脑细胞周期蛋白A1和A2为尽管表达出来却显示为白色)。

我将下面的代码附加到另一种生物上(但是使用了相同的代码)-如何最好地解决此问题?

 #Anolis carelinensis Cyclin A
    #importing data- Anolis carelinensis
    AnolisA<-read.csv(file.choose(),header=TRUE)
    #all data in the matrix must be numerical 
    #therefore I need to remove the left column
    AnolisA2<-AnolisA[-grep('X', colnames(AnolisA))]
    #converting dataframe to a matrix
    AnolisA3<-as.matrix(AnolisA2)
    #builting the heatmap
    heatmap(AnolisA3)
    #remove dendogram and reordering of columns/rows
    #no scale argument applied because we are interested in the variation 
    #between both organs and cyclin types
    heatmap(AnolisA3, Colv=NA, Rowv=NA)
    #adding axis labels
    heatmap(AnolisA3, Colv=NA, Rowv=NA, xlab="Organ", ylab="Cyclin")
    #creating a vector for column names
    rowname<-c("A1","A2")
    #altering labels
    #labRow- change row names
    rownames(AnolisA3)<-rowname
    #cexCol- alters column text size
    heatmap(AnolisA3, Colv=NA, Rowv=NA, xlab="Organ", ylab="Cyclin",cexCol=1,cexRow=1.5,margins=c(11,4))

1 个答案:

答案 0 :(得分:1)

使用scale=参数使您处在正确的轨道上。我认为这就是您在scale="none"中寻找的东西。

library(tidyverse)
df <- tribble(
  ~brain, ~heart, ~kidney, ~liver, ~skeletal,
  1, 0, 0, 0, 0,
  1, 1, 1, 0, 0
)
mat <- as.matrix(df, nrow = 2, ncol = 5)
rownames(mat) <- c("A1", "A2")
heatmap(mat, Colv=NA, Rowv=NA, xlab="Organ", ylab="Cyclin",
        scale = "none", cexCol=1,cexRow=1.5,margins=c(11,4))

reprex package(v0.3.0)于2019-11-23创建