我想更改热图多个注释的颜色。示例代码:
#test data
test = matrix(rnorm(200), 20, 10)
test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3
test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2
test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4
colnames(test) = paste("Test", 1:10, sep = "")
rownames(test) = paste("Gene", 1:20, sep = "")
#plot
annotation <- data.frame(Var1 = factor(1:10 %% 2 == 0, labels = c("Exp1", "None")), Var1 = factor(1:10 %% 2 == 0, labels = c("Exp1", "None")))
rownames(annotation) <- colnames(test) # check out the row names of annotation
pheatmap(test, annotation = annotation)
预期结果是类别中的白色和类别中的None
黑色。Exp1
Exp2