我对pheatmap中的行缩放有些困惑。这是我的数据框
gene s1 s2 s3
1 -3.83 -8.17 -8.59
2 0.33 -4.51 -7.27
3 0.15 -5.26 -6.2
4 -0.08 -6.13 -5.95
5 -1.15 -4.82 -5.75
6 -0.99 -4.11 -4.85
7 0.42 -4.18 -4.54
8 -0.32 -3.43 -4.4
9 -0.72 -3.37 -4.39我需要在pheatmap生成带有行z得分的图形之后提取数据帧的这些值
library(pheatmap)
my_colors <- c(min(d),seq(-4,4,by=0.01),max(d))
my_palette <- c("green",colorRampPalette(colors = c("green", "red"))
(n = length(my_colors)-2), "red")
pheatmap(as.matrix(d),
scale = "row",
cluster_cols=FALSE,
cluster_rows = FALSE,
treeheight_row=0,
show_rownames=FALSE,
main = "test.txt",
color = my_palette,
breaks = my_colors)我怎样才能得到一个新的矩阵,pheatmap使用它来制作热图?
发布于 2021-11-01 19:45:15
scale_rows = function(x){
m = apply(x, 1, mean, na.rm = T)
s = apply(x, 1, sd, na.rm = T)
return((x - m) / s)
}
zscores <- scale_rows(matrix)https://github.com/raivokolde/pheatmap/blob/44a44f7e640c73867f40261691c16dfa4da34fa8/R/pheatmap.r
https://stackoverflow.com/questions/56382743
复制相似问题