在R的pheatmap中插入多条垂直线和水平线可以通过以下步骤实现:
install.packages("pheatmap")
library(pheatmap)
data <- matrix(rnorm(100), nrow = 10)
pheatmap(data, color = colorRampPalette(c("blue", "white", "red"))(100),
labels_row = rownames(data), labels_col = colnames(data))
library(grid)
grid.lines(x = c(3, 3), y = c(0, 1), gp = gpar(col = "black", lwd = 2))
grid.lines(x = c(7, 7), y = c(0, 1), gp = gpar(col = "black", lwd = 2))
grid.lines(x = c(0, 1), y = c(5, 5), gp = gpar(col = "black", lwd = 2))
grid.lines(x = c(0, 1), y = c(8, 8), gp = gpar(col = "black", lwd = 2))
完整的代码示例:
library(pheatmap)
library(grid)
data <- matrix(rnorm(100), nrow = 10)
pheatmap(data, color = colorRampPalette(c("blue", "white", "red"))(100),
labels_row = rownames(data), labels_col = colnames(data))
grid.lines(x = c(3, 3), y = c(0, 1), gp = gpar(col = "black", lwd = 2))
grid.lines(x = c(7, 7), y = c(0, 1), gp = gpar(col = "black", lwd = 2))
grid.lines(x = c(0, 1), y = c(5, 5), gp = gpar(col = "black", lwd = 2))
grid.lines(x = c(0, 1), y = c(8, 8), gp = gpar(col = "black", lwd = 2))
这样就可以在R的pheatmap中插入多条垂直线和水平线了。请注意,以上示例中的参数和位置仅供参考,根据实际需求进行调整。
领取专属 10元无门槛券
手把手带您无忧上云