如何在 R 上获取此热图以不规范化我的数据?
How do I get this heatmap on R to not normalise my data?
我正在尝试在 R 热图上显示一些数据,比较跨细胞周期蛋白类型和 body 部分的表达水平。如果您查看下面的数据,您会发现大脑中细胞周期蛋白 A1 的表达与大脑中细胞周期蛋白 A2 的表达相同。
然而,当我们查看热图时,它们显示为不同的颜色。 我试过使用 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))
您的 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 创建
我正在尝试在 R 热图上显示一些数据,比较跨细胞周期蛋白类型和 body 部分的表达水平。如果您查看下面的数据,您会发现大脑中细胞周期蛋白 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))
您的 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 创建