Open bakerwm opened 4 years ago
How can I change the text in annotation legend?
For example. Change the "Exp1" to "Ex^p1" in the legend.
It sames that expression( ) function is not work for this purpose: expression("Ex"^"p1").
expression( )
expression("Ex"^"p1")
library(pheatmap) # Generate some 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 = "") annotation <- data.frame(Var1 = factor(1:10 %% 2 == 0, labels = c("Exp1", "Exp2"))) rownames(annotation) <- colnames(test) # check out the row names of annotation # change the color of annotation to what you want: (eg: "navy", "darkgreen") Var1 <- c("navy", "darkgreen") names(Var1) <- c("Exp1", "Exp2") anno_colors <- list(Var1 = Var1) pheatmap(test, annotation = annotation, annotation_colors = anno_colors)
How can I change the text in annotation legend?
For example. Change the "Exp1" to "Ex^p1" in the legend.
It sames that
expression( )
function is not work for this purpose:expression("Ex"^"p1")
.